Faisal Vali [Sat, 15 Jun 2013 11:54:37 +0000 (11:54 +0000)]
A quick fix to allow return type deduction on member templates
by ensuring DiagnoseUseOfDecl is called both on the found decl and the
decl being used (i.e the specialization in the case of member templates) whenever they are different.
Per the exchange captured in
http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130610/081636.html
a more comprehensive fix that allows both decls to be passed into DiagnoseUseOfDecl is (or should be) forthcoming relatively soon.
Ed Schouten [Sat, 15 Jun 2013 09:40:14 +0000 (09:40 +0000)]
Emit native implementations of atomic operations on FreeBSD/armv6.
Just like on Linux, FreeBSD/armv6 assumes the system supports
ldrex/strex unconditionally. It is also used by the kernel. We can
therefore enable support for it, like we do on Linux.
While there, change one of the unit tests to explicitly test against
armv5 instead of armv7, as it actually tests whether libcalls are
emitted.
Richard Smith [Sat, 15 Jun 2013 00:30:29 +0000 (00:30 +0000)]
PR16263: Implement current direction of core issue 1376. Binding a reference to
the result of a cast-to-reference-type lifetime-extends the object to which the
reference inside the cast binds.
This requires us to look for subobject adjustments on both the inside and the
outside of the MaterializeTemporaryExpr when looking for a temporary to
lifetime-extend (which we also need for core issue 616, and possibly 1213).
Richard Smith [Fri, 14 Jun 2013 22:27:52 +0000 (22:27 +0000)]
Fix handling of const_cast from prvalue to rvalue reference: such a cast is
only permitted if the source object is of class type, and should materialize a
temporary for the reference to bind to.
Reid Kleckner [Fri, 14 Jun 2013 17:17:23 +0000 (17:17 +0000)]
[Driver] Refactor clang driver to use LLVM's Option library
The big changes are:
- Deleting Driver/(Arg|Opt)*
- Rewriting includes to llvm/Option/ and re-sorting
- 'using namespace llvm::opt' in clang::driver
- Fixing the autoconf build by adding option everywhere
As discussed in the review, this change includes using directives in
header files. I'll make follow up changes to remove those in favor of
name specifiers.
Summary:
Don't remove backslashes from block comments. Previously this
/* \ \ \ \ \ \
*/
would be turned to this:
/*
*/
which spoils some kinds of ASCII-art, people use in their comments. The behavior
was related to handling escaped newlines in block comments inside preprocessor
directives. This patch makes handling it in a more civilized way.
Chandler Carruth [Fri, 14 Jun 2013 08:57:18 +0000 (08:57 +0000)]
Fix the warning for divide by zero to be a bit more robust. ;]
Previously, it only ever fired for zeros which formed null pointers.
Now, hilariously, in C++98 this was almost anything. Including tricks
like warning on the divisor in this code:
Why the RHS of the outer divide is a null pointer constant is a sordid
tale of sorrow. Anyways, the committee fixed this for C++11 and onward
as part of core isssue 903, and Richard recently implemented this fix
causing the warning to go away here (and elsewhere).
This patch restores the warning here and adds it for numerous other
somewhat obvious gaffes:
int g(int x) {
return x / (int)(0.0);
}
The patch is essentially just using the full power of our constant
folding in Clang to produce the warning, but insisting that it must fold
to an *integer* which is zero so that we don't get false positives
anywhere.
Richard Smith [Thu, 13 Jun 2013 22:07:02 +0000 (22:07 +0000)]
Avoid fallthrough in header, to allow external users of Clang libraries to
build with Clang's -Wimplicit-fallthrough warning enabled. The fallthrough
was not making this code better.
Tim Northover [Thu, 13 Jun 2013 15:02:46 +0000 (15:02 +0000)]
Teach clang about the armv4/armv4t distinction
When choosing a default CPU, clang used to pick ARM7TDMI (which has Thumb) even
when the more restrictive armv4 triple was specified. This should fix that.
Richard Smith [Thu, 13 Jun 2013 03:23:42 +0000 (03:23 +0000)]
C++11: If a class has a user-declared copy operation or destructor, the
implicit definition of a copy operation is deprecated. Add a warning for this
to -Wdeprecated. This warning is disabled by default for now, pending
investigation into how common this situation is.
Richard Smith [Wed, 12 Jun 2013 23:38:09 +0000 (23:38 +0000)]
Simplify: we don't need any special-case lifetime extension when initializing
declarations of reference type; they're handled by the general case handling of
MaterializeTemporaryExpr.
Richard Smith [Wed, 12 Jun 2013 22:31:48 +0000 (22:31 +0000)]
PR12086, PR15117
Introduce CXXStdInitializerListExpr node, representing the implicit
construction of a std::initializer_list<T> object from its underlying array.
The AST representation of such an expression goes from an InitListExpr with a
flag set, to a CXXStdInitializerListExpr containing a MaterializeTemporaryExpr
containing an InitListExpr (possibly wrapped in a CXXBindTemporaryExpr).
This more detailed representation has several advantages, the most important of
which is that the new MaterializeTemporaryExpr allows us to directly model
lifetime extension of the underlying temporary array. Using that, this patch
*drastically* simplifies the IR generation of this construct, provides IR
generation support for nested global initializer_list objects, fixes several
bugs where the destructors for the underlying array would accidentally not get
invoked, and provides constant expression evaluation support for
std::initializer_list objects.
Richard Smith [Wed, 12 Jun 2013 21:51:50 +0000 (21:51 +0000)]
Move detection of reference members binding to temporaries from building of
CXXCtorInitializers to the point where we perform the questionable lifetime
extension. This exposed a selection of false negatives in the warning.
Richard Trieu [Wed, 12 Jun 2013 21:20:57 +0000 (21:20 +0000)]
Introducing -Wheader-guard, a warning that checks header guards actually work
properly. This warning checks that the #ifndef and #define directives at
the beginning of a header refer to the same macro name. Includes a fix-it
hint to correct the header guard.
Richard Smith [Wed, 12 Jun 2013 20:42:33 +0000 (20:42 +0000)]
Reapply r183721, reverted in r183776, with a fix for a bug in the former (we
were lacking ExprWithCleanups nodes in some cases where the new approach to
lifetime extension needed them).
Original commit message:
Rework IR emission for lifetime-extended temporaries. Instead of trying to walk
into the expression and dig out a single lifetime-extended entity and manually
pull its cleanup outside the expression, instead keep a list of the cleanups
which we'll need to emit when we get to the end of the full-expression. Also
emit those cleanups early, as EH-only cleanups, to cover the case that the
full-expression does not terminate normally. This allows IR generation to
properly model temporary lifetime when multiple temporaries are extended by the
same declaration.
We have a pre-existing bug where an exception thrown from a temporary's
destructor does not clean up lifetime-extended temporaries created in the same
expression and extended to automatic storage duration; that is not fixed by
this patch.
Pavel Labath [Wed, 12 Jun 2013 07:45:04 +0000 (07:45 +0000)]
Fix memory corruption in CStringChecker
Summary:
"register" functions for the checker were caching the checker objects in a
static variable. This caused problems when the function is called with a
different CheckerManager.
Eli Friedman [Tue, 11 Jun 2013 21:48:11 +0000 (21:48 +0000)]
Correctly handle designated initializers which modify an array initialized
with a string. This case is sort of tricky because we can't modify the
StringLiteral used to represent such initializers.
We are forced to decompose the string into individual characters.
Samuel Benzaquen [Tue, 11 Jun 2013 18:51:07 +0000 (18:51 +0000)]
Reduce the number of symbols on the object file.
Summary:
Some compilers where failing with this file because the number of symbols was above 2**15.
- Replace std::list<> and std::vector<> with plain arrays.
- Change VariadicMatcherCreateCallback to be a function template, and a
single class that wraps the instantiations.
- Remove some more unnecessary template arguments and function calls.
Insert a space at the start of a line comment in case it starts with an alphanumeric character.
Summary:
"//Test" becomes "// Test". This change is aimed to improve code
readability and conformance to certain coding styles. If a comment starts with a
non-alphanumeric character, the space isn't added, e.g. "//-*-c++-*-" stays
unchanged.
Richard Smith [Tue, 11 Jun 2013 02:41:00 +0000 (02:41 +0000)]
Rework IR emission for lifetime-extended temporaries. Instead of trying to walk
into the expression and dig out a single lifetime-extended entity and manually
pull its cleanup outside the expression, instead keep a list of the cleanups
which we'll need to emit when we get to the end of the full-expression. Also
emit those cleanups early, as EH-only cleanups, to cover the case that the
full-expression does not terminate normally. This allows IR generation to
properly model temporary lifetime when multiple temporaries are extended by the
same declaration.
We have a pre-existing bug where an exception thrown from a temporary's
destructor does not clean up lifetime-extended temporaries created in the same
expression and extended to automatic storage duration; that is not fixed by
this patch.
Eli Friedman [Tue, 11 Jun 2013 01:08:22 +0000 (01:08 +0000)]
Fix a FIXME in a testcase about packed structs and calls I left around
while fixing a related bug. The fix here was simpler than I thought it
would be.
[libclang] Allow building a precompiled preamble with compiler errors
A while ago we allowed libclang to build a PCH that had compiler errors; this was to retain the performance
afforded by a PCH even if the user's code is in an intermediate state.
Adrian Prantl [Mon, 10 Jun 2013 21:36:55 +0000 (21:36 +0000)]
cleanup (address some more review comments for r183474):
- reduce default buffer size to 64, which will still be large enough to
hold any property names found in the wild.
- get rid of the /*static*/ comments.
Jordan Rose [Mon, 10 Jun 2013 19:34:30 +0000 (19:34 +0000)]
[analyzer] SATestBuild: Don't require reference results to have logs.
The Logs directory isn't used for testing, so it's filtered out ahead of
time. However, there's then no reason to include it in version control at
all. Don't error if it's not present.
Richard Trieu [Mon, 10 Jun 2013 18:52:07 +0000 (18:52 +0000)]
Add a new warning, -Wlogical-not-parentheses, to -Wparentheses.
This warning triggers on the logical not of a non-boolean expression on the
left hand side of comparison. Often, the user meant to negate the comparison,
not just the left hand side of the comparison. Two notes are also emitted,
the first with a fix-it to add parentheses around the comparison, and the other
to put parenthesis around the not expression to silence the warning.
bool not_equal(int x, int y) {
return !x == y; // warn here
}
return !(x == y); // first fix-it, to negate comparison.
return (!x) == y; // second fix-it, to silence warning.
Reid Kleckner [Sun, 9 Jun 2013 16:45:02 +0000 (16:45 +0000)]
[CodeGen] Move EHScopeStack to CGCleanup.h from CodeGenFunction.h
No functionality change. CGCleanup.cpp provides the implementation for
EHScopeStack, so it seems more consistent to place the class definition
in CGCleanup.h.
This should also help solve a header ordering problem that I have.
Faisal Vali [Sat, 8 Jun 2013 19:47:52 +0000 (19:47 +0000)]
Fix the parser's updating of the template depth when parsing local templates and late-parsed templates.
This is a slight tweak of r180708; It avoids incrementing depth when non-template local classes nested within member templates of local classes are encountered.
This patch was LGTM'd by Doug http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130506/079656.html and passed the regression tests that normally pass (i.e. excluding many Module and Index tests on Windows that fail regardless)
Faisal Vali [Sat, 8 Jun 2013 19:39:00 +0000 (19:39 +0000)]
Revert r183618.
I ran clang-format on my patch but it seemed to have wreaked havoc with new lines - might have to do with using it on windows :( will resubmit once i've cleaned this issue up. sorry.
Faisal Vali [Sat, 8 Jun 2013 19:33:09 +0000 (19:33 +0000)]
Fix the parser's updating of the template depth when parsing local templates and late-parsed templates. This is a slight tweak of r180708; It avoids incrementing depth when non-template local classes nested within member templates of local classes are encountered.
This patch was LGTM'd by Doug http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130506/079656.html and passed the regression tests that normally pass (i.e. excluding many Module and Index tests on Windows that fail regardless)
Reid Kleckner [Sat, 8 Jun 2013 17:28:56 +0000 (17:28 +0000)]
[Sema] Make FunctionType's TSI use unadjusted argument types
This helps preserve the type-as-written in the AST, which we need for
MSVC mangling. In particular, we need to preserve the types of array
parameters in function pointer types.
The essence of this change is:
- QualType ArgTy = Param->getType();
+ QualType ArgTy = Param->getTypeSourceInfo()->getType();
... followed by the adjustment in ActOnFunctionDeclarator().