summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Unlike in C++03, a constant-expression is not an unevaluated operand in C++11.Richard Smith2011-12-201-15/+17
| | | | | | | | | | | | | | | | | | | | | | Split out a new ExpressionEvaluationContext flag for this case, and don't treat it as unevaluated in C++11. This fixes some crash-on-invalids where we would allow references to class members in potentially-evaluated constant expressions in static member functions, and also fixes half of PR10177. The fix to PR10177 exposed a case where template instantiation failed to provide a source location for a diagnostic, so TreeTransform has been tweaked to supply source locations when transforming a type. The source location is still not very good, but MarkDeclarationsReferencedInType would need to operate on a TypeLoc to improve it further. Also fix MarkDeclarationReferenced in C++98 mode to trigger instantiation for static data members of class templates which are used in constant expressions. This fixes a link-time problem, but we still incorrectly treat the member as non-constant. The rest of the fix for that issue is blocked on PCH support for early-instantiated static data members, which will be added in a subsequent patch. llvm-svn: 146955
* Make sure that we infer __strong, etc. when we instantiate variablesDouglas Gregor2011-12-101-0/+6
| | | | | | under ARC. Fixes <rdar://problem/10530209>. llvm-svn: 146307
* Fixed lexical declaration context when instantiating a friend / out-of-line ↵Abramo Bagnara2011-11-261-0/+7
| | | | | | class template member. llvm-svn: 145146
* Fixed implicit instantiations source range.Abramo Bagnara2011-11-181-0/+3
| | | | llvm-svn: 144977
* Compute whether a class is trivial correctly for template classes with an ↵Eli Friedman2011-11-151-0/+6
| | | | | | explicitly deleted or defaulted special member. PR11387. llvm-svn: 144715
* Removing unused initialization.David Blaikie2011-11-101-2/+1
| | | | llvm-svn: 144264
* Drastically simplify the mapping from the declaration corresponding toDouglas Gregor2011-11-071-66/+40
| | | | | | | | | | | | | | | | | | | | | | | | the injected-class-name of a class (or class template) to the declaration that results from substituting the given template arguments. Previously, we would actually perform a substitution into the injected-class-name type and then retrieve the resulting declaration. However, in certain, rare circumstances involving deeply-nested member templates, we would get the wrong substitution arguments. This new approach just matches up the declaration with a declaration that's part of the current context (or one of its parents), which will either be an instantiation (during template instantiation) or the declaration itself (during the definition of the template). This is both more efficient (we're avoiding a substitution) and more correct (we can't get the template arguments wrong in the member-template case). Fixes <rdar://problem/9676205>. Reinstated, now that we have the fix in r143967. llvm-svn: 143968
* Revert r143551. It is causing g++.dg/template/crash52.C test failure.Devang Patel2011-11-041-40/+66
| | | | llvm-svn: 143725
* Drastically simplify the mapping from the declaration corresponding toDouglas Gregor2011-11-021-66/+40
| | | | | | | | | | | | | | | | | | | | | | the injected-class-name of a class (or class template) to the declaration that results from substituting the given template arguments. Previously, we would actually perform a substitution into the injected-class-name type and then retrieve the resulting declaration. However, in certain, rare circumstances involving deeply-nested member templates, we would get the wrong substitution arguments. This new approach just matches up the declaration with a declaration that's part of the current context (or one of its parents), which will either be an instantiation (during template instantiation) or the declaration itself (during the definition of the template). This is both more efficient (we're avoiding a substitution) and more correct (we can't get the template arguments wrong in the member-template case). Fixes <rdar://problem/9676205>. llvm-svn: 143551
* Rework the AST for the initializer of a delegating constructor, soDouglas Gregor2011-11-011-10/+15
| | | | | | | | | that it retains source location information for the type. Aside from general goodness (being able to walk the types described in that information), we now have a proper representation for dependent delegating constructors. Fixes PR10457 (for real). llvm-svn: 143410
* Fixed FriendDecl source locations.Abramo Bagnara2011-10-291-1/+2
| | | | llvm-svn: 143295
* Add a -Wc++98-compat warning for friend functions of class templates which wouldRichard Smith2011-10-191-7/+29
| | | | | | be implicitly instantiated (resulting in a redefinition) in C++98. llvm-svn: 142468
* Revert r142142: "Make a C-style cast a const-cast, to suppress a GCC warning."Sebastian Redl2011-10-171-1/+1
| | | | | | Richard already fixed the underlying issue, so the cast was superfluous. llvm-svn: 142192
* Make a C-style cast a const-cast, to suppress a GCC warning. I should fix ↵Sebastian Redl2011-10-161-1/+1
| | | | | | the underlying issue eventually, but this interface will probably change anyway. llvm-svn: 142142
* Move some bool flags out of function parameter lists.Kaelyn Uhrain2011-10-111-6/+3
| | | | llvm-svn: 141610
* After instantiating a 'noexcept' expression, be sure to convert it toDouglas Gregor2011-10-091-0/+14
| | | | | | | a boolean value and check that it is a constant expression. Fixes PR11084. llvm-svn: 141511
* Silence a warning about casting away constness.Benjamin Kramer2011-10-081-4/+3
| | | | llvm-svn: 141496
* WhitespaceNAKAMURA Takumi2011-10-081-203/+203
| | | | llvm-svn: 141486
* constexpr: semantic checking for constexpr functions and constructors. Based inRichard Smith2011-10-011-10/+12
| | | | | | | | | | | | | part on patches by Peter Collingbourne. We diverge from the C++11 standard in a few areas, mostly related to checking constexpr function declarations, and not just definitions. See WG21 paper N3308=11-0078 for details. Function invocation substitution is not available in this patch; constexpr functions cannot yet be used from within constant expressions. llvm-svn: 140926
* Correctly parse braced member initializers (even in delayed parsing) and ↵Sebastian Redl2011-09-241-26/+28
| | | | | | | | | | | correctly pass the information on to Sema. There's still an incorrectness in the way template instantiation works now, but that is due to a far larger underlying representational problem. Also add a test case for various list initialization cases of scalars, which test this commit as well as the previous one. llvm-svn: 140460
* Removing a bunch of dead returns/breaks after llvm_unreachables.David Blaikie2011-09-231-3/+0
| | | | llvm-svn: 140407
* Switch assert(0/false) llvm_unreachable.David Blaikie2011-09-231-4/+4
| | | | llvm-svn: 140367
* ArrayRef-ifying the UnexpandedParameterPacks passed to ↵David Blaikie2011-09-221-6/+3
| | | | | | Sema::CheckParameterPacksForExpansion llvm-svn: 140290
* ArrayRef-ifying Function/BlockDecl's setParamsDavid Blaikie2011-09-211-2/+2
| | | | llvm-svn: 140268
* Changed references of BaseTy, MemInitTy, CXXScopeTy, TemplateParamsTy to ↵Richard Trieu2011-09-091-2/+2
| | | | | | CXXBaseSpecifier, CXXCtorInitializer, NestedNameSpecifier, TemplateParameterList and removed their typedefs. llvm-svn: 139350
* Always mark friend function declarations in class templates asChandler Carruth2011-08-181-3/+7
| | | | | | | | | | | implicitly instantiable, even if we don't see a body on the friend function declaration. The body may simply have not yet been attached. This fixes PR10666. There may be an alternate, preferred implementation strategy, see my FIXME. Review would definitely be appreciated Doug. =D llvm-svn: 137934
* Track in the AST whether a function is constexpr.Richard Smith2011-08-151-4/+11
| | | | llvm-svn: 137653
* Implement function template specialization at class scope extension in ↵Francois Pichet2011-08-141-5/+32
| | | | | | | | | | | | | | | | | 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
* Make the deserialization of Sema::PendingInstantiations lazy. At thisDouglas Gregor2011-07-281-0/+8
| | | | | | | | point, ASTReader::InitializeSema() has very little interesting work, *except* issues stemming from preloaded declarations. That's something we'll still need to cope with. llvm-svn: 136378
* remove unneeded llvm:: namespace qualifiers on some core types now that ↵Chris Lattner2011-07-231-18/+18
| | | | | | | | 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-16/+14
| | | | | | non-value-dependent cases. llvm-svn: 135543
* Use attributes from the definition (if available) whenRafael Espindola2011-07-061-2/+7
| | | | | | | | instantiating functions. Fixes PR10272. llvm-svn: 134491
* Look through parenthesized declarators when determining whether anDouglas Gregor2011-07-051-1/+1
| | | | | | | instantiated function template was written with a prototype or via some kind of typedef. Fixes PR10273 / <rdar://problem/9723679>. llvm-svn: 134426
* Introduce the notion of instantiation dependence into Clang's AST. ADouglas Gregor2011-07-011-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* When instantiating a function template declaration that was expressedDouglas Gregor2011-06-221-3/+20
| | | | | | | via a typedef of a function, make sure to synthesize parameter declarations. Fixes PR9654 / <rdar://problem/9257497>. llvm-svn: 133628
* Fix PR10168: don't warn for unused non-dependent variables in both the ↵Richard Smith2011-06-211-2/+4
| | | | | | template definition and each instantiation. llvm-svn: 133580
* Implement support for C++11 in-class initialization of non-static data members.Richard Smith2011-06-111-0/+1
| | | | llvm-svn: 132878
* When performing template argument deduction given a function argumentDouglas Gregor2011-06-031-0/+4
| | | | | | | | | of incomplete array type, attempt to complete the array type. This was made much easier by Chandler's addition of RequireCompleteExprType(), which I've tweaked (slightly) to improve the consistency of the DeclRefExpr. Fixes PR7985. llvm-svn: 132530
* The expression in a noexcept exception-specification is aDouglas Gregor2011-06-011-0/+1
| | | | | | | constant-expression, and, therefore, an unevaluated operand. Make it so. llvm-svn: 132400
* Whenever we instantiate a static data member, make sure to define any newNick Lewycky2011-05-311-9/+21
| | | | | | | | | vtables! Fixes PR10020 This also allows us to revert the part of r130023 which added a big loop around the template instantiation. llvm-svn: 132331
* Add assertions to verify that we are not trying to instantiate aAlexis Hunt2011-05-271-9/+11
| | | | | | | | | nontemplate in Sema::InstantiateTemplateDecl. This should make the issue in PR10026 more visible, although it's not going to fix it because something is violating this precondition. llvm-svn: 132208
* Add an additional check for null pointer before accessing PatternDecl.Richard Trieu2011-05-271-1/+1
| | | | llvm-svn: 132175
* Fix a minor thinko that leads to a crash if PatternDecl is null butAlexis Hunt2011-05-251-4/+5
| | | | | | Pattern is not. Thanks Nick for catching this! llvm-svn: 132089
* Delete the extraneous return statement that was causing my earlierAlexis Hunt2011-05-231-2/+0
| | | | | | | | | | issues and also add a test. We should now handle defaulted members of templates properly. No comment as to whether or not this also holds for templated functions, but defaulting those is kind of insane. llvm-svn: 131938
* Implement explicit specialization of explicitly-defaulted constructors.Alexis Hunt2011-05-231-14/+25
| | | | | | | | The general out-of-line case (including explicit instantiation mostly works except that the definition is being lost somewhere between the AST and CodeGen, so the definition is never emitted. llvm-svn: 131933
* Correctly propagate defaultedness across template instantiation. ThisAlexis Hunt2011-05-231-1/+9
| | | | | | | | fixes PR9965, but we're not out of the water yet, as we do not successfully handle out-of-line definitions, due to my utter misunderstanding of how we manage templates. llvm-svn: 131920
* Fix crasher spotted in IWYU.Nick Lewycky2011-05-121-1/+2
| | | | llvm-svn: 131222
* Modify some deleted function methods to better reflect reality:Alexis Hunt2011-05-061-5/+5
| | | | | | | | | | | | | | | | | | | | - 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
* Revert r130912 in order to approach defaulted functions from the otherAlexis Hunt2011-05-061-2/+1
| | | | | | | direction and not introduce things in the wrong place three different times. llvm-svn: 130968
* Implement support for C++0x alias templates.Richard Smith2011-05-051-5/+50
| | | | llvm-svn: 130953
OpenPOWER on IntegriCloud