the type of the "types" typedef is a PackExpansionType whose pattern
is Types&.
This commit introduces support for creating pack expansions for
template type arguments, as above, but not for any other kind of pack
expansion, nor for any form of instantiation.
John McCall [Sat, 18 Dec 2010 03:30:47 +0000 (03:30 +0000)]
Apply attributes to explicit specializations. Specializations which
don't provide their own explicit visibility attributes should get them
from the template. Fixes rdar://problem/8778497.
Ted Kremenek [Fri, 17 Dec 2010 05:21:58 +0000 (05:21 +0000)]
Move CocoaConventions.[h,cpp] from libChecker
to libAnalysis. Similar to Format (format string checking),
CocoaConventions has the
potential to serve clients other than the
static analyzer.
Ted Kremenek [Fri, 17 Dec 2010 04:44:43 +0000 (04:44 +0000)]
Revise Cocoa conventions detection: 'copy' and 'mutableCopy'
only indicates the create rule if it starts
at the beginning of the method name, not
within the method name.
Douglas Gregor [Thu, 16 Dec 2010 17:48:04 +0000 (17:48 +0000)]
Add tests checking for unexpanded parameter packs in declarations that
occur within statements. Teach Sema::ActOnExceptionDeclarator() to
check for unexpanded parameter packs in the exception type.
Douglas Gregor [Thu, 16 Dec 2010 15:36:43 +0000 (15:36 +0000)]
Delay the check for unexpanded parameter packs in the types of
non-type template parameters until we know that we have an actual
template declaration of some sort. This cannot be tested yet, but will
become important when we have template template parameter packs.
Ted Kremenek [Thu, 16 Dec 2010 08:22:16 +0000 (08:22 +0000)]
Tweak location of diagnostic for -Wunreachable-code
test due to recent changes to the CFG. The
diagnostic is somewhat in the wrong place, but
the -Wunreachable-code diagnostic needs to be
revamped anyway since most of the diagnostics
in this test case are redundant.
Ted Kremenek [Thu, 16 Dec 2010 07:46:53 +0000 (07:46 +0000)]
Start migration of static analyzer to using the
implicit lvalue-to-rvalue casts that John McCall
recently introduced. This causes a whole bunch
of logic in the analyzer for handling lvalues
to vanish. It does, however, raise a few issues
in the analyzer w.r.t to modeling various constructs
(e.g., field accesses to compound literals).
The .c/.m analysis test cases that fail are
due to a missing lvalue-to-rvalue cast that
will get introduced into the AST. The .cpp
failures were more than I could investigate in
one go, and the patch was already getting huge.
I have XFAILED some of these tests, and they
should obviously be further investigated.
Some highlights of this patch include:
- CFG no longer requires an lvalue bit for
CFGElements
- StackFrameContext doesn't need an 'asLValue'
flag
- The "VisitLValue" path from GRExprEngine has
been eliminated.
Besides the test case failures (XFAILed), there
are surely other bugs that are fallout from
this change.
Douglas Gregor [Thu, 16 Dec 2010 00:46:58 +0000 (00:46 +0000)]
Check for unexpanded parameter packs in using declarations. As a
drive-by, make sure to check for unexpanded parameter packs within the
name of a declaration.
Bob Wilson [Wed, 15 Dec 2010 23:36:44 +0000 (23:36 +0000)]
Implement builtins for Neon half-precision float conversions.
Also tweak the VCVT_F32_F16 entry in arm_neon.td to be more consistent with
the other floating-point conversion builtins. Radar 8068427.
ivars craeted for explicit @synthesize and those
created for auto-synthesis are @private. Fixes: // rdar://8769582
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@121913 91177308-0d34-0410-b5e6-96231b3b80d8
Douglas Gregor [Wed, 15 Dec 2010 23:18:36 +0000 (23:18 +0000)]
Check for unexpanded parameter packs in various kinds of
declarations. This is a work in progress, as I go through the C++
declaration grammar to identify where unexpanded parameter packs can
occur.
Douglas Gregor [Wed, 15 Dec 2010 21:57:59 +0000 (21:57 +0000)]
Test that all of the relevant types properly compute the "contains
unexpanded parameter pack" bit and that the recursive AST visitor can
then find those unexpanded parameter packs.
Douglas Gregor [Wed, 15 Dec 2010 19:43:21 +0000 (19:43 +0000)]
Introduce a RecursiveASTVisitor subclass that finds all unexpanded
parameter packs within a statement, type, etc. Use this visitor to
provide improved diagnostics for the presence of unexpanded parameter
packs in a full expression, base type, declaration type, etc., by
highlighting the unexpanded parameter packs and providing their names,
e.g.,
Diagnostic pragmas are broken because we don't keep track of the diagnostic state changes and we only check the current/latest state.
Problems manifest if a diagnostic is emitted for a source line that has different diagnostic state than the current state; this can affect
a lot of places, like C++ inline methods, template instantiations, the lexer, etc.
Fix the issue by having the Diagnostic object keep track of the source location of the pragmas so that it is able to know what is the diagnostic state at any given source location.
Sema: have BuildExpressionFromIntegralTemplateArgument produce well-formed IntegerLiterals
BuildExpressionFromIntegralTemplateArgument can produce malformed
IntegerLiterals with an EnumType if the template parameter type
is an EnumType. This breaks the AST printer which expects all
IntegerLiterals to have a plain integer type. Instead, give the
IntegerLiteral the enum's promotion type and wrap in an implicit cast
to the EnumType.
John McCall [Wed, 15 Dec 2010 04:42:30 +0000 (04:42 +0000)]
Sundry missing lvalue-to-rvalue conversions. Also leave a TODO for the vital
future task of performing contextual conversion to size_t in a VLA size
expression. :)
John McCall [Wed, 15 Dec 2010 04:00:32 +0000 (04:00 +0000)]
Set the "implicitly inline" bit on a method as soon as we see a definition
within the class. Teach IR gen to look for function definitions in record
lexical contexts when deciding whether to emit a function whose address
was taken. Fixes PR8789.
Douglas Gregor [Wed, 15 Dec 2010 01:34:56 +0000 (01:34 +0000)]
Variadic templates: extend the Expr class with a bit that specifies
whether the expression contains an unexpanded parameter pack, in the
same vein as the changes to the Type hierarchy. Compute this bit
within all of the Expr subclasses.
This change required a bunch of reshuffling of dependency
calculations, mainly to consolidate them inside the constructors and
to fuse multiple loops that iterate over arguments to determine type
dependence, value dependence, and (now) containment of unexpanded
parameter packs.
Again, testing is painfully sparse, because all of the diagnostics
will change and it is more important to test the to-be-written visitor
that collects unexpanded parameter packs.
John McCall [Tue, 14 Dec 2010 17:51:41 +0000 (17:51 +0000)]
Rewrite ComplexExprEvaluator::VisitCastExpr to use cast kinds, and fix
the basic casting logic to insert intermediate casts and preserve the
exact complex-cast design. Fixes a crash in the test suite.
John McCall [Tue, 14 Dec 2010 16:45:57 +0000 (16:45 +0000)]
Improve some comments, shrink FunctionType::ExtInfo, and fix a bug found
by valgrind where we were doing the wrong thing in the presence of invalid
exception specs.
John McCall [Tue, 14 Dec 2010 06:51:39 +0000 (06:51 +0000)]
Factor out most of the extra state in a FunctionProtoType into a separate
class to be passed around. The line between argument and return types and
everything else is kindof vague, but I think it's justifiable.
Douglas Gregor [Mon, 13 Dec 2010 22:49:22 +0000 (22:49 +0000)]
Variadic templates: extend Type, NestedNameSpecifier, TemplateName,
and TemplateArgument with an operation that determines whether there
are any unexpanded parameter packs within that construct. Use this
information to diagnose the appearance of the names of parameter packs
that have not been expanded (C++ [temp.variadic]p5). Since this
property is checked often (every declaration, ever expression
statement, etc.), we extend Type and Expr with a bit storing the
result of this computation, rather than walking the AST each time to
determine whether any unexpanded parameter packs occur.
This commit is deficient in several ways, which will be remedied with
future commits:
- Expr has a bit to store the presence of an unexpanded parameter
pack, but it is never set.
- The error messages don't point out where the unexpanded parameter
packs were named in the type/expression, but they should.
- We don't check for unexpanded parameter packs in all of the places
where we should.
- Testing is sparse, pending the resolution of the above three
issues.
Chandler Carruth [Mon, 13 Dec 2010 07:40:47 +0000 (07:40 +0000)]
Fix PR8774 by restricting when hasInit returns true. Previously, it
would return true if the initializer pointer union had *any* non-null
pointer in it, even if the pointer wasn't one that would actually be
returned via getInit(). This makes it more accurately model the logic of
'getInit() != NULL'.
This still isn't completely satisfying. From a principled stance,
I suspect we should make hasInit() and getInit() *always* return false
and NULL (resp.) for ParmVarDecl. We shouldn't at the API level treat
initializers and default arguments as the same thing.
Chandler Carruth [Mon, 13 Dec 2010 01:44:01 +0000 (01:44 +0000)]
Reduce the number of builtin operator overload candidates added in certain
cases. First, omit all builtin overloads when no non-record type is in the set
of candidate types. Second, avoid arithmetic type overloads for non-arithmetic
or enumeral types (counting vector types as arithmetic due to Clang
extensions). When heavily using constructs such as STL's '<<' based stream
logging, this can have a significant impact. One logging-heavy test case's
compile time dropped by 10% with this. Self-host shows 1-2% improvement in
compile time, but that's likely in the noise.
Chandler Carruth [Sun, 12 Dec 2010 21:36:11 +0000 (21:36 +0000)]
Move the functionality to mark all vtables of key functions as used within
a translation unit to the ActOnEndOfTranslationUnit function instead of doing
it at the start of DefineUsedVTables. The latter is now called *recursively*
during template instantiation, which causes an absolutely insane number of
walks of every record decl in the translation unit.
After this patch, an extremely template instantiation heavy test case's compile
time drops by 10x, and we see between 15% and 20% improvement in average
compile times across a project. This is just recovering a regression, it
doesn't make anything faster than it was several weeks ago.
Chandler Carruth [Sun, 12 Dec 2010 10:35:00 +0000 (10:35 +0000)]
Finish cleaning up the static utility code for adding builtin operator overload
candidates. They're now wrapped in nice APIs which hide the tables, etc. Also
removes some repetitive code from clients.
Chandler Carruth [Sun, 12 Dec 2010 09:59:53 +0000 (09:59 +0000)]
Clean up the helpers used to compute the usual arithmetic conversions' result
type. Localize all of the logic within a single function rather than spreading
it throughout the class.
Also fixes a buglet where we failed to check for a RHS arithmetic type wider
than the LHS and return its canonical type. I've yet to produce a test case
that breaks because of this, but it was spotted by inspection by folks on the
IRC channel and is obviously correct now.
Chandler Carruth [Sun, 12 Dec 2010 09:14:11 +0000 (09:14 +0000)]
Sink the logic to suppress builtin operator overloads in the presence of
user-defined operator overloads on the same enumeral types to the one place
where it is used.
In theory this removes wasted computation from several paths through this code,
but I'm not aware of a case where it actually matters. This is mostly for
cleanliness.
Chandler Carruth [Sun, 12 Dec 2010 08:51:33 +0000 (08:51 +0000)]
Reorder the cases in the switch to be more logically grouped (to my mind). If
others have another ordering they would prefer, I'm all ears, but this one made
it much easier for me to find the group of operators I'm interested in.