summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiate.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Only print _Bool as 'bool' when 'bool' is defined as an object-likeDouglas Gregor2011-09-271-2/+2
| | | | | | macro whose only replacement token is '_Bool'. llvm-svn: 140656
* When 'bool' is not a built-in type but is defined as a macro, printDouglas Gregor2011-09-271-2/+2
| | | | | | | 'bool' rather than '_Bool' within types, to make things a bit more readable. Fixes <rdar://problem/10063263>. llvm-svn: 140650
* ArrayRef-ifying the fields passed to Sema::ActOnFieldsDavid Blaikie2011-09-221-3/+2
| | | | llvm-svn: 140293
* ArrayRef-ifying the UnexpandedParameterPacks passed to ↵David Blaikie2011-09-221-4/+2
| | | | | | Sema::CheckParameterPacksForExpansion llvm-svn: 140290
* Implement function template specialization at class scope extension in ↵Francois Pichet2011-08-141-2/+3
| | | | | | | | | | | | | | | | | Microsoft mode. A new AST node is introduced: ClassScopeFunctionSpecialization. This node holds a FunctionDecl that is not yet specialized; then during the class template instantiation the ClassScopeFunctionSpecialization will spawn the actual function specialization. Example: template <class T> class A { public: template <class U> void f(U p) { } template <> void f(int p) { } // <== class scope specialization }; This extension is necessary to parse MSVC standard C++ headers, MFC and ATL code. BTW, with this feature in, clang can parse (-fsyntax-only) all the MSVC 2010 standard header files without any error. llvm-svn: 137573
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-16/+15
| | | | | | | | LLVM.h imports them into the clang namespace. llvm-svn: 135852
* Replace r134583's fix for PR10290 with one which also works for ↵Richard Smith2011-07-201-26/+8
| | | | | | non-value-dependent cases. llvm-svn: 135543
* Create a new expression node, SubstNonTypeTemplateParmExpr,John McCall2011-07-151-56/+53
| | | | | | | | to represent a fully-substituted non-type template parameter. This should improve source fidelity, as well as being generically useful for diagnostics and such. llvm-svn: 135243
* In an in-class initialization, defer checks for value-dependent initializationNick Lewycky2011-07-071-3/+5
| | | | | | expressions. llvm-svn: 134583
* Introduce the notion of instantiation dependence into Clang's AST. ADouglas Gregor2011-07-011-6/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | type/expression/template argument/etc. is instantiation-dependent if it somehow involves a template parameter, even if it doesn't meet the requirements for the more common kinds of dependence (dependent type, type-dependent expression, value-dependent expression). When we see an instantiation-dependent type, we know we always need to perform substitution into that instantiation-dependent type. This keeps us from short-circuiting evaluation in places where we shouldn't, and lets us properly implement C++0x [temp.type]p2. In theory, this would also allow us to properly mangle instantiation-dependent-but-not-dependent decltype types per the Itanium C++ ABI, but we aren't quite there because we still mangle based on the canonical type in cases like, e.g., template<unsigned> struct A { }; template<typename T> void f(A<sizeof(sizeof(decltype(T() + T())))>) { } template void f<int>(A<sizeof(sizeof(int))>); and therefore get the wrong answer. llvm-svn: 134225
* Preserve that a TemplateName was arrived at by substitutingJohn McCall2011-06-301-2/+3
| | | | | | | | | | | for a template template parameter. Uses to follow. I've also made the uniquing of SubstTemplateTemplateParmPacks use a ContextualFoldingSet as a minor space efficiency. llvm-svn: 134137
* When performing substitution of default template template parametersDouglas Gregor2011-06-151-2/+14
| | | | | | | | | | before the template parameters have acquired a proper context (e.g., because the enclosing context has yet to be built), provide empty parameter lists for all outer template parameter scopes to inhibit any substitution for those template parameters. Fixes PR9643 / <rdar://problem/9251019>. llvm-svn: 133055
* Implement support for C++11 in-class initialization of non-static data members.Richard Smith2011-06-111-2/+46
| | | | llvm-svn: 132878
* Made changes to how 'struct'/'class' mismatches are handled in ↵Richard Trieu2011-06-101-1/+2
| | | | | | | | | | | | | | | | | -Wmismatched-tags. - Removed fix-it hints from template instaniations since changes to the templates are rarely helpful. - Changed the caret in template instaniations from the class/struct name to the class/struct keyword, matching the other warnings. - Do not offer fix-it hints when multiple declarations disagree. Warnings are still given. - Once a definition is found, offer a fix-it hint to all previous declarations with wrong tag. - Declarations that disagree with a previous definition will get a fix-it hint to change the declaration. llvm-svn: 132831
* Add an assertion to tell us when we're going off the deep end tryingDouglas Gregor2011-05-221-2/+6
| | | | | | | | to determine outer template arguments lists for template parameters. This is actually the problem behind PR9643, which I have yet to figure out how to fix. llvm-svn: 131822
* When determining whether we need to instantiate a function type,Douglas Gregor2011-05-091-0/+6
| | | | | | | also consider whether any of the parameter types (as written, prior to decay) are dependent. Fixes PR9880 and <rdar://problem/9408413>. llvm-svn: 131099
* Modify some deleted function methods to better reflect reality:Alexis Hunt2011-05-061-2/+2
| | | | | | | | | | | | | | | | | | | | - New isDefined() function checks for deletedness - isThisDeclarationADefinition checks for deletedness - New doesThisDeclarationHaveABody() does what isThisDeclarationADefinition() used to do - The IsDeleted bit is not propagated across redeclarations - isDeleted() now checks the canoncial declaration - New isDeletedAsWritten() does what it says on the tin. - isUserProvided() now correct (thanks Richard!) This fixes the bug that we weren't catching void foo() = delete; void foo() {} as being a redefinition. llvm-svn: 131013
* Implement support for C++0x alias templates.Richard Smith2011-05-051-4/+8
| | | | llvm-svn: 130953
* Store a parameter index and function prototype depth in everyJohn McCall2011-05-011-1/+7
| | | | | | | | | | parameter node and use this to correctly mangle parameter references in function template signatures. A follow-up patch will improve the storage usage of these fields; here I've just done the lazy thing. llvm-svn: 130669
* Re-applies the patch first applied way back in r106099, withChandler Carruth2011-05-011-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | accompanying fixes to make it work today. The core of this patch is to provide a link from a TemplateTypeParmType back to the TemplateTypeParmDecl node which declared it. This in turn provides much more precise information about the type, where it came from, and how it functions for AST consumers. To make the patch work almost a year after its first attempt, it needed serialization support, and it now retains the old getName() interface. Finally, it requires us to not attempt to instantiate the type in an unsupported friend decl -- specifically those coming from template friend decls but which refer to a specific type through a dependent name. A cleaner representation of the last item would be to build FriendTemplateDecl nodes for these, storing their template parameters etc, and to perform proper instantation of them like any other template declaration. They can still be flagged as unsupported for the purpose of access checking, etc. This passed an asserts-enabled bootstrap for me, and the reduced test case mentioned in the original review thread no longer causes issues, likely fixed at somewhere amidst the 24k revisions that have elapsed. llvm-svn: 130628
* Diagnose attempts to implicitly instantiate a template before it isJohn McCall2011-04-271-2/+11
| | | | | | fully defined. Somehow this escaped notice for a very long time. llvm-svn: 130298
* Fixed source range for all DeclaratorDecl's.Abramo Bagnara2011-03-081-7/+10
| | | | llvm-svn: 127225
* When substituting in for a template name, do not produce a qualifiedDouglas Gregor2011-03-051-0/+7
| | | | | | | | | | | template name as the result of substitution. The qualifier is handled separately by the tree transformer, so we would end up in an inconsistent state. This is actually the last bit of PR9016, and possibly also fixes PR8965. It takes Boost.Icl from "epic fail" down to a single failure. llvm-svn: 127108
* When determining template instantiation arguments within a functionDouglas Gregor2011-03-051-0/+6
| | | | | | | | | | | template (not a specialization!), use the "injected" function template arguments, which correspond to the template parameters of the function template. This is required when substituting into the default template parameters of template template parameters within a function template. Fixes PR9016. llvm-svn: 127092
* Kill off TreeTransform::TransformNestedNameSpecifier() in favor of theDouglas Gregor2011-03-021-10/+0
| | | | | | | | source-location-preserving TreeTransform::TranformNestedNameSpecifierLoc(). No functionality change: the victim had no callers (that themselves had callers) anyway. llvm-svn: 126853
* Kill off the TreeTransform::TransformTemplateName overload that hasDouglas Gregor2011-03-021-60/+5
| | | | | | poor source-location information. llvm-svn: 126852
* Start migrating TreeTransform's TransformTemplateName over to versionDouglas Gregor2011-03-021-0/+62
| | | | | | | that preserve source-location information. This commit adds more redundancy than it removes; WIP. llvm-svn: 126849
* When we're substituting into a parameter-type-list nested inside the patternDouglas Gregor2011-03-021-5/+11
| | | | | | | | of an expansion, and we have a paramameter that is not a parameter pack, don't suppress substitution of parameter packs within this context. llvm-svn: 126819
* Reinstate the introduction of source-location information forDouglas Gregor2011-03-011-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | nested-name-speciciers within elaborated type names, e.g., enum clang::NestedNameSpecifier::SpecifierKind Fixes in this iteration include: (1) Compute the type-source range properly for a dependent template specialization type that starts with "template template-id ::", as in a member access expression dep->template f<T>::f() This is a latent bug I triggered with this change (because now we're checking the computed source ranges for dependent template specialization types). But the real problem was... (2) Make sure to set the qualifier range on a dependent template specialization type appropriately. This will go away once we push nested-name-specifier locations into dependent template specialization types, but it was the source of the valgrind errors on the buildbots. llvm-svn: 126765
* Revert r126748, my second attempt at nested-name-specifier sourceDouglas Gregor2011-03-011-5/+3
| | | | | | location information for elaborated types. *sigh* llvm-svn: 126753
* Reinstate r126737, extending the generation of type-source locationDouglas Gregor2011-03-011-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | information for qualifier type names throughout the parser to address several problems. The commit message from r126737: Push nested-name-specifier source location information into elaborated name types, e.g., "enum clang::NestedNameSpecifier::SpecifierKind". Aside from the normal changes, this also required some tweaks to the parser. Essentially, when we're looking at a type name (via getTypeName()) specifically for the purpose of creating an annotation token, we pass down the flag that asks for full type-source location information to be stored within the returned type. That way, we retain source-location information involving nested-name-specifiers rather than trying to reconstruct that information later, long after it's been lost in the parser. With this change, test/Index/recursive-cxx-member-calls.cpp is showing much improved results again, since that code has lots of nested-name-specifiers. llvm-svn: 126748
* Revert r126737, the most recent nested-name-specifier location change, for ↵Douglas Gregor2011-03-011-5/+3
| | | | | | buildbot breakage. llvm-svn: 126746
* Push nested-name-specifier source location information into elaboratedDouglas Gregor2011-03-011-3/+5
| | | | | | | | | | | | | | | | | | | name types, e.g., "enum clang::NestedNameSpecifier::SpecifierKind". Aside from the normal changes, this also required some tweaks to the parser. Essentially, when we're looking at a type name (via getTypeName()) specifically for the purpose of creating an annotation token, we pass down the flag that asks for full type-source location information to be stored within the returned type. That way, we retain source-location information involving nested-name-specifiers rather than trying to reconstruct that information later, long after it's been lost in the parser. With this change, test/Index/recursive-cxx-member-calls.cpp is showing much improved results again, since that code has lots of nested-name-specifiers. llvm-svn: 126737
* Use NestedNameSpecifierLoc within out-of-line variables, function, andDouglas Gregor2011-02-251-0/+11
| | | | | | | tag definitions. Also, add support for template instantiation of NestedNameSpecifierLocs. llvm-svn: 126470
* Step #2/N of __label__ support: keep pushing LabelDecl forward,Chris Lattner2011-02-171-3/+7
| | | | | | | | | | making them be template instantiated in a more normal way and make them handle attributes like other decls. This fixes the used/unused label handling stuff, making it use the same infrastructure as other decls. llvm-svn: 125771
* Inline LocalInstantiationScope::getInstantiationOf into its oneChris Lattner2011-02-171-11/+0
| | | | | | client, making room for future hacking. llvm-svn: 125770
* remove some defensive code: LocalInstantiationScope::getInstantiationOfChris Lattner2011-02-171-4/+2
| | | | | | and findInstantiationOf can never return null, even on invalid code. llvm-svn: 125769
* Teach the evaluation of the __is_convertible_to trait to translateDouglas Gregor2011-01-271-17/+52
| | | | | | | | | | | | | | | access control errors into SFINAE errors, so that the trait provides enough support to implement the C++0x std::is_convertible type trait. To get there, the SFINAETrap now knows how to set up a SFINAE context independent of any template instantiations or template argument deduction steps, and (separately) can set a Sema flag to translate access control errors into SFINAE errors. The latter can also be useful if we decide that access control errors during template argument deduction should cause substitution failure (rather than a hard error) as has been proposed for C++0x. llvm-svn: 124446
* Use attributes for all the override control specifiers.Anders Carlsson2011-01-241-3/+0
| | | | llvm-svn: 124122
* Mark classes final and/or explicit during class template instantiation.Anders Carlsson2011-01-221-0/+3
| | | | llvm-svn: 124040
* Implement support for non-type template parameter packs whose type isDouglas Gregor2011-01-191-6/+29
| | | | | | | | | | | | | | | | | | | | | a pack expansion, e.g., the parameter pack Values in: template<typename ...Types> struct Outer { template<Types ...Values> struct Inner; }; 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. llvm-svn: 123845
* Change QualType::getTypePtr() to return a const pointer, then change aJohn McCall2011-01-191-1/+1
| | | | | | thousand other things which were (generally inadvertantly) relying on that. llvm-svn: 123814
* Introduce a new kind of TemplateName that captures a substitutedDouglas Gregor2011-01-151-6/+59
| | | | | | | | | | | | | | | 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. llvm-svn: 123521
* Introduce a new expression kind, SubstNonTypeTemplateParmPackExpr,Douglas Gregor2011-01-151-4/+52
| | | | | | | | | 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. llvm-svn: 123506
* Teach template template argument pack expansions to keep track of theDouglas Gregor2011-01-141-4/+1
| | | | | | | number of expansions, when we know it, and propagate that information through Sema. llvm-svn: 123493
* Handle substitutions into function parameter packs whose patternsDouglas Gregor2011-01-141-6/+9
| | | | | | contain multiple parameter packs at different levels. llvm-svn: 123488
* Keep track of the number of expansions to be produced from a type packDouglas Gregor2011-01-141-4/+6
| | | | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 123448
* Start implementing support for substitution into pack expansions thatDouglas Gregor2011-01-141-4/+41
| | | | | | | | | | | | | | | | | 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. llvm-svn: 123425
* Work-in-progress implementation of C++0x [temp.arg.explicit]p9, whichDouglas Gregor2011-01-101-3/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | allows an argument pack determines via explicit specification of function template arguments to be extended by further, deduced arguments. For example: template<class ... Types> void f(Types ... values); void g() { f<int*, float*>(0, 0, 0); // Types is deduced to the sequence int*, float*, int } There are a number of FIXMEs in here that indicate places where we need to implement + test retained expansions, plus a number of other places in deduction where we need to correctly cope with the explicitly-specified arguments when deducing an argument pack. Furthermore, it appears that the RecursiveASTVisitor needs to be auditied; it's missing some traversals (especially w.r.t. template arguments) that cause it not to find unexpanded parameter packs when it should. The good news, however, is that the tr1::tuple implementation now works fully, and the tr1::bind example (both from N2080) is actually working now. llvm-svn: 123163
* When instantiating the arguments to an initializer, use theDouglas Gregor2011-01-071-0/+12
| | | | | | | TreeTransform version of TransformExprs() rather than explicit loop, so that we expand pack expansions properly. Test cast coming soon... llvm-svn: 123014
OpenPOWER on IntegriCloud