summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclTemplate.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Centralize and complete the computation of value- and type-dependence for ↵Douglas Gregor2009-11-231-3/+1
| | | | | | DeclRefExprs llvm-svn: 89649
* Encapsulate "an array of TemplateArgumentLocs and two angle bracket ↵John McCall2009-11-231-1/+2
| | | | | | | | | | locations" into a new class. Use it pervasively throughout Sema. My fingers hurt. llvm-svn: 89638
* Introduce a new representation for template templateDouglas Gregor2009-11-111-6/+1
| | | | | | | | | | | | | | | | | | | | | | | | | parameters. Rather than storing them as either declarations (for the non-dependent case) or expressions (for the dependent case), we now (always) store them as TemplateNames. The primary change here is to add a new kind of TemplateArgument, which stores a TemplateName. However, making that change ripples to every switch on a TemplateArgument's kind, also affecting TemplateArgumentLocInfo/TemplateArgumentLoc, default template arguments for template template parameters, type-checking of template template arguments, etc. This change is light on testing. It should fix several pre-existing problems with template template parameters, such as: - the inability to use dependent template names as template template arguments - template template parameter default arguments cannot be instantiation However, there are enough pieces missing that more implementation is required before we can adequately test template template parameters. llvm-svn: 86777
* Track source information for template arguments and template specializationJohn McCall2009-10-291-4/+15
| | | | | | | types. Preserve it through template instantiation. Preserve it through PCH, although TSTs themselves aren't serializable, so that's pretty much meaningless. llvm-svn: 85500
* Extract TemplateArgument into a new header just for common templateJohn McCall2009-10-291-28/+0
| | | | | | | | classes. Move its implementation into a new module. This will seem marginally more justified in a bit. llvm-svn: 85499
* Implement support for semantic checking and template instantiation ofDouglas Gregor2009-10-291-0/+23
| | | | | | | | class template partial specializations of member templates. Also, fixes a silly little bug in the marking of "used" template parameters in member templates. Fixes PR5236. llvm-svn: 85447
* Correct a comment.Sebastian Redl2009-10-231-1/+1
| | | | llvm-svn: 84973
* Canonicality is a property of qualified types, not unqualified types.John McCall2009-10-221-1/+1
| | | | llvm-svn: 84891
* WIP implementation of explicit function template specialization. ThisDouglas Gregor2009-09-241-0/+6
| | | | | | | | | | | | | | | | | | | | | first implementation recognizes when a function declaration is an explicit function template specialization (based on the presence of a template<> header), performs template argument deduction + ambiguity resolution to determine which template is being specialized, and hooks There are many caveats here: - We completely and totally drop any explicitly-specified template arguments on the floor - We don't diagnose any of the extra semantic things that we should diagnose. - I haven't looked to see that we're getting the right linkage for explicit specializations On a happy note, this silences a bunch of errors that show up in libstdc++'s <iostream>, although Clang still can't get through the entire header. llvm-svn: 82728
* Improved representation and support for friend class templates. Angst about ↵John McCall2009-09-161-0/+16
| | | | | | same. llvm-svn: 82088
* Implement partial ordering of class template partial specializations Douglas Gregor2009-09-151-3/+4
| | | | | | (C++ [temp.class.order]). llvm-svn: 81866
* When stringizing a NamedDecl for a diagnostic, treat the templateJohn McCall2009-09-111-0/+13
| | | | | | specialization types differently. llvm-svn: 81512
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-44/+44
| | | | llvm-svn: 81346
* Remove TypeSpecStartLocation from VarDecl/FunctionDecl/FieldDecl, and use ↵Argyrios Kyrtzidis2009-08-211-4/+2
| | | | | | DeclaratorInfo to get this information. llvm-svn: 79584
* Introduce DeclaratorDecl and pass DeclaratorInfo through the Decl/Sema ↵Argyrios Kyrtzidis2009-08-191-1/+2
| | | | | | | | | | | | interfaces. DeclaratorDecl contains a DeclaratorInfo* to keep type source info. Subclasses of DeclaratorDecl are FieldDecl, FunctionDecl, and VarDecl. EnumConstantDecl still inherits from ValueDecl since it has no need for DeclaratorInfo. Decl/Sema interfaces accept a DeclaratorInfo as parameter but no DeclaratorInfo is created yet. llvm-svn: 79392
* Keep track of the template arguments deduced when matching a classDouglas Gregor2009-08-021-0/+16
| | | | | | | | template partial specialization. Then, use those template arguments when instantiating members of that class template partial specialization. Fixes PR4607. llvm-svn: 77925
* Support out-of-line definitions of the members of class templateDouglas Gregor2009-07-301-0/+15
| | | | | | partial specializations. llvm-svn: 77606
* Make tag declarations redeclarable. This change has three purposes:Douglas Gregor2009-07-291-4/+7
| | | | | | | | | | | | | | | | 1) Allow the Index library (and any other interested client) to walk the set of declarations for a given tag (enum, union, class, whatever). At the moment, this information is not readily available. 2) Reduce our dependence on TagDecl::TypeForDecl being mapped down to a TagType (for which getDecl() will return the tag definition, if one exists). This property won't exist for class template partial specializations. 3) Make the canonical declaration of a TagDecl actually canonical, e.g., so that it does not change when the tag is defined. llvm-svn: 77523
* Refactor the code that produces a TemplateSpecializationType, so thatDouglas Gregor2009-07-281-24/+5
| | | | | | | | canonicalization for dependent TemplateSpecializationTypes occurs within ASTContext::getTemplateSpecializationType. Also, move template argument canonicalization into ASTContext::getCanonicalTemplateArgument. llvm-svn: 77388
* Remove ASTContext::getCanonicalDecl() and use Decl::getCanonicalDecl in its ↵Argyrios Kyrtzidis2009-07-181-1/+1
| | | | | | place. llvm-svn: 76274
* Move the functionality of ASTContext::getCanonicalDecl(), into a virtual ↵Argyrios Kyrtzidis2009-07-181-0/+14
| | | | | | method Decl::getCanonicalDecl(). llvm-svn: 76273
* Keep track of function template specializations, to eliminateDouglas Gregor2009-06-291-1/+26
| | | | | | | redundant, implicit instantiations of function templates and provide a place where we can hang function template specializations. llvm-svn: 74454
* Check in a new template argument list builder that should work better for ↵Anders Carlsson2009-06-231-51/+75
| | | | | | variadic templates. llvm-svn: 73937
* Keep track of whether a type parameter type is a parameter pack.Anders Carlsson2009-06-161-1/+1
| | | | llvm-svn: 73452
* More parameter pack work.Anders Carlsson2009-06-151-10/+13
| | | | llvm-svn: 73395
* Add a new 'Pack' argument kind to TemplateArgument. This is not yet used.Anders Carlsson2009-06-151-0/+16
| | | | llvm-svn: 73391
* More work on type parameter packs.Anders Carlsson2009-06-131-1/+3
| | | | llvm-svn: 73281
* Improvements to TemplateArgumentListBuilder to make it work better with ↵Anders Carlsson2009-06-131-0/+18
| | | | | | parameter packs. llvm-svn: 73272
* Keep track of whether a type parameter is actually a type parameter pack.Anders Carlsson2009-06-121-2/+3
| | | | llvm-svn: 73261
* Avoid warnings.Mike Stump2009-06-051-0/+1
| | | | llvm-svn: 72976
* Make TemplateArgumentListBuilder take an ASTContext (because we're probably ↵Anders Carlsson2009-06-051-0/+13
| | | | | | going to need it later). Move push_back to the .cpp file. If the passed in template argument is a type, assert that it's canonical. llvm-svn: 72918
* Make the TemplateArgumentList take a TemplateArgumentListBuilder.Anders Carlsson2009-06-051-10/+9
| | | | llvm-svn: 72917
* Change the specialization decls to take a TemplateArgumentListBuilder.Anders Carlsson2009-06-051-10/+7
| | | | llvm-svn: 72916
* Initial infrastructure for class template partial specialization. HereDouglas Gregor2009-05-311-3/+26
| | | | | | | | | | | | | we have the basics of declaring and storing class template partial specializations, matching class template partial specializations at instantiation time via (limited) template argument deduction, and using the class template partial specialization's pattern for instantiation. This patch is enough to make a simple is_pointer type trait work, but not much else. llvm-svn: 72662
* Encapsulate template arguments lists in a new class,Douglas Gregor2009-05-111-12/+38
| | | | | | | | TemplateArgumentList. This avoids the need to pass around pointer/length pairs of template arguments lists, and will eventually make it easier to introduce member templates and variadic templates. llvm-svn: 71517
* Implement the semantics of the injected-class-name within a classDouglas Gregor2009-05-101-0/+59
| | | | | | | | | | | | | | | | | | template. The injected-class-name is either a type or a template, depending on whether a '<' follows it. As a type, the injected-class-name's template argument list contains its template parameters in declaration order. As part of this, add logic for canonicalizing declarations, and be sure to canonicalize declarations used in template names and template arguments. A TagType is dependent if the declaration it references is dependent. I'm not happy about the rather complicated protocol needed to use ASTContext::getTemplateSpecializationType. llvm-svn: 71408
* Introduce a new expression type, UnresolvedDeclRefExpr, that describesDouglas Gregor2009-03-191-2/+25
| | | | | | | | | | | | | | | | | | | | | | | | dependent qualified-ids such as Fibonacci<N - 1>::value where N is a template parameter. These references are "unresolved" because the name is dependent and, therefore, cannot be resolved to a declaration node (as we would do for a DeclRefExpr or QualifiedDeclRefExpr). UnresolvedDeclRefExprs instantiate to DeclRefExprs, QualifiedDeclRefExprs, etc. Also, be a bit more careful about keeping only a single set of specializations for a class template, and instantiating from the definition of that template rather than a previous declaration. In general, we need a better solution for this for all TagDecls, because it's too easy to accidentally look at a declaration that isn't the definition. We can now process a simple Fibonacci computation described as a template metaprogram. llvm-svn: 67308
OpenPOWER on IntegriCloud