This new implementation approach introduces the notion of an
"expanded" non-type template parameter pack, for which we have already
expanded the types of the parameter pack (to, say, "int*, float*",
for Outer<int*, float*>) but have not yet expanded the values. Aside
from creating these expanded non-type template parameter packs, this
patch updates template argument checking and non-type template
parameter pack instantiation to make use of the appropriate types in
the parameter pack.
John McCall [Wed, 19 Jan 2011 11:48:09 +0000 (11:48 +0000)]
When building the copy expression for a __block variable, make sure
there's a respectable point of instantiation. Also, make sure we do
this operation even when instantiating a dependently-typed variable.
John McCall [Wed, 19 Jan 2011 10:06:00 +0000 (10:06 +0000)]
Change the canonical representation of array types to store qualifiers on the
outermost array types and not on the element type. Move the CanonicalType
member from Type to ExtQualsTypeCommonBase; the canonical type on an ExtQuals
node includes the qualifiers on the ExtQuals. Assorted optimizations enabled
by this change.
getQualifiers(), hasQualifiers(), etc. should all now implicitly look through
array types.
Ted Kremenek [Tue, 18 Jan 2011 21:18:58 +0000 (21:18 +0000)]
Teach UninitializedValuesV2 to implicitly reason about C++
references by monitoring whether an access to
a variable is solely to compute it's lvalue or
to do an lvalue-to-rvalue conversion (i.e., a load).
John McCall [Tue, 18 Jan 2011 07:41:22 +0000 (07:41 +0000)]
Generalize some operations on qualifiers. QualType::getQualifiers() and
::getCVRQualifiers() now look through array types, like all the other
standard queries. Also, make a 'split' variant of getUnqualifiedType().
Convert "#pragma unused(...)" into tokens for the parser.
This allows us to cache a "#pragma unused" that occurs inside an inline C++ member function.
Fixes rdar://8829590&8770988.
Rafael Espindola [Mon, 17 Jan 2011 16:31:00 +0000 (16:31 +0000)]
Add unnamed_addr to the special strings created by
__builtin___CFStringMakeConstantString
This fixes PR8993. A darwin expert might want to check that this is safe.
This lands support for parsing virt-specifier-seq after member functions, including the
contextual keywords 'final', and 'override'. The keywords are not yet used for anything.
Francois Pichet [Sun, 16 Jan 2011 21:44:17 +0000 (21:44 +0000)]
Downgrade ext_enumerator_too_large from ExtWarn to Extension in Microsoft mode. Otherwise you can warnings flooding trying to selfhost clang with fms-extensions because of "unsigned int" -> "signed int" enumerator conversion.
Douglas Gregor [Sun, 16 Jan 2011 16:03:23 +0000 (16:03 +0000)]
Tweak the partial ordering rules for function templates to prefer a
non-variadic function template over a variadic one. This matches GCC
and the intent of the C++0x wording, in a way that I think is likely
to be acceptable to the committee.
Chris Lattner [Sun, 16 Jan 2011 08:14:11 +0000 (08:14 +0000)]
improve compatibility with GCC: when generating the ".d" filename to use
and the filename has multiple .'s in it, use the last. For example, "foo.bar.cpp"
should produce "foo.bar.d" not "foo.d". Patch by Johan Boule in PR8391
Douglas Gregor [Sat, 15 Jan 2011 06:45:20 +0000 (06:45 +0000)]
Introduce a new kind of TemplateName that captures a substituted
template template parameter pack that cannot be fully expanded because
its enclosing pack expansion could not be expanded. This form of
TemplateName plays the same role as SubstTemplateTypeParmPackType and
SubstNonTypeTemplateParmPackExpr do for template type parameter packs
and non-type template parameter packs, respectively.
We should now handle these multi-level pack expansion substitutions
anywhere. The largest remaining gap in our variadic-templates support
is that we cannot cope with non-type template parameter packs whose
type is a pack expansion.
Douglas Gregor [Sat, 15 Jan 2011 01:39:24 +0000 (01:39 +0000)]
Tweak the storage mechanism for a set of overloaded template names in
the TemplateName class. Nothing actually changes, but I find this less
objectionable (and it will factor into an upcoming change).
Douglas Gregor [Sat, 15 Jan 2011 01:15:58 +0000 (01:15 +0000)]
Introduce a new expression kind, SubstNonTypeTemplateParmPackExpr,
that captures the substitution of a non-type template argument pack
for a non-type template parameter pack within a pack expansion that
cannot be fully expanded. This follows the approach taken by
SubstTemplateTypeParmPackType.
Douglas Gregor [Fri, 14 Jan 2011 23:41:42 +0000 (23:41 +0000)]
Teach template template argument pack expansions to keep track of the
number of expansions, when we know it, and propagate that information
through Sema.
Ted Kremenek [Fri, 14 Jan 2011 22:31:31 +0000 (22:31 +0000)]
Driver: tweak handling of '--analyze' to invoke
analyzer -cc1 options that are tailored to the
input type. If the input type is "C++", we should
only run the dead stores checker (for now). Similarly,
checks specific to Objective-C should only run
on Objective-C Code.
Ted Kremenek [Fri, 14 Jan 2011 20:29:43 +0000 (20:29 +0000)]
Teach RegionStore::EnterStackFrame() to handle
the case where the called function has fewer
formal arguments than actual arguments. This
fixes a crash in the analyzer when doing
function call inlining.
Douglas Gregor [Fri, 14 Jan 2011 17:12:22 +0000 (17:12 +0000)]
When we're instantiating a direct variable initializer that has a pack
expansion in it, we may end up instantiating to an empty
expression-list. In this case, the variable is uninitialized; tweak
the instantiation logic to handle this case. Fixes PR8977.
Douglas Gregor [Fri, 14 Jan 2011 17:04:44 +0000 (17:04 +0000)]
Keep track of the number of expansions to be produced from a type pack
expansion, when it is known due to the substitution of an out
parameter pack. This allows us to properly handle substitution into
pack expansions that involve multiple parameter packs at different
template parameter levels, even when this substitution happens one
level at a time (as with partial specializations of member class
templates and the signatures of member function templates).
Note that the diagnostic we provide when there is an arity mismatch
between an outer parameter pack and an inner parameter pack in this
case isn't as clear as the normal diagnostic for an arity
mismatch. However, this doesn't matter because these cases are very,
very rare and (even then) only typically occur in a SFINAE context.
The other kinds of pack expansions (expression, template, etc.) still
need to support optional tracking of the number of expansions, and we
need the moral equivalent of SubstTemplateTypeParmPackType for
substituted argument packs of template template and non-type template
parameters.
John McCall [Fri, 14 Jan 2011 10:35:38 +0000 (10:35 +0000)]
When simplifying a cleanup's entry by merging it into a single predecessor,
replace all uses of the entry with the predecessor. There are no cleanups
relying on this right now, but if we ever want a cleanup with a phi inside
it, this will be important.
Douglas Gregor [Fri, 14 Jan 2011 02:55:32 +0000 (02:55 +0000)]
Start implementing support for substitution into pack expansions that
involve template parameter packs at multiple template levels that
occur within the signatures members of class templates (and partial
specializations thereof). This is a work-in-progress that is deficient
in several ways, notably:
- It only works for template type parameter packs, but we need to
also support non-type template parameter packs and template template
parameter packs.
- It doesn't keep track of the lengths of the substituted argument
packs in the expansion, so it can't properly diagnose length
mismatches.
However, this is a concrete step in the right direction.
Ted Kremenek [Thu, 13 Jan 2011 20:58:56 +0000 (20:58 +0000)]
Remove warning in dead stores checker for
dead stores within nested assignments. I have
never seen an actual bug found by this specific
warning, and it can lead to many false positives.
Move name mangling support from CodeGen to AST. In the
process, perform a number of refactorings:
- Move MiscNameMangler member functions to MangleContext
- Remove GlobalDecl dependency from MangleContext
- Make MangleContext abstract and move Itanium/Microsoft functionality
to their own classes/files
- Implement ASTContext::createMangleContext and have CodeGen use it
Douglas Gregor [Thu, 13 Jan 2011 18:47:47 +0000 (18:47 +0000)]
Only apply the parameter pack matching of C++0x [temp.arg.template]p3
when we're actually matching a template template argument to a
template template parameter. Otherwise, use strict matching.
Fixes <rdar://problem/8859985> clang++: variadics and out-of-line definitions.
Zhongxing Xu [Thu, 13 Jan 2011 12:30:12 +0000 (12:30 +0000)]
Support inlining base initializers. We still haven't got it completely right,
since the bindings are purged after they are set up. Need to investigate
RemoveDeadBindings algorithm.