Remove a kludge from analysis based warnings that used to detect
temporaries with no-return destructors. The CFG now properly supports
temporaries and implicit destructors which both makes this kludge no
longer work, and conveniently removes the need for it.
Turn on CFG handling of implicit destructors and initializers. Several
ad-hoc benchmarks don't indicate any measurable performance impact from
growing the CFG, and it fixes real correctness problems with warnings.
As a result of turning on these CFG elements, we started to tickle an
inf-loop in the unreachable code logic used for warnings. The fix is
trivial.
Douglas Gregor [Fri, 7 Jan 2011 19:37:08 +0000 (19:37 +0000)]
Variadic templates example: a nearly-complete implementation of a TR1
tuple class template. This implementation is boosted directly from the
variadic templates proposal. N2080.
Note that one section is #ifdef'd out. I'll implement that aspect of
template argument deduction next.
Douglas Gregor [Fri, 7 Jan 2011 19:35:17 +0000 (19:35 +0000)]
When instantiating the arguments to an initializer, use the
TreeTransform version of TransformExprs() rather than explicit loop,
so that we expand pack expansions properly. Test cast coming soon...
Update AST reader/writer to handle new AppleKext.
Fix an unexpected hickup caused by exceeding size of
generated table (and a misleading comment). Improve
on help message for -fapple-kext.
Douglas Gregor [Fri, 7 Jan 2011 16:43:16 +0000 (16:43 +0000)]
Implement substitution of a function parameter pack for its set of
instantiated function parameters, enabling instantiation of arbitrary
pack expansions involving function parameter packs. At this point, we
can now correctly compile a simple, variadic print() example:
John McCall [Fri, 7 Jan 2011 01:49:06 +0000 (01:49 +0000)]
Rework a few things about how we emit ObjC's for enumeration statement.
In particular, the iteration variable (if present) should be created and
destroyed in a narrow span around the loop body, and the body should
be emitted in a cleanup scope in case it's not a compound statement.
Otherwise, rename a few variables and use phis instead of temporary
variables for the index and buffer count.
Douglas Gregor [Fri, 7 Jan 2011 00:20:55 +0000 (00:20 +0000)]
Factor out the template transformation of a sequence of function
parameters into parameter types, so that substitution of
explicitly-specified function template arguments uses the same
path. This enables the use of explicitly-specified function template
arguments with variadic templates.
Douglas Gregor [Thu, 6 Jan 2011 22:09:01 +0000 (22:09 +0000)]
Implement template argument deduction from a call to a function
template whose last parameter is a parameter pack. This allows us to
form a call to, e.g.,
John McCall [Thu, 6 Jan 2011 01:58:22 +0000 (01:58 +0000)]
Introduce an AttributedType, but don't actually use it anywhere yet.
The initial TreeTransform is a cop-out, but it's more-or-less equivalent
to what we were doing before, or rather what we're doing now and might
eventually stop doing in favor of using this type.
I am simultaneously intrigued by the possibilities of rebuilding a
dependent Attri
Douglas Gregor [Thu, 6 Jan 2011 00:33:28 +0000 (00:33 +0000)]
When default-initializing a TemplateArgumentLocInfo, make sure that we
initialize *all* of the bits to zero. Also, when the pattern of a
template argument pack expansion, make sure to set the ellipsis
location along all paths.
This should clear up the valgrind failure that popped up in Clang.
Douglas Gregor [Wed, 5 Jan 2011 23:16:57 +0000 (23:16 +0000)]
Eliminate an unnecessary dance where we tried to cope with the lack of
TypeSourceInfo when transforming a function parameter. The callees of
this routine already assume that TypeSourceInfo will be present, and
we want to always be sure that it exists.
Douglas Gregor [Wed, 5 Jan 2011 23:12:31 +0000 (23:12 +0000)]
Initial implementation of function parameter packs. This implementation allows:
1) Declaration of function parameter packs
2) Instantiation of function parameter packs within function types.
3) Template argument deduction of function parameter packs when
matching two function types.
We're missing all of the important template-instantiation logic for
function template definitions, along with template argument deduction
from the argument list of a function call, so don't even think of
trying to use these for real yet.
Douglas Gregor [Wed, 5 Jan 2011 21:11:38 +0000 (21:11 +0000)]
Add Decl::isParameterPack(), which covers both function and template
parameter packs, along with ParmVarDecl::isParameterPack(), which
looks for function parameter packs. Use these routines to fix some
obvious FIXMEs.
Douglas Gregor [Wed, 5 Jan 2011 20:52:18 +0000 (20:52 +0000)]
When we're converting deduced template arguments to the type of the
corresponding template parameter, make sure that prior converted
template arguments are available for substitution.
Douglas Gregor [Wed, 5 Jan 2011 19:06:29 +0000 (19:06 +0000)]
Eliminate two "unsupported" errors relating to variadic templates: one
for template template argument pack expansions (which was no longer
used) and another that was a placeholder for an llvm_unreachable.
Douglas Gregor [Wed, 5 Jan 2011 18:58:31 +0000 (18:58 +0000)]
Replace the representation of template template argument pack
expansions with something that is easier to use correctly: a new
template argment kind, rather than a bit on an existing kind. Update
all of the switch statements that deal with template arguments, fixing
a few latent bugs in the process. I"m happy with this representation,
now.
And, oh look! Template instantiation and deduction work for template
template argument pack expansions.
Douglas Gregor [Wed, 5 Jan 2011 17:40:24 +0000 (17:40 +0000)]
Add semantic analysis for the creation of and an AST representation
for template template argument pack expansions. This allows fun such
as:
template<template<class> class ...> struct apply_impl { /*...*/ };
template<template<class> class ...Metafunctions> struct apply {
typedef typename apply_impl<Metafunctions...>::type type;
};
However, neither template argument deduction nor template
instantiation is implemented for template template argument packs, so
this functionality isn't useful yet.
I'll probably replace the encoding of template template
argument pack expansions in TemplateArgument so that it's harder to
accidentally forget about the expansion. However, this is a step in
the right general direction.
Douglas Gregor [Wed, 5 Jan 2011 16:19:19 +0000 (16:19 +0000)]
Implement C++0x [temp.param]p11 for non-type and template template
parameter packs. Also, the "no template parameters after a template
parameter pack" rule only applies to primary class templates.
John McCall [Wed, 5 Jan 2011 12:14:39 +0000 (12:14 +0000)]
Refactor the application of type attributes so that attributes from
the declaration-specifiers and on the declarator itself are moved
to the appropriate declarator chunk. This permits a greatly
simplified model for how to apply these attributes, as well as
allowing a much more efficient query for the GC attribute.
Now all qualifier queries follow the same basic strategy of
"local qualifiers, local qualifiers on the canonical type,
then look through arrays". This can be easily optimized by
changing the canonical qualified-array-type representation.
Do not process type attributes as decl attributes on declarations
with declarators.
When computing the type of a block, synthesize a prototype
function declarator chunk if the decl-spec type was not a
function. This simplifies the logic for building block signatures.
Change the logic which inserts an objc_read_weak on a block
literal to only fire if the block has a __weak __block variable,
rather than if the return type of the block is __weak qualified,
which is not actually a sensible thing to ask.
Douglas Gregor [Wed, 5 Jan 2011 01:10:06 +0000 (01:10 +0000)]
Use Parser::ExpectAndConsume() uniformly to eat semicolons after
Objective-C declarations and statements. Fixes
<rdar://problem/8814576> (wrong source line for diagnostics about
missing ';'), and now we actually consume the ';' at the end of a
@compatibility_alias directive!
Douglas Gregor [Wed, 5 Jan 2011 00:13:17 +0000 (00:13 +0000)]
Many of the built-in operator candidates introduced into overload
resolution require that the pointed-to type be an object type, but we
weren't filtering out non-object types. Do so, fixing PR7851.
Douglas Gregor [Tue, 4 Jan 2011 23:42:36 +0000 (23:42 +0000)]
Eliminate some completely useless code that attempted to perform some
conversions on the substituted non-type template arguments of a class
template partial specialization. C++ [temp.class.spec]p8 actually
prohibits all of the cases where this code would have fired.
Hey, it's better than having to deal with variadic templates here!
Douglas Gregor [Tue, 4 Jan 2011 23:35:54 +0000 (23:35 +0000)]
Improve our handling of non-type template parameters in partial
specializations. We weren't dealing with any of the cases where the
type of the non-type template argument differs from the type of the
corresponding template parameter in the primary template. We would
think that the template parameter in the partial specialization was
not deducible (and warn about it, incorrectly), then fail to convert a
deduced parameter to the type of the template parameter in the partial
specialization (which may involve truncation, among other
things). Fixes PR8905.
Douglas Gregor [Tue, 4 Jan 2011 22:13:36 +0000 (22:13 +0000)]
Improve the checking of deduced template arguments stored within template argument packs when finishing template argument deduction for a function template
Douglas Gregor [Tue, 4 Jan 2011 18:56:13 +0000 (18:56 +0000)]
Implement name mangling for sizeof...(pack), to silence the last of
the switch-enum warnings. Test is forthcoming, once I've dealt with
some template argument deduction issues.
Implement -Wself-assign, which warns on code such as:
int x = 42;
x = x; // Warns here.
The warning avoids macro expansions, templates, user-defined assignment
operators, and volatile types, so false positives are expected to be low.
The common (mis-)use of this code pattern is to silence unused variable
warnings, but a more idiomatic way of doing that is '(void)x;'.
A follow-up to this will add a note and fix-it hint suggesting this
replacement in cases where the StmtExpr consists precisely of the self
assignment.
Enhance the diagnostic for negative array sizes to include the
declaration name of the array when present. This ensures that
a poor-man's C++03 static_assert will include the user error message
often embedded in the name.
Update all the tests to reflect the new wording, and add a test for the
name behavior.
Douglas Gregor [Tue, 4 Jan 2011 02:33:52 +0000 (02:33 +0000)]
When creating the injected-class-name for a class template involving a
non-type template parameter pack, make sure to create a pack expansion
for the corresponding template argument.
Rename MaybeSkipFunctionBodyForCodeCompletion -> trySkippingFunctionBodyForCodeCompletion and check isCodeCompletionEnabled() before doing the call.
Suggestions by Chris.
Douglas Gregor [Mon, 3 Jan 2011 21:37:45 +0000 (21:37 +0000)]
Properly rebuild pack expansions whose pattern is a non-type template
argument. As part of this, be more careful when determining if there
are any parameter packs that cannot be expanded.
Douglas Gregor [Mon, 3 Jan 2011 21:13:47 +0000 (21:13 +0000)]
Unwrap template argument packs when checking the template arguments of
a class template partial specialiation, and look through pack
expansions when checking the conditions of C++0x [temp.class.spec]p8.
Fix PR8841 by checking for both semantic and lecical dependent
contexts. This prevents -Wunused-function from firing on friend function
definitions inside of class templates for example.
Douglas Gregor [Mon, 3 Jan 2011 19:04:46 +0000 (19:04 +0000)]
Refactor the tree transform's many loops over sets of expressions
(transforming each in turn) into calls into one central routine
(TransformExprs) that transforms a list of expressions. This
refactoring is preparatory work for pack expansions whose in an
expression-list.
In the latest episode of "Deserializing bugs caused by accessors" the series reached a thrilling climax when
FunctionDecl::setPure crashed a poor user's code.
Remove the use of this accessor when deserializing, along with several other in the neighborhood. Fixes rdar://8759653.
David Greene [Mon, 3 Jan 2011 17:28:52 +0000 (17:28 +0000)]
Support lit fixes for PR8199
Replace "clang++" with "clang\+\+" because we have to escape regexp
special characters now. This is in preparation for changes to lit to
fix PR8199. Tests will fail until the lit part gets committed.
Douglas Gregor [Mon, 3 Jan 2011 09:37:44 +0000 (09:37 +0000)]
When we attempt to create a built-in that involves a library type we
don't have access to (e.g., fprintf, which needs the library type
FILE), fail with a warning and forget about the builtin
entirely. Previously, we would actually provide an error, which breaks
autoconf's super-lame checks for fprintf, longjmp, etc. Fixes PR8316.