summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Introduce a sequence number into class template partialDouglas Gregor2010-04-301-27/+4
| | | | | | | | | | | 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
* Recommit r102215, this time being more careful to only set the "principalJohn McCall2010-04-241-8/+13
| | | | | | | declaration" (i.e. the only which will actually be looked up) to have the non-member-operator bit. llvm-svn: 102231
* Revert r102215. This causes clang crash while compiling a test case from gdb ↵Devang Patel2010-04-241-6/+0
| | | | | | testsuite. llvm-svn: 102224
* Transition the last acceptable-result filter kind in LookupResult over to useJohn McCall2010-04-231-0/+6
| | | | | | a simple IDNS mask by introducing a namespace for non-member operators. llvm-svn: 102215
* When instantiating a typedef of an anonymous tag type, note in the tagDouglas Gregor2010-04-231-0/+10
| | | | | | | declaration that this typedef gives the tag a name. Fixes a problem uncovered by Boost.GIL (Generic Image Library). llvm-svn: 102180
* Keep track of the actual storage specifier written on a variable orDouglas Gregor2010-04-191-5/+10
| | | | | | | | function declaration, since it may end up being changed (e.g., "extern" can become "static" if a prior declaration was static). Patch by Enea Zaffanella and Paolo Bolzoni. llvm-svn: 101826
* Be sure to instantiate the parameters of a function, even when theDouglas Gregor2010-04-121-65/+21
| | | | | | | | | | | | | | | | | | | | function's type is (strictly speaking) non-dependent. This ensures that, e.g., default function arguments get instantiated properly. And, since I couldn't resist, collapse the two implementations of function-parameter instantiation into calls to a single, new function (Sema::SubstParmVarDecl), since the two had nearly identical code (and each had bugs the other didn't!). More importantly, factored out the semantic analysis of a parameter declaration into Sema::CheckParameter, which is called both by Sema::ActOnParamDeclarator (when parameters are parsed) and when a parameter is instantiated. Previously, we were missing some Objective-C and address-space checks on instantiated function parameters. Fixes PR6733. llvm-svn: 101029
* Instantiate default argument expressions even if their associated parameterJohn McCall2010-04-091-3/+4
| | | | | | type isn't dependent. Fixes rdar://problem/7838962. llvm-svn: 100871
* Set access properly on instantiated friend class template declarations.John McCall2010-04-081-2/+7
| | | | | | Fixes PR6752. llvm-svn: 100806
* Introduce an egregious hack to work around a bug in libstdc++ 4.2.x'sDouglas Gregor2010-04-081-4/+37
| | | | | | | | | <tr1/hashtable> header, where a friend class template std::tr1::__detail::_Map_base is declared with the wrong template parameters. GCC doesn't catch the problem, so Clang does a little back-flip to avoid diagnosing just this one instance of the problem. llvm-svn: 100790
* Implement dependent friend function template specializations.John McCall2010-04-081-14/+43
| | | | llvm-svn: 100753
* Improve handling of friend types in several ways:Douglas Gregor2010-04-071-29/+26
| | | | | | | | | | | - When instantiating a friend type template, perform semantic analysis on the resulting type. - Downgrade the errors concerning friend type declarations that do not refer to classes to ExtWarns in C++98/03. C++0x allows practically any type to be befriended, and ignores the friend declaration if the type is not a class. llvm-svn: 100635
* Improve diagnostics when an elaborated-type-specifer containing aDouglas Gregor2010-03-311-1/+2
| | | | | | | | | | | | | | | | nested-name-specifier (e.g., "class T::foo") fails to find a tag member in the scope nominated by the nested-name-specifier. Previously, we gave a bland error: 'Nested' does not name a tag member in the specified scope which didn't actually say where we were looking, which was rather horrible when the nested-name-specifier was instantiated. Now, we give something a bit better: error: no class named 'Nested' in 'NoDepBase<T>' llvm-svn: 100060
* the big refactoring bits of PR3782.Rafael Espindola2010-03-301-2/+1
| | | | | | | | This introduces FunctionType::ExtInfo to hold the calling convention and the noreturn attribute. The next patch will extend it to include the regparm attribute and fix the bug. llvm-svn: 99920
* Implement method friends in class templates and fix a few related problems.John McCall2010-03-271-27/+64
| | | | llvm-svn: 99708
* Put function templates instantiated from friend declarations in the correctJohn McCall2010-03-261-6/+15
| | | | | | lexical context. This is required for ADL to work properly; fixes PR6716. llvm-svn: 99665
* Reapply r99596 with a fix: link an instantiated friend function to itsJohn McCall2010-03-261-14/+40
| | | | | | pattern if it has a body. llvm-svn: 99610
* Apparently that didn't work. Reverting for now.John McCall2010-03-261-29/+14
| | | | llvm-svn: 99601
* Properly instantiate and link in friend function templates.John McCall2010-03-261-14/+29
| | | | llvm-svn: 99596
* Preserve type-source information in friend declarations.John McCall2010-03-251-6/+10
| | | | llvm-svn: 99525
* Properly instantiate friend class template declarations and link them intoJohn McCall2010-03-251-23/+94
| | | | | | | the redeclaration chain. Recommitted from r99477 with a fix: we need to merge in default template arguments from previous declarations. llvm-svn: 99496
* Revert 99477 since it appears to be breaking the clang-x86_64-darwin10-fntBob Wilson2010-03-251-84/+23
| | | | | | | | | | | buildbot. The tramp3d test fails. --- Reverse-merging r99477 into '.': U test/SemaTemplate/friend-template.cpp U test/CXX/temp/temp.decls/temp.friend/p1.cpp U lib/Sema/SemaTemplateInstantiateDecl.cpp U lib/Sema/SemaAccess.cpp llvm-svn: 99481
* Properly instantiate and link in friend-class-template declarations.John McCall2010-03-251-23/+84
| | | | llvm-svn: 99477
* When pulling apart an initializer that involves a CXXConstructExpr, doDouglas Gregor2010-03-241-11/+13
| | | | | | | not pick apart a CXXTemporaryObjectExpr because such an object construction was explicitly written in the source code. Fixes PR6657. llvm-svn: 99427
* Implement a framework for the delay of arbitrary diagnostics withinJohn McCall2010-03-241-0/+17
| | | | | | | | | templates. So delay access-control diagnostics when (for example) the target of a friend declaration is a specific specialization of a template. I was surprised to find that this was required for an access-controlled selfhost. llvm-svn: 99383
* Remember declaration scope qualifiers in the AST. Imposes no memory overheadJohn McCall2010-03-151-0/+64
| | | | | | | | | | | on unqualified declarations. Patch by Enea Zaffanella! Minimal adjustments: allocate the ExtInfo nodes with the ASTContext and delete them during Destroy(). I audited a bunch of Destroy methods at the same time, to ensure that the correct teardown was being done. llvm-svn: 98540
* Maintain type source information for functions through templateJohn McCall2010-03-111-59/+52
| | | | | | | | | | | instantiation. Based on a patch by Enea Zaffanella! I found a way to reduce some of the redundancy between TreeTransform's "standard" FunctionProtoType transformation and TemplateInstantiator's override, and I killed off the old SubstFunctionType by adding type source info for the last cases where we were creating FunctionDecls without TSI (at least that get passed through template instantiation). llvm-svn: 98252
* Create a new InjectedClassNameType to represent bare-word references to the John McCall2010-03-101-14/+24
| | | | | | | | | | | | | 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
* Unify initializer-instantiation code for variable declarations andDouglas Gregor2010-03-021-85/+93
| | | | | | base/member initializers. llvm-svn: 97560
* When looking for a redeclaration of a static variable, only look for ↵Douglas Gregor2010-03-011-1/+1
| | | | | | redeclarations. Fixes PR6449 llvm-svn: 97478
* When instantiating a function-scoped enum, make sure that it and itsDouglas Gregor2010-03-011-0/+9
| | | | | | | enumeration constants get placed into the local instantiation hash table. Fixes PR6375. llvm-svn: 97471
* Robustify instantiation of templates when there are errors in theDouglas Gregor2010-03-011-1/+2
| | | | | | | | | template definition. Do this both by being more tolerant of errors in our asserts and by not dropping a variable declaration completely when its initializer is ill-formed. Fixes the crash-on-invalid in PR6375, but not the original issue. llvm-svn: 97463
* When looking for the instantiated declaration that corresponds to aDouglas Gregor2010-03-011-11/+32
| | | | | | | given declaration in a template, make sure that the context we're searching through is complete. Fixes PR6376. llvm-svn: 97444
* Do not try to instantiate invalid declarations. It's a recipe forDouglas Gregor2010-02-161-0/+3
| | | | | | disaster. Fixes PR6161. llvm-svn: 96371
* Support local namespace aliases and permit them to be instantiated.John McCall2010-02-161-0/+16
| | | | llvm-svn: 96335
* Skip implicit instantiation of templated variables where a more recentChandler Carruth2010-02-131-0/+18
| | | | | | redeclaration provides an explicit instantiation or is invalid. llvm-svn: 96097
* Eliminate a bunch of unnecessary ASTContexts from members functions ofDouglas Gregor2010-02-111-6/+4
| | | | | | Decl subclasses. No functionality change. llvm-svn: 95841
* Migrate the mish-mash of declaration checks inDouglas Gregor2010-02-091-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Sema::ActOnUninitializedDecl over to InitializationSequence (with default initialization), eliminating redundancy. More importantly, we now check that a const definition in C++ has an initilizer, which was an #if 0'd code for many, many months. A few other tweaks were needed to get everything working again: - Fix all of the places in the testsuite where we defined const objects without initializers (now that we diagnose this issue) - Teach instantiation of static data members to find the previous declaration, so that we build proper redeclaration chains. Previously, we had the redeclaration chain but built it too late to be useful, because... - Teach instantiation of static data member definitions not to try to check an initializer if a previous declaration already had an initializer. This makes sure that we don't complain about static const data members with in-class initializers and out-of-line definitions. - Move all of the incomplete-type checking logic out of Sema::FinalizeDeclaratorGroup; it makes more sense in ActOnUnitializedDecl. There may still be a few places where we can improve these diagnostics. I'll address that as a separate commit. llvm-svn: 95657
* Workaround for friend template instantiation crash in PR5848, from Keir Mierle!Douglas Gregor2010-02-071-3/+11
| | | | llvm-svn: 95517
* Teach Sema how to instantiate a local function declaration properly. FixesJohn McCall2010-02-061-3/+8
| | | | | | PR 5517. llvm-svn: 95470
* Cope with finding the "instantiated" declaration when we areDouglas Gregor2010-02-051-21/+36
| | | | | | | | type-checking within a template definition. In this case, the "instantiated" declaration is just the declaration itself, found within the current instantiation. Fixes PR6239. llvm-svn: 95442
* Fix two issues with the substitution of template template parametersDouglas Gregor2010-02-051-1/+1
| | | | | | | | | | | | | | | | when instantiating the declaration of a member template: - Only check if the have a template template argument at a specific position when we already know that we have template arguments at that level; otherwise, we're substituting for a level-reduced template template parameter. - When trying to find an instantiated declaration for a template template parameter, look into the instantiated scope. This was a typo, where we had two checks for TemplateTypeParmDecl, one of which should have been a TemplateTemplateParmDecl. With these changes, tramp3d-v4 passes -fsyntax-only. llvm-svn: 95421
* Look through CXXExprWithTemporaries when digging out the originalDouglas Gregor2010-02-031-0/+3
| | | | | | initializer. Grrr.... llvm-svn: 95211
* Rework base and member initialization in constructors, with severalDouglas Gregor2010-01-311-14/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (necessarily simultaneous) changes: - CXXBaseOrMemberInitializer now contains only a single initializer rather than a set of initialiation arguments + a constructor. The single initializer covers all aspects of initialization, including constructor calls as necessary but also cleanup of temporaries created by the initializer (which we never handled before!). - Rework + simplify code generation for CXXBaseOrMemberInitializers, since we can now just emit the initializer as an initializer. - Switched base and member initialization over to the new initialization code (InitializationSequence), so that it - Improved diagnostics for the new initialization code when initializing bases and members, to match the diagnostics produced by the previous (special-purpose) code. - Simplify the representation of type-checked constructor initializers in templates; instead of keeping the fully-type-checked AST, which is rather hard to undo at template instantiation time, throw away the type-checked AST and store the raw expressions in the AST. This simplifies instantiation, but loses a little but of information in the AST. - When type-checking implicit base or member initializers within a dependent context, don't add the generated initializers into the AST, because they'll look like they were explicit. - Record in CXXConstructExpr when the constructor call is to initialize a base class, so that CodeGen does not have to infer it from context. This ensures that we call the right kind of constructor. There are also a few "opportunity" fixes here that were needed to not regress, for example: - Diagnose default-initialization of a const-qualified class that does not have a user-declared default constructor. We had this diagnostic specifically for bases and members, but missed it for variables. That's fixed now. - When defining the implicit constructors, destructor, and copy-assignment operator, set the CurContext to that constructor when we're defining the body. llvm-svn: 94952
* Preserve access for enum constants during template instantiation.John McCall2010-01-231-0/+1
| | | | llvm-svn: 94333
* Create function, block, and template parameters in the context of theJohn McCall2010-01-221-1/+3
| | | | | | | | | translation unit. This is temporary for function and block parameters; template parameters can just stay this way, since Templates aren't DeclContexts. This gives us the nice property that everything created in a record DC should have access in C++. llvm-svn: 94122
* First pass at collecting access-specifier information along inheritance paths.John McCall2010-01-201-0/+9
| | | | | | | | Triggers lots of assertions about missing access information; fix them. Will actually consume this information soon. llvm-svn: 94038
* Encoding calling conventions in the type system, from Charles Davis!Douglas Gregor2010-01-181-1/+2
| | | | llvm-svn: 93726
* Introduce a second queue of "local" pending implicit instantiation,Douglas Gregor2010-01-161-6/+25
| | | | | | | | | | which are instantiations of the member functions of local classes. These implicit instantiations have to occur at the same time as---and in the same local instantiation scope as---the enclosing function, since the member functions of the local class can refer to locals within the enclosing function. This should really, really fix PR5764. llvm-svn: 93666
OpenPOWER on IntegriCloud