summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclTemplate.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Teach template template argument pack expansions to keep track of theDouglas Gregor2011-01-141-1/+4
| | | | | | | number of expansions, when we know it, and propagate that information through Sema. llvm-svn: 123493
* Teach PackExpansionExpr to keep track of the number of pack expansionsDouglas Gregor2011-01-141-1/+2
| | | | | | it will expand to, if known. Propagate this information throughout Sema. llvm-svn: 123470
* Keep track of the number of expansions to be produced from a type packDouglas Gregor2011-01-141-1/+2
| | | | | | | | | | | | | | | | | | | | | | | 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
* PR3558: mark "logically const" accessor methods in ASTContext as const,Jay Foad2011-01-121-5/+5
| | | | | | | and mark the fields they use as mutable. This allows us to remove a few const_casts. llvm-svn: 123314
* Add TemplateArgument::CreatePackCopy() to create a new parameter packDouglas Gregor2011-01-111-5/+2
| | | | | | | in ASTContext-allocated memory, copying the provided template arguments. Use this new routine where we can. No functionality change. llvm-svn: 123289
* Add semantic analysis for the creation of and an AST representationDouglas Gregor2011-01-051-2/+1
| | | | | | | | | | | | | | | | | | | | | 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. llvm-svn: 122890
* Implement support for template template parameter packs, e.g.,Douglas Gregor2011-01-051-2/+3
| | | | | | | template<template<class> class ...Metafunctions> struct apply_to_each; llvm-svn: 122874
* When creating the injected-class-name for a class template involving aDouglas Gregor2011-01-041-1/+5
| | | | | | | non-type template parameter pack, make sure to create a pack expansion for the corresponding template argument. llvm-svn: 122799
* Add an AST representation for non-type template parameterDouglas Gregor2010-12-231-2/+3
| | | | | | | | | | | | | | packs, e.g., template<typename T, unsigned ...Dims> struct multi_array; along with semantic analysis support for finding unexpanded non-type template parameter packs in types, expressions, and so on. Template instantiation involving non-type template parameter packs probably doesn't work yet. That'll come soon. llvm-svn: 122527
* When forming the injected-class-name of a variadic template, theDouglas Gregor2010-12-231-9/+26
| | | | | | | | | 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). llvm-svn: 122498
* Calculate the value kind of an expression when it's created andJohn McCall2010-11-181-0/+1
| | | | | | | | | | | | | store it on the expression node. Also store an "object kind", which distinguishes ordinary "addressed" l-values (like variable references and pointer dereferences) and bitfield, @property, and vector-component l-values. Currently we're not using these for much, but I aim to switch pretty much everything calculating l-valueness over to them. For now they shouldn't necessarily be trusted. llvm-svn: 119685
* Remove broken support for variadic templates, along with the variousDouglas Gregor2010-11-071-120/+24
| | | | | | | | | | | | | abstractions (e.g., TemplateArgumentListBuilder) that were designed to support variadic templates. Only a few remnants of variadic templates remain, in the parser (parsing template type parameter packs), AST (template type parameter pack bits and TemplateArgument::Pack), and Sema; these are expected to be used in a future implementation of variadic templates. But don't get too excited about that happening now. llvm-svn: 118385
* Use the ASTMutationListener to track added template specializations in a ↵Argyrios Kyrtzidis2010-10-281-0/+16
| | | | | | chained PCH. llvm-svn: 117533
* Make AST deserialization for class template specializations lazier, byDouglas Gregor2010-10-271-0/+23
| | | | | | | not loading the specializations of a class template until some AST consumer needs them. llvm-svn: 117498
* Avoid setters in ASTDeclReader::VisitClassTemplatePartialSpecializationDecl.Argyrios Kyrtzidis2010-09-131-13/+0
| | | | llvm-svn: 113743
* Fix C++ PCH issues.Argyrios Kyrtzidis2010-09-081-7/+9
| | | | | | | | | | | PCH got a severe beating by the boost-using test case reported here: http://llvm.org/PR8099 Fix issues like: -When PCH reading, make sure Decl's getASTContext() doesn't get called since a Decl in the parent hierarchy may be initializing. -In ASTDeclReader::VisitFunctionDecl VisitRedeclarable should be called before using FunctionDecl's isCanonicalDecl() -In ASTDeclReader::VisitRedeclarableTemplateDecl CommonOrPrev must be initialized before anything else. llvm-svn: 113391
* Refactor find*Specialization functions using SpecEntryTraitsPeter Collingbourne2010-07-301-16/+17
| | | | | | | | | This patch reimplements the find*Specialization family of member functions of {Class,Function}TemplateDecl in terms of a common implementation that uses SpecEntryTraits to obtain the most recent declaration. llvm-svn: 109869
* Implement RedeclarableTemplateDecl::getNextRedeclarationPeter Collingbourne2010-07-291-0/+7
| | | | | | | This patch uses the newly added Latest field of CommonBase to provide a getNextRedeclaration() implementation for RedeclarableTemplateDecl. llvm-svn: 109756
* Store latest redeclaration for each redeclarable template declarationPeter Collingbourne2010-07-291-0/+13
| | | | | | | This patch adds a Latest field to RedeclarableTemplateDecl's CommonBase class which is used to store the latest redeclaration. llvm-svn: 109755
* Refactor redeclarable template declarationsPeter Collingbourne2010-07-291-42/+35
| | | | | | | | | | | This patch refactors much of the common code in ClassTemplateDecl and FunctionTemplateDecl into a common base class RedeclarableTemplateDecl together with support functions in a template class RedeclarableTemplate. The patch also includes similar refactoring for these classes' PCH reader and writer implementations. llvm-svn: 109754
* Remove destructors from declaration nodesDouglas Gregor2010-07-251-9/+0
| | | | llvm-svn: 109380
* Remove the vast majority of the Destroy methods from the AST library,Douglas Gregor2010-07-251-33/+0
| | | | | | since we aren't going to be calling them ever. llvm-svn: 109377
* Read/write FriendTemplateDecl for PCH.Argyrios Kyrtzidis2010-07-221-0/+5
| | | | llvm-svn: 109113
* Hide FunctionTemplateDecl's specializations folding set as implementation ↵Argyrios Kyrtzidis2010-07-201-0/+10
| | | | | | | | | | | detail and introduce FunctionTemplateDecl::findSpecialization. Redeclarations of specializations will not cause the previous decl to be removed from the set, the set will keep the canonical decl. findSpecialization will return the most recent redeclaration. llvm-svn: 108834
* Hide the specializations folding sets of ClassTemplateDecl as an ↵Argyrios Kyrtzidis2010-07-201-2/+39
| | | | | | | | | | | | | implementation detail (InsertPos leaks though) and add methods to its interface for adding/finding specializations. Simplifies its users a bit and we no longer need to replace specializations in the folding set with their redeclarations. We just return the most recent redeclarations. As a bonus, it fixes http://llvm.org/PR7670. llvm-svn: 108832
* Whenever we're creating an expression that is typically an rvalueDouglas Gregor2010-07-131-1/+1
| | | | | | | | | | | | | | | | (e.g., a call, cast, etc.), immediately adjust the expression's type to strip cv-qualifiers off of all non-class types (in C++) or all types (in C). This effectively extends my previous fix for PR7463, which was restricted to calls, to other kinds of expressions within similar characteristics. I've audited every use of getNonReferenceType() in the code base, switching to the newly-renamed getNonLValueExprType() where necessary. Big thanks to Eli for pointing out just how incomplete my original fix for PR7463 actually was. We've been handling cv-qualifiers on rvalues wrong for a very, very long time. Fixes PR7463. llvm-svn: 108253
* When performing substitution of template arguments within the body ofDouglas Gregor2010-07-081-2/+2
| | | | | | | a template, be sure to include the template arguments from the injected-class-name. Fixes PR7587. llvm-svn: 107895
* Add some side-effect free Create methods for TypeDecl subclasses and use ↵Argyrios Kyrtzidis2010-07-021-2/+9
| | | | | | them for PCH reading. llvm-svn: 107468
* Fix various bugs in recent commits for C++ PCH.Argyrios Kyrtzidis2010-06-281-1/+2
| | | | llvm-svn: 106995
* Modify ClassTemplateSpecializationDecl and ↵Argyrios Kyrtzidis2010-06-231-13/+50
| | | | | | ClassTemplatePartialSpecializationDecl to allow PCH read/write. llvm-svn: 106624
* Make it easier to read/write the template part of FunctionDecl.Argyrios Kyrtzidis2010-06-221-0/+16
| | | | | | | | | | | Introduce: -FunctionDecl::getTemplatedKind() which returns an enum signifying what kind of templated FunctionDecl it is. -An overload of FunctionDecl::setFunctionTemplateSpecialization() which accepts arrays of TemplateArguments and TemplateArgumentLocs -A constructor to TemplateArgumentList which accepts an array of TemplateArguments. llvm-svn: 106532
* Combine ClassTemplateDecl's PreviousDeclaration with CommonPtr, as in ↵Argyrios Kyrtzidis2010-06-211-29/+18
| | | | | | FunctionTemplateDecl. llvm-svn: 106412
* Initial support for reading templates from PCH.Argyrios Kyrtzidis2010-06-191-10/+18
| | | | llvm-svn: 106392
* Revert r106099; it broke self-host.Douglas Gregor2010-06-161-9/+2
| | | | llvm-svn: 106100
* Added TemplateTypeParmType::getDecl().Abramo Bagnara2010-06-161-2/+9
| | | | llvm-svn: 106099
* Don't omit class explicit instantiation from AST.Abramo Bagnara2010-06-121-1/+3
| | | | llvm-svn: 105880
* Added inherited info to template and non-type arguments of templates.Abramo Bagnara2010-06-091-2/+3
| | | | llvm-svn: 105716
* Allocate the contents of TemplateArgumentList using ASTContext's allocator. ↵Ted Kremenek2010-05-251-5/+9
| | | | | | | | | | | This fixes a massive memory leak when using a BumpPtrAllocator in ASTContext. Added a FIXME, as the Destroy method for TemplateArgumentList isn't getting called. This means we will instead leak when using the MallocAllocator. llvm-svn: 104633
* Keep track of all of the class and function template's "common"Douglas Gregor2010-05-231-3/+14
| | | | | | | | pointers in the ASTContext, so that the folding sets stored inside them will be deallocated when the ASTContext is destroyed (under -disable-free). <rdar://problem/7998824>. llvm-svn: 104465
* Renamed misleading getSourceRange -> getLocalSourceRange and ↵Abramo Bagnara2010-05-201-1/+1
| | | | | | getFullSourceRange -> getSourceRange for TypeLoc. llvm-svn: 104220
* just add a fixme for the StructuredArgs leak, it shouldn't affectChris Lattner2010-05-201-0/+1
| | | | | | c++'03 code and variadic support "needs work". llvm-svn: 104195
* switch TemplateArgumentListBuilder to hold its flat argument list in a ↵Chris Lattner2010-05-201-15/+8
| | | | | | | | | | | | | | | | | | | | | smallvector instead of new[]'d. This greatly reduces the number of new[]'s, and guess what, they were all leaked. This adds a fixme in this hunk: unsigned NumPackArgs = NumFlatArgs - PackBeginIndex; + // FIXME: NumPackArgs shouldn't be negative here??? if (NumPackArgs) - PackArgs = &FlatArgs[PackBeginIndex]; + PackArgs = FlatArgs.data()+PackBeginIndex; where test/SemaTemplate/variadic-class-template-2.cpp is accessing the vector out of range and NumPackArgs is negative. I assume variadic template args are completely hosed. llvm-svn: 104194
* fix the TemplateArgumentList copy constructor to notChris Lattner2010-05-201-5/+9
| | | | | | | be a copy constructor (since it isn't one semantically) and fix the ownership bits it sets to be correct! llvm-svn: 104192
* Clarify TemplateArgumentList ownership over its "flat" and Chris Lattner2010-05-201-12/+20
| | | | | | | "structure" arg lists, the first step to fixing some massive memory leaks. llvm-svn: 104191
* Partial and full specializations of a class template may have aDouglas Gregor2010-05-061-10/+6
| | | | | | | | | different tag kind ("struct" vs. "class") than the primary template, which has an affect on access control. Should fix the last remaining Boost.Accumulors failure. llvm-svn: 103144
* Introduce a sequence number into class template partialDouglas Gregor2010-04-301-2/+18
| | | | | | | | | | | specializations, which keeps track of the order in which they were originally declared. We use this number so that we can always walk the list of partial specializations in a predictable order during matching or template instantiation. This also fixes a failure in Boost.Proto, where SourceManager::isBeforeInTranslationUnit was behaving poorly in inconsistent ways. llvm-svn: 102693
* Make the InjectedClassNameType the canonical type of the current instantiationJohn McCall2010-04-271-1/+1
| | | | | | | | | | | | | | | | of a class template or class template partial specialization. That is to say, in template <class T> class A { ... }; or template <class T> class B<const T*> { ... }; make 'A<T>' and 'B<const T*>' sugar for the corresponding InjectedClassNameType when written inside the appropriate context. This allows us to track the current instantiation appropriately even inside AST routines. It also allows us to compute a DeclContext for a type much more efficiently, at some extra cost every time we write a template specialization (which can be optimized, but I've left it simple in this patch). llvm-svn: 102407
* Create a new InjectedClassNameType to represent bare-word references to the John McCall2010-03-101-2/+6
| | | | | | | | | | | | | injected class name of a class template or class template partial specialization. This is a non-canonical type; the canonical type is still a template specialization type. This becomes the TypeForDecl of the pattern declaration, which cleans up some amount of code (and complicates some other parts, but whatever). Fixes PR6326 and probably a few others, primarily by re-establishing a few invariants about TypeLoc sizes. llvm-svn: 98134
* Fix PR6156 and test several of the basic aspects of non-type template argumentsChandler Carruth2010-01-311-1/+2
| | | | | | when implicitly supplied to the injected class name. llvm-svn: 94948
* DeclaratorInfo -> TypeSourceInfo. Makes an effort to rename associated ↵John McCall2009-12-071-2/+2
| | | | | | | | | | | | | | | | | | | | | variables, but the results are imperfect. For posterity, I did: cat <<EOF > $cmdfile s/DeclaratorInfo/TypeSourceInfo/g s/DInfo/TInfo/g s/TypeTypeSourceInfo/TypeSourceInfo/g s/SourceTypeSourceInfo/TypeSourceInfo/g EOF find lib -name '*.cpp' -not -path 'lib/Parse/*' -exec sed -i '' -f $cmdfile '{}' \; find lib -name '*.h' -exec sed -i '' -f $cmdfile '{}' \; find include -name '*.h' -not -path 'include/clang/Parse/*' -not -path 'include/clang/Basic/*' -exec sed -i '' -f $cmdfile '{}' \; llvm-svn: 90743
OpenPOWER on IntegriCloud