Douglas Gregor [Fri, 24 Dec 2010 00:15:10 +0000 (00:15 +0000)]
When instantiating a non-type template parameter pack, be sure to
extract the appropriate argument from the argument pack (based on the
current substitution index, of course). Simple instantiation of pack
expansions involving non-type template parameter packs now works.
Douglas Gregor [Thu, 23 Dec 2010 22:44:42 +0000 (22:44 +0000)]
Implement parsing of function parameter packs and non-type template
parameter packs (C++0x [dcl.fct]p13), including disambiguation between
unnamed function parameter packs and varargs (C++0x [dcl.fct]p14) for
cases like
void f(T...)
where T may or may not contain unexpanded parameter packs.
Ted Kremenek [Thu, 23 Dec 2010 21:35:43 +0000 (21:35 +0000)]
Add -fobjc-default-synthesized-properties flag
to allow us to explicitly control whether or
not Objective-C properties are default synthesized.
Currently this feature only works when using
the -fobjc-non-fragile-abi2 flag (so there is
no functionality change), but we can now turn
off this feature without turning off all the features
coupled with -fobjc-non-fragile-abi2.
Douglas Gregor [Thu, 23 Dec 2010 17:13:55 +0000 (17:13 +0000)]
Reimplement the comparison of a class template partial
specialization's template arguments against the primary template's
template arguments using the obvious, correct method of checking the
injected-class-name type (C++ [temp.class.spec]p9b3). The previous
incarnation of this comparison attempted to use its own formulation of
the injected-class-name, which is redudant and, with the introduction
of variadic templates, became wrong (again).
Douglas Gregor [Thu, 23 Dec 2010 16:00:30 +0000 (16:00 +0000)]
When forming the injected-class-name of a variadic template, the
template argument corresponding to a template parameter pack is an
argument pack of a pack expansion of that template parameter
pack. Implements C++0x [temp.dep.type]p2 (at least, as much of it as
we can).
Ted Kremenek [Thu, 23 Dec 2010 02:42:49 +0000 (02:42 +0000)]
It's amazing what you find when you actually
set the RUN line correctly in a test file!
Mark a bunch of tests for ArrayBoundCheckerV2
as FIXME's, as our current lack of pointer
arithmetic handling causes these to be all
false positives/negatives.
Douglas Gregor [Thu, 23 Dec 2010 01:52:01 +0000 (01:52 +0000)]
Implement the part of C++0x [temp.arg.explicit]p3 that pertains to
parameter packs. In particular, a parameter pack not otherwise deduced
is deduced to an empty parameter pack.
The C++0x wording here is a bit unfortunate; this should really only
apply to function templates, and it mentions "trailing" parameter
packs, which doesn't really make sense in the context of function
templates. Will file a core issue separately.
Douglas Gregor [Thu, 23 Dec 2010 01:24:45 +0000 (01:24 +0000)]
Implement the rest of C++0x [temp.deduct.type]p9, which specifies that
the presence of a pack expansion anywhere except at the end of a
template-argument-list causes the entire template-argument-list to be
a non-deduced context.
Jeffrey Yasskin [Thu, 23 Dec 2010 01:01:28 +0000 (01:01 +0000)]
Change all self assignments X=X to (void)X, so that we can turn on a
new gcc warning that complains on self-assignments and
self-initializations. Fix one bug found by the warning, in which one
clang::OverloadCandidate constructor failed to initialize its
FunctionTemplate member.
Douglas Gregor [Wed, 22 Dec 2010 23:09:49 +0000 (23:09 +0000)]
Unify the consistency checking for deduced template arguments into a
single routine. Extend that routine to handle consistency
checking for template argument packs, so that we can compare the
deduced packs for template parameter packs across different pack
expansions.
Douglas Gregor [Wed, 22 Dec 2010 21:19:48 +0000 (21:19 +0000)]
Implement template argument deduction for pack expansions whose
pattern is a template argument, which involves repeatedly deducing
template arguments using the pattern of the pack expansion, then
bundling the resulting deductions into an argument pack.
We can now handle a variety of simple list-handling metaprograms using
variadic templates. See, e.g., the new "count" metaprogram.
Move AnalysisConsumer.cpp and ExprEngine.cpp into the Checkers subdir temporarily
to avoid cyclic dependency between the libraries and fix the linux build.
Douglas Gregor [Wed, 22 Dec 2010 18:55:49 +0000 (18:55 +0000)]
When performing template argument deduction where the argument is a
dependent template specialization type, the number of template
arguments need not match precisely. Rather than checking the number of
arguments eagerly (which does not consider argument packs), let the
deduction routine for template argument lists cope with too many/too
few arguments.
Douglas Gregor [Wed, 22 Dec 2010 18:17:10 +0000 (18:17 +0000)]
Implicitly expand argument packs when performing template argument
deduction. Unify all of the looping over template arguments for
deduction purposes into a single place, where argument pack expansion
occurs; this is also the hook for deducing from pack expansions, which
itself is not yet implemented.
For now, at least we can handle a basic "count" metafunction written
with variadics. See the new test for the formulation that works.
Zhongxing Xu [Wed, 22 Dec 2010 07:20:27 +0000 (07:20 +0000)]
After inlining the CXXConstructExpr, bind the temporary object region to it.
This change is necessary when the variable is a const reference and we need
the l-value of the construct expr. After that, when binding the variable,
recover the lazy compound value when the variable is not a reference.
In Environment, use the value of a no-op cast expression when it has one.
Otherwise, blast-through it.
Francois Pichet [Wed, 22 Dec 2010 03:46:10 +0000 (03:46 +0000)]
Redesign the way anonymous fields are handled in designated-initializers.
Previously designated anonymous fields were found via name lookup. This redesign uses the fact that an IndirectFieldDecl declaration will always follow an anonymous implicit field to remove the special case of name lookup.
Douglas Gregor [Tue, 21 Dec 2010 22:27:23 +0000 (22:27 +0000)]
Tweak the checking of class template partial specialization arguments
to cope with parameter packs. This is a band-aid I will be
revisiting this section when I implement declaration matching
semantics for variadic templates.
Douglas Gregor [Tue, 21 Dec 2010 21:40:41 +0000 (21:40 +0000)]
For member pointer conversions potentially involving derived-to-base
conversions, make sure that the (possibly) derived type is complete
before looking for base classes.
Douglas Gregor [Tue, 21 Dec 2010 19:47:46 +0000 (19:47 +0000)]
In C++, if the user redeclares a builtin function with a type that is
inconsistent with the type that the builtin *should* have, forget
about the builtin altogether: we don't want subsequence analyses,
CodeGen, etc., to think that we have a proper builtin function.
C is protected from errors here because it allows one to use a
library builtin without having a declaration, and detects inconsistent
(re-)declarations of builtins during declaration merging. C++ was
unprotected, and therefore would crash.
Douglas Gregor [Tue, 21 Dec 2010 19:07:48 +0000 (19:07 +0000)]
When determining which preprocessed entities to traverse in libclang,
take into account the region of interest. Otherwise, we may fail to
traverse some important preprocessed entity cursors.
Fixes <rdar://problem/8554072>.
Douglas Gregor [Tue, 21 Dec 2010 17:34:17 +0000 (17:34 +0000)]
Fix a major inconsistency in the representation of Objective-C
classes, categories, protocols, and class extensions, where the
methods and properties of these entities would be inserted into the
DeclContext in an ordering that doesn't necessarily reflect source
order. The culprits were Sema::ActOnMethodDeclaration(), which did not
perform the insertion of the just-created method declaration into
the DeclContext for these Objective-C entities, and
Sema::ActOnAtEnd(), which inserted all method declarations at the
*end* of the DeclContext.
With this fix in hand, clean up the code-completion actions for
property setters/getters that worked around this brokenness in the AST.
Fixes <rdar://problem/8062781>, where this problem manifested as poor
token-annotation information, but this would have struck again in many
other places.
Douglas Gregor [Tue, 21 Dec 2010 16:27:07 +0000 (16:27 +0000)]
Implement BlockDecl::getSourceRange(). The bogus source-range
information caused token-annotation to fail in funny ways. Fixes
<rdar://problem/8595386>.
Douglas Gregor [Tue, 21 Dec 2010 07:55:45 +0000 (07:55 +0000)]
Teach clang_getCursorSemanticParent() and
clang_getCursorLexicalParent() to cope with class and function
templates, along with the parent of the translation unit. Fixes PR8761
and PR8766.
John McCall [Tue, 21 Dec 2010 00:44:39 +0000 (00:44 +0000)]
Fix the noreturn conversion to only strip off a single level of indirection.
Apply the noreturn attribute while creating a builtin function's type.
Remove the getNoReturnType() API.
Warn when message is sent to receiver of
unknown type and there is a possibility that
at runtime method is resolved to a deprecated or
unavailable method. Addreses // rdar://8769853
Douglas Gregor [Mon, 20 Dec 2010 23:36:19 +0000 (23:36 +0000)]
Further refactoring of the tree transformation for template argument
lists, so that all such transformations go through a single,
iterator-based transformation function. This is the only place where
we need to implement the logic for transforming pack expansions whose
pattern is a template argument.
Unfortunately, the new cases this refactoring brings into the fold
can't be meaningfully tested yet. We need template argument deduction
to work well enough for variadic function templates first.
Douglas Gregor [Mon, 20 Dec 2010 23:07:20 +0000 (23:07 +0000)]
Give the RecursiveASTVisitor a configuration function
shouldWalkTypesOfTypeLocs() that determines whether it should walk the
Types within TypeLocs. This walk is redundant, but perhaps required
for some clients. Disabling this redundant walk in the unexpanded
parameter pack finder produces better results, because we get
parameter packs with source location info *unless* such source
location information isn't available.
Rafael Espindola [Mon, 20 Dec 2010 22:45:09 +0000 (22:45 +0000)]
Fix PR8639 by making the "argument unused during compilation" less agressive. Now we
don't warn if an argument is not used because it is shadowed by a subsequent argument.
where OuterTypes and InnerTypes are template type parameter packs.
There is a horrible inefficiency in
TemplateArgumentLoc::getPackExpansionPattern(), where we need to
create copies of TypeLoc data because our interfaces traffic in
TypeSourceInfo pointers where they should traffic in TypeLocs
instead. I've isolated in efficiency in this one routine; once we
refactor our interfaces to traffic in TypeLocs, we can eliminate it.
Douglas Gregor [Mon, 20 Dec 2010 16:57:52 +0000 (16:57 +0000)]
When checking a template argument list against a template containing
a parameter pack, check the parameter pack against each of the
template arguments it corresponds to, then pack the converted
arguments into a template argument pack. Allows us to use variadic
class templates so long as instantiation isn't required, e.g.,
Douglas Gregor [Mon, 20 Dec 2010 16:52:59 +0000 (16:52 +0000)]
Clean up the handling of template argument packs, especially in the
area of printing template arguments. The functionality changes here
are limited to cases of variadic templates that aren't yet enabled.
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.