summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* When we are instantiating a member function of a local class, be sureDouglas Gregor2010-01-161-2/+8
| | | | | | | | | to merge the local instantiation scope with the outer local instantiation scope, so that we can instantiate declarations from the function owning the local class. Fixes an assert while instantiating Boost.MPL's BOOST_MPL_ASSERT_MSG. llvm-svn: 93651
* Typedefs can be redeclared. That seems like something we should record inJohn McCall2009-12-301-0/+5
| | | | | | the AST lest we run into some crazy canonicalization bug like PR5874. llvm-svn: 92283
* Egregious, disgusting workaround for PR5866. We need to rework how weDouglas Gregor2009-12-241-2/+5
| | | | | | | | keep track of friends within templates, which will provide a real for PR5866. For now, this makes sure we don't do something entirely stupid with friends of specializations. llvm-svn: 92143
* Add using shadow decls to the "instantiated locals" map, fixing PR5847.John McCall2009-12-221-0/+5
| | | | llvm-svn: 91928
* Patch over yet more problems with friend declarations which were provokingJohn McCall2009-12-171-1/+7
| | | | | | | problems on LLVM-Code-Syntax. This proved remarkably easy to "fix" once I settled on how I was going to approach it. llvm-svn: 91633
* Link up member-class redeclarations during template instantiation.John McCall2009-12-151-0/+6
| | | | | | This test courtesy of LLVM. llvm-svn: 91462
* Fix PR5716 by bandaging over the solution until we can come back to it.John McCall2009-12-141-1/+6
| | | | | | I apologize for friend declarations. llvm-svn: 91359
* Improve template instantiation for object constructions in several ways:Douglas Gregor2009-12-141-69/+96
| | | | | | | | | | | | | - During instantiation, drop default arguments from constructor and call expressions; they'll be recomputed anyway, and we don't want to instantiate them twice. - Rewrote the instantiation of variable initializers to cope with non-dependent forms properly. Together, these fix a handful of problems I introduced with the switch to always rebuild expressions from the source code "as written." llvm-svn: 91315
* Rework the way we handle template instantiation forDouglas Gregor2009-12-121-11/+42
| | | | | | | | | | | | | | | | | | | | | | | implicitly-generated AST nodes. We previously built instantiated nodes for each of these AST nodes, then passed them on to Sema, which was not prepared to see already-type-checked nodes (see PR5755). In some places, we had ugly workarounds to try to avoid re-type-checking (e.g., in VarDecl initializer instantiation). Now, we skip implicitly-generated nodes when performing instantiation, preferring instead to build just the AST nodes that directly reflect what was written in the source code. This has several advantages: - We don't need to instantiate anything that doesn't have a direct correlation to the source code, so we can have better location information. - Semantic analysis sees the same thing at template instantiation time that it would see for a non-template. - At least one ugly hack (VarDecl initializers) goes away. Fixes PR5755. llvm-svn: 91218
* Implement redeclaration checking and hiding semantics for using ↵John McCall2009-12-101-20/+53
| | | | | | | | | | | declarations. There are a couple of O(n^2) operations in this, some analogous to the usual O(n^2) redeclaration problem and some not. In particular, retroactively removing shadow declarations when they're hidden by later decls is pretty unfortunate. I'm not yet convinced it's worse than the alternative, though. llvm-svn: 91045
* Implement template instantiation for exception specifications. Also,Douglas Gregor2009-12-081-0/+37
| | | | | | | | | | | | | | print exception specifications on function types and declarations. Fixes <rdar://problem/7450999>. There is some poor source-location information here, because we don't track locations of the types in exception specifications. Filed PR5719. Failures during template instantiation of the signature of a function or function template have wrong point-of-instantiation location information. I'll tackle that with a separate commit. llvm-svn: 90863
* Correctly implement the C++03 and 0x restrictions on class-member usingJohn McCall2009-12-081-9/+4
| | | | | | declarations. llvm-svn: 90843
* DeclaratorInfo -> TypeSourceInfo. Makes an effort to rename associated ↵John McCall2009-12-071-14/+14
| | | | | | | | | | | | | | | | | | | | | 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
* Fix "using typename" and the instantiation of non-dependent using declarations.John McCall2009-12-041-6/+78
| | | | llvm-svn: 90614
* A new helper function to set various bits in the class whenFariborz Jahanian2009-12-031-7/+2
| | | | | | | a new virtual function is declared/instantiated. it is used in couple of places. llvm-svn: 90470
* When we're building a CXXExprWithTemporaries, only include thoseDouglas Gregor2009-12-031-0/+6
| | | | | | | | | | | temporaries that are within our current evaluation context. That way, nested evaluation contexts (e.g., within a sizeof() expression) won't see temporaries from outer contexts. Also, make sure to push a new evaluation context when instantiating the initializer of a variable; this may be an unevaluated context or a potentially-evaluated context, depending on whether it's an in-class initializer or not. Fixes PR5672. llvm-svn: 90460
* Improve source location information for C++ member initializers in aDouglas Gregor2009-12-021-6/+12
| | | | | | | constructor, by keeping the DeclaratorInfo* rather than just the type and a single location. llvm-svn: 90355
* Funtion templates and function template specializations do notDouglas Gregor2009-12-011-2/+0
| | | | | | | override virtual functions. Also, eliminate a (now redundant) call to AddOverriddenMethods. llvm-svn: 90242
* Move the checking of overridden virtual functions into the code pathDouglas Gregor2009-12-011-4/+3
| | | | | | | | | | | | | | | common to both parsing and template instantiation, so that we'll find overridden virtuals for member functions of class templates when they are instantiated. Additionally, factor out the checking for pure virtual functions, so that it will be executed both at parsing time and at template instantiation time. These changes fix PR5656 (for real), although one more tweak w.r.t. member function templates will be coming along shortly. llvm-svn: 90241
* Remove all of Sema's explicit uses of OverloadedFunctionDecl except forJohn McCall2009-11-301-16/+0
| | | | | | those associated with TemplateNames. llvm-svn: 90162
* Remove remaining VISIBILITY_HIDDEN from anonymous namespaces.Benjamin Kramer2009-11-281-2/+1
| | | | llvm-svn: 90044
* Fix a crash when "instantiating" VarDecls that are neither type nor value ↵Anders Carlsson2009-11-241-0/+1
| | | | | | dependent. llvm-svn: 89774
* Encapsulate "an array of TemplateArgumentLocs and two angle bracket ↵John McCall2009-11-231-11/+7
| | | | | | | | | | locations" into a new class. Use it pervasively throughout Sema. My fingers hurt. llvm-svn: 89638
* Overhaul previous-declaration and overload checking to work on lookup resultsJohn McCall2009-11-181-21/+19
| | | | | | | rather than NamedDecl*. This is a major step towards eliminating OverloadedFunctionDecl. llvm-svn: 89263
* Track overriding methods when instantiating a template class. Fixes PR5550.Sebastian Redl2009-11-181-0/+2
| | | | llvm-svn: 89248
* Split LookupResult into its own header.John McCall2009-11-181-6/+7
| | | | llvm-svn: 89199
* Incremental progress on using declarations. Split UnresolvedUsingDecl intoJohn McCall2009-11-181-7/+49
| | | | | | | | | | two classes, one for typenames and one for values; this seems to have some support from Doug if not necessarily from the extremely-vague-on-this-point standard. Track the location of the 'typename' keyword in a using-typename decl. Make a new lookup result for unresolved values and deal with it in most places. llvm-svn: 89184
* Implement template instantiation for using directives, which is dead simple.Douglas Gregor2009-11-171-2/+22
| | | | | | | | Also, make the "don't know how to instantiate a particular kind of declaration" diagnostic nicer, so we don't have to trap Clang in a debugger to figure out what went wrong. llvm-svn: 89050
OpenPOWER on IntegriCloud