Jim Grosbach [Fri, 10 Feb 2012 20:37:10 +0000 (20:37 +0000)]
Have the driver pass CPU and target feature information to cc1as.
When creating the MCSubtargetInfo, the assembler driver uses the CPU and
feature string to construct a more accurate model of what instructions
are and are not legal.
Douglas Gregor [Fri, 10 Feb 2012 17:46:20 +0000 (17:46 +0000)]
Allow implicit capture of 'this' in a lambda even when the capture
default is '=', and reword the warning about explicitly capturing
'this' in such lambdas to indicate that only explicit capture is
banned.
Introduce Fix-Its for this and other "save the programmer from
themself" rules regarding what can be explicitly captured and what
must be implicitly captured.
Douglas Gregor [Fri, 10 Feb 2012 16:48:36 +0000 (16:48 +0000)]
Add test from [expr.prim.lambda]p12, which deals with odr-use and
nested captures. We currently don't get odr-use correct in array
bounds, so that bit is commented out while we sort out what we need to
do.
Douglas Gregor [Fri, 10 Feb 2012 16:13:20 +0000 (16:13 +0000)]
Don't introduce a lambda's operator() into the class until after we
have finished parsing the body, so that name lookup will never find
anything within the closure type. Then, add this operator() and the
conversion function (if available) before completing the class.
Richard Smith [Fri, 10 Feb 2012 11:05:11 +0000 (11:05 +0000)]
PR11684, core issue 1417:
o Correct the handling of the restrictions on usage of cv-qualified and
ref-qualified function types.
o Fix a bug where such types were rejected in template type parameter default
arguments, due to such arguments not being treated as a template type arg
context.
o Remove the ExtWarn for usage of such types as template arguments; that was
a standard defect, not a GCC extension.
o Improve the wording and unify the code for diagnosing cv-qualifiers with the
code for diagnosing ref-qualifiers.
Richard Smith [Fri, 10 Feb 2012 09:58:53 +0000 (09:58 +0000)]
Track whether a function type has a trailing return type as type sugar. Use this
to pretty-print such function types better, and to fix a case where we were not
instantiating templates in lexical order. In passing, move the Variadic bit from
Type's bitfields to FunctionProtoType to get the Type bitfields down to 32 bits.
Also ensure that we always substitute the return type of a function when
substituting explicitly-specified arguments, since that can cause us to bail
out with a SFINAE error before we hit a hard error in parameter substitution.
Evgeniy Stepanov [Fri, 10 Feb 2012 09:30:15 +0000 (09:30 +0000)]
Fix function prolog codegen whe coerce-to type is a struct.
This changes function prolog in such a way as to avoid out-of-bounds
stack store in the case when coerce-to type has a larger storage size
than the real argument type.
Douglas Gregor [Fri, 10 Feb 2012 09:26:04 +0000 (09:26 +0000)]
Add various tests for captures and the reaching scope of the lambda
expression. Implement C++11 [expr.prim.lambda]p12's requirement that
capturing a variable will odr-use it.
Douglas Gregor [Fri, 10 Feb 2012 07:45:31 +0000 (07:45 +0000)]
Extend CXXRecordDecl with a function that determines the mapping from
the variables captured by a lambda to the fields that store the
captured values. To be used in IRgen.
Richard Smith [Fri, 10 Feb 2012 07:41:06 +0000 (07:41 +0000)]
Update to new resolution for DR1458. When taking the address of an object of
incomplete class type which has an overloaded operator&, it's now just
unspecified whether the overloaded operator or the builtin is used.
David Blaikie [Fri, 10 Feb 2012 05:15:16 +0000 (05:15 +0000)]
Move -Wswitch from -Wmost to -Wall, consitent with GCC.
This is a relatively noisy warning for a codebase not explicitly designed for
it (effectively enforcing a stylistic constraint about the use of defaults
in switches over enums) & there's nothing Clang does to clean up the noise
when compared to GCC's implementation so the same decision seems suitable.
Ted Kremenek [Fri, 10 Feb 2012 02:45:47 +0000 (02:45 +0000)]
Revert r145999. This turned out to be a bad idea. Unfortunately, 'id' is used so profusely
in many APIs and large codebases that this made the deprecated warning trigger happy to
the point of not being useful.
objc: If a method is not implemented in the category implementation but
has been declared in its primary class, superclass,
or in one of their protocols, no need to issue unimplemented method.
// rdar://10823023
Akira Hatanaka [Thu, 9 Feb 2012 19:54:16 +0000 (19:54 +0000)]
Class objects passed by value follow the same rules as structure objects.
Double fields of by-value class objects should be passed in floating point
registers.
Douglas Gregor [Thu, 9 Feb 2012 10:18:50 +0000 (10:18 +0000)]
Implement return type deduction for lambdas per C++11
[expr.prim.lambda]p4, including the current suggested resolution of
core isue 975, which allows multiple return statements so long as the
types match. ExtWarn when user code is actually making use of this
extension.
Douglas Gregor [Thu, 9 Feb 2012 08:52:43 +0000 (08:52 +0000)]
Restore the appropriate lexical declaration context for a lambda's
function call operator (to the lambda class). This allows us to IRgen
calls to simple (non-capturing) lambdas, e.g.,
[](int i, int j) -> int { return i + j; }(1, 2)
Eli will be providing test cases as he brings up more IRgen.
Douglas Gregor [Thu, 9 Feb 2012 08:14:43 +0000 (08:14 +0000)]
Implement C++ [expr.prim.lambda]p2, which bans lambda expressions in
unevaluated operands. Be certain that we're marking everything
referenced within a capture initializer as odr-used.
We were passing a decl to the consumer after all pending deserializations were finished
but this was not enough; due to processing by the consumer we may end up into yet another
deserialization process but the way FinishedDeserializing() was setup we would not ensure
that everything was fully deserialized before returning to the consumer.
Separate ASTReader::FinishedDeserializing() into two semantic actions.
The first is ensuring that a deserialization process ends up will fully deserialized decls/types even
if the process is started by the consumer.
The second is pushing "interesting" decls to the consumer; we make sure that we don't re-enter this
section recursively be checking a variable.
Don't cache the artificial type for the this pointer, there's no
difference in the qual type. This is a workaround for the fact that
the type isn't artificial but the this decl is, however, we don't
have any way of representing it in the current metadata. For now,
however, just don't cache the full type.
Fixes rdar://10831526 and probably a couple of others.
Richard Smith [Thu, 9 Feb 2012 06:40:58 +0000 (06:40 +0000)]
DR1359: A constexpr constructor does not need to initialize an empty struct or
empty union. This still rejects anonymous member structs or unions which only
contain such empty class types, pending standard wording defining exactly what
an empty class type is.
[PCH] Set the DeclContext before doing any deserialization, to make sure internal
calls to Decl::getASTContext() by Decl's methods will find the TranslationUnitDecl
without crashing due to a parent declaration context still deserializing.
David Blaikie [Thu, 9 Feb 2012 03:57:02 +0000 (03:57 +0000)]
Correct comment Clang C++ use in production.
This was from way-back-when (r82583) when Clang's C++ support wasn't prime-time
yet. Production quality C++ was tested experimentally from r100119 and turned
on by default in r141063.
[PCH] Avoid using Decl::setAttrs() and Decl::setLexicalDeclContext() from the ASTReaderDecl
directly; they internally call Decl::getASTContext() which may crash if a declaration context
parent is still deserializing.
Douglas Gregor [Thu, 9 Feb 2012 00:47:04 +0000 (00:47 +0000)]
Various interrelated cleanups for lambdas:
- Complete the lambda class when we finish the lambda expression
(previously, it was left in the "being completed" state)
- Actually return the LambdaExpr object and bind to the resulting
temporary when needed.
- Detect when cleanups are needed while capturing a variable into a
lambda (e.g., due to default arguments in the copy constructor), and
make sure those cleanups apply for the whole of the lambda
expression.
Anna Zaks [Wed, 8 Feb 2012 23:16:56 +0000 (23:16 +0000)]
[analyzer] MallocChecker: implement pessimistic version of the checker,
which allows values to escape through unknown calls.
Assumes all calls but the malloc family are unknown.
Also, catch a use-after-free when a pointer is passed to a
function after a call to free (previously, you had to explicitly
dereference the pointer value).
Douglas Gregor [Wed, 8 Feb 2012 20:56:50 +0000 (20:56 +0000)]
When computing the type of a local variable reference within a lambda,
only add 'const' for variables captured by copy in potentially
evaluated expressions of non-mutable lambdas. (The "by copy" part was
missing).
Richard Smith [Wed, 8 Feb 2012 08:11:33 +0000 (08:11 +0000)]
Implement DR1458: Taking the address of an object of incomplete class type is
not a constant expression, because we can't tell whether the complete class type
will have an overloaded operator&.
Richard Smith [Wed, 8 Feb 2012 06:14:53 +0000 (06:14 +0000)]
Implement the agreed resolution to DR1457: a signed left shift of a 1 bit into
the sign bit doesn't have undefined behavior, but a signed left shift of a 1 bit
out of the sign bit still does. As promised to Howard :)
The suppression of the potential constant expression checking in system headers
is also removed, since the problem it was working around is gone.
Ted Kremenek [Wed, 8 Feb 2012 05:08:58 +0000 (05:08 +0000)]
Move -Wcovered-switch-default out of -Wswitch (and -Wall), and make it an opt-in warning.
This is a great warning, but it was observed that a ton of real world code violates
it all the time for (semi-)legitimate reasons. This warnings is fairly pedantic, which is good,
but not for everyone. For example, there is a fair amount of idiomatic code out there
that does "default: abort()", and similar idioms.
Ted Kremenek [Wed, 8 Feb 2012 04:32:34 +0000 (04:32 +0000)]
Change PathDiagnosticPieces to be reference counted (simplifying their management), and introduce 'PathPieces' as a common container for PathDiagnosticPieces.