summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Improves parsing and semantic analysis for MS __declspec attributes. This ↵Aaron Ballman2012-06-191-2/+4
| | | | | | includes support for the align (which fixes PR12631). llvm-svn: 158717
* Documentation cleanup: fixing a typo from my previous 'fix'.James Dennett2012-06-171-1/+1
| | | | llvm-svn: 158617
* Documentation cleanup:James Dennett2012-06-151-2/+2
| | | | | | | | | * Escaped "::" and "<" as needed in Doxygen comments; * Marked up code examples with \code...\endcode; * Documented a \param that is current, instead of a few that aren't; * Fixed up some \file and \brief comments. llvm-svn: 158562
* Still more Doxygen documentation fixes:James Dennett2012-06-141-2/+2
| | | | | | | | * Escape #, < and @ symbols where Doxygen would try to interpret them; * Fix several function param documentation where names had got out of sync; * Delete param documentation referring to parameters that no longer exist. llvm-svn: 158472
* PR13064: Store whether an in-class initializer uses direct or copyRichard Smith2012-06-101-1/+1
| | | | | | | initialization, and use that information to produce the right kind of initialization during template instantiation. llvm-svn: 158288
* Revert Decl's iterators back to pointer value_type rather than reference ↵David Blaikie2012-06-061-2/+2
| | | | | | | | | | | | | | value_type In addition, I've made the pointer and reference typedef 'void' rather than T* just so they can't get misused. I would've omitted them entirely but std::distance likes them to be there even if it doesn't use them. This rolls back r155808 and r155869. Review by Doug Gregor incorporating feedback from Chandler Carruth. llvm-svn: 158104
* Correct the starting location for instantiations of field declarations whichRichard Smith2012-05-231-1/+1
| | | | | | | | | | | | | start with a cv-qualifier. DeclaratorDecl::getTypeSpecStartLoc() does not produce the location of the first type-specifier (the cv-qualifier) in this case, because we don't track source locations for cv-qualifiers. No test here: I've not found a way to test this with a lit-style test, and introducing a gtest test for this seems unwarranted. Suggestions welcome! Patch by Daniel Jasper! llvm-svn: 157311
* Fix our handling of visibility in explicit template instantiations.Rafael Espindola2012-05-151-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | * Don't copy the visibility attribute during instantiations. We have to be able to distinguish struct HIDDEN foo {}; template<class T> DEFAULT void bar() {} template DEFAULT void bar<foo>(); from struct HIDDEN foo {}; template<class T> DEFAULT void bar() {} template void bar<foo>(); * If an instantiation has an attribute, it takes precedence over an attribute in the template. * With instantiation attributes handled with the above logic, we can now select the minimum visibility when looking at template arguments. llvm-svn: 156821
* Move Sema::VerifyIntegerConstantExpression() andDouglas Gregor2012-05-041-3/+4
| | | | | | | | Sema::ConvertToIntegralOrEnumerationType() from PartialDiagnostics to abstract "diagnoser" classes. Not much of a win here, but we're -several PartialDiagnostics. llvm-svn: 156217
* Remove the ref/value inconsistency in filter_decl_iterator.David Blaikie2012-04-301-2/+2
| | | | | | | | | | | | | filter_decl_iterator had a weird mismatch where both op* and op-> returned T* making it difficult to generalize this filtering behavior into a reusable library of any kind. This change errs on the side of value, making op-> return T* and op* return T&. (reviewed by Richard Smith) llvm-svn: 155808
* PR 12586: Fix assert while running libc++ testsuite: deal with exceptionRichard Smith2012-04-191-17/+14
| | | | | | | | | specifications on member function templates of class templates and other such nested beasties. Store the function template from which we are to instantiate an exception specification rather than trying to deduce it. Plus some additional test cases. llvm-svn: 155076
* PR12569: Instantiate exception specifications of explicit instantiationsRichard Smith2012-04-171-1/+10
| | | | | | and explicit specializations of function templates appropriately. llvm-svn: 154956
* Implement DR1330 in C++11 mode, to support libstdc++4.7 which uses it.Richard Smith2012-04-171-151/+211
| | | | | | | | | | | | | | | | | | | | | | | | | | | | We have a new flavor of exception specification, EST_Uninstantiated. A function type with this exception specification carries a pointer to a FunctionDecl, and the exception specification for that FunctionDecl is instantiated (if needed) and used in the place of the function type's exception specification. When a function template declaration with a non-trivial exception specification is instantiated, the specialization's exception specification is set to this new 'uninstantiated' kind rather than being instantiated immediately. Expr::CanThrow has migrated onto Sema, so it can instantiate exception specs on-demand. Also, any odr-use of a function triggers the instantiation of its exception specification (the exception specification could be needed by IRGen). In passing, fix two places where a DeclRefExpr was created but the corresponding function was not actually marked odr-used. We used to get away with this, but don't any more. Also fix a bug where instantiating an exception specification which refers to function parameters resulted in a crash. We still have the same bug in default arguments, which I'll be looking into next. This, plus a tiny patch to fix libstdc++'s common_type, is enough for clang to parse (and, in very limited testing, support) all of libstdc++4.7's standard headers. llvm-svn: 154886
* Implement C++11 [expr.prim.general]p3, which permits the use of 'this'Douglas Gregor2012-04-161-1/+26
| | | | | | | | | | | | | | | | | | | | | | | in the declaration of a non-static member function after the (optional) cv-qualifier-seq, which in practice means in the exception specification and late-specified return type. The new scheme here used to manage 'this' outside of a member function scope is more general than the Scope-based mechanism previously used for non-static data member initializers and late-parsesd attributes, because it can also handle the cv-qualifiers on the member function. Note, however, that a separate pass is required for static member functions to determine whether 'this' was used, because we might not know that we have a static function until after declaration matching. Finally, this introduces name mangling for 'this' and for the implicit 'this', which is intended to match GCC's mangling. Independent verification for the new mangling test case would be appreciated. Fixes PR10036 and PR12450. llvm-svn: 154799
* If something already instantiated is reinstantiated as an explicit definition,Nick Lewycky2012-04-041-1/+6
| | | | | | | | | keep the latter. No test. This was noticed when poking around something else with GDB. I'm not able to figure out a testcase that would break due to this bug. Sorry. llvm-svn: 153992
* Basic semantic analysis support for inheriting constructor declarations inRichard Smith2012-04-021-0/+6
| | | | | | dependent contexts. llvm-svn: 153858
* When we form a new function/class template specialization, we firstDouglas Gregor2012-03-281-5/+5
| | | | | | | | | | | search for the specialization (in a folding set) and, if not found form a *Decl that is then inserted into that folding set. In rare cases, the folding set may be reallocated between the search and the insertion, causing a crash. No test case, because triggering rehashing consistently in a small test case is not feasible. Fixes <rdar://problem/11115071>. llvm-svn: 153575
* Add a special-case diagnostic for one of the more obnoxious special cases ofRichard Smith2012-03-261-0/+14
| | | | | | | | | | | | | | | unscoped enumeration members: an enumerator name which is visible in the out-of-class definition of a member of a templated class might not actually exist in the instantiation of that class, if the enumeration is also lexically defined outside the class definition and is explicitly specialized. Depending on the result of a CWG discussion, we may have a different resolution for a class of problems in this area, but this fixes the immediate issue of a crash-on-invalid / accepts-invalid (depending on +Asserts). Thanks to Johannes Schaub for digging into the standard wording to find how this case is currently specified to behave. llvm-svn: 153461
* Handle instantiations of redeclarations of forward-declared enumerations withinRichard Smith2012-03-261-3/+15
| | | | | | | templated functions. Build a redeclaration chain, and only instantiate the definition of the enum when visiting the defining declaration. llvm-svn: 153427
* Delay checking of dependent underlying types for redeclarations of memberRichard Smith2012-03-261-5/+16
| | | | | | enumerations in templates until the template is instantiated. llvm-svn: 153426
* Support for definitions of member enumerations of class templates outside theRichard Smith2012-03-231-1/+4
| | | | | | | class template's definition, and for explicit specializations of such enum members. llvm-svn: 153304
* Instantiating a class template should not instantiate the definition of anyRichard Smith2012-03-141-20/+34
| | | | | | | | scoped enumeration members. Later uses of an enumeration temploid as a nested name specifier should cause its instantiation. Plus some groundwork for explicit specialization of member enumerations of class templates. llvm-svn: 152750
* PR11850 + duplicates: don't assume that a function parameter pack expansion isRichard Smith2012-03-131-11/+14
| | | | | | at the end of the parameter list. llvm-svn: 152618
* Fix PR10447: lazily building name lookup tables for DeclContexts was broken.Richard Smith2012-03-131-2/+2
| | | | | | | | | | | | | | | | | | | | | | | The deferred lookup table building step couldn't accurately tell which Decls should be included in the lookup table, and consequently built different tables in some cases. Fix this by removing lazy building of DeclContext name lookup tables. In practice, the laziness was frequently not worthwhile in C++, because we performed lookup into most DeclContexts. In C, it had a bit more value, since there is no qualified lookup. In the place of lazy lookup table building, we simply don't build lookup tables for function DeclContexts at all. Such name lookup tables are not useful, since they don't capture the scoping information required to correctly perform name lookup in a function scope. The resulting performance delta is within the noise on my testing, but appears to be a very slight win for C++ and a very slight loss for C. The C performance can probably be recovered (if it is a measurable problem) by avoiding building the lookup table for the translation unit. llvm-svn: 152608
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-7/+7
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* Replace MarkVarRequired with a more genericRafael Espindola2012-03-081-4/+3
| | | | | | HandleCXXStaticMemberVarInstantiation. Suggested by Argyrios. llvm-svn: 152320
* Fix a small difference in sema and codegen views of what needs to be output.Rafael Espindola2012-03-051-4/+8
| | | | | | | | | | | | In the included testcase, soma thinks that we already have a definition after we see the out of line decl. Codegen puts it in a deferred list, to be output if a use is seen. This would break when we saw an explicit template instantiation definition, since codegen would not be notified. This patch adds a method to the consumer interface so that soma can notify codegen that this decl is now required. llvm-svn: 152024
* Lambda closure types are always considered to be like "local" classes,Douglas Gregor2012-02-161-3/+6
| | | | | | | | | even if they are not within a function scope. Teach template instantiation to treat them as such, and make sure that we have a local instantiation scope when instantiating default arguments and static data members. llvm-svn: 150725
* Minor fix to template instantiation, which properly instantiatesDeLesley Hutchins2012-02-161-1/+1
| | | | | | dependent attributes on static members of templatized classes. llvm-svn: 150704
* Update constexpr implementation to match CWG's chosen approach for core issuesRichard Smith2012-02-131-11/+4
| | | | | | | | | | | | | | | | | | | | 1358, 1360, 1452 and 1453. - Instantiations of constexpr functions are always constexpr. This removes the need for separate declaration/definition checking, which is now gone. - This makes it possible for a constexpr function to be virtual, if they are only dependently virtual. Virtual calls to such functions are not constant expressions. - Likewise, it's now possible for a literal type to have virtual base classes. A constexpr constructor for such a type cannot actually produce a constant expression, though, so add a special-case diagnostic for a constructor call to such a type rather than trying to evaluate it. - Classes with trivial default constructors (for which value initialization can produce a fully-initialized value) are considered literal types. - Classes with volatile members are not literal types. - constexpr constructors can be members of non-literal types. We do not yet use static initialization for global objects constructed in this way. llvm-svn: 150359
* Represent C++ direct initializers as ParenListExprs before semantic analysisSebastian Redl2012-02-111-111/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | instead of having a special-purpose function. - ActOnCXXDirectInitializer, which was mostly duplication of AddInitializerToDecl (leading e.g. to PR10620, which Eli fixed a few days ago), is dropped completely. - MultiInitializer, which was an ugly hack I added, is dropped again. - We now have the infrastructure in place to distinguish between int x = {1}; int x({1}); int x{1}; -- VarDecl now has getInitStyle(), which indicates which of the above was used. -- CXXConstructExpr now has a flag to indicate that it represents list- initialization, although this is not yet used. - InstantiateInitializer was renamed to SubstInitializer and simplified. - ActOnParenOrParenListExpr has been replaced by ActOnParenListExpr, which always produces a ParenListExpr. Placed that so far failed to convert that back to a ParenExpr containing comma operators have been fixed. I'm pretty sure I could have made a crashing test case before this. The end result is a (I hope) considerably cleaner design of initializers. More importantly, the fact that I can now distinguish between the various initialization kinds means that I can get the tricky generalized initializer test cases Johannes Schaub supplied to work. (This is not yet done.) This commit passed self-host, with the resulting compiler passing the tests. I hope it doesn't break more complicated code. It's a pretty big change, but one that I feel is necessary. llvm-svn: 150318
* Move instantiateTemplateAttribute into the sema namespace, make helpers static.Benjamin Kramer2012-02-061-2/+2
| | | | llvm-svn: 149864
* In C++11 mode, when an integral constant expression is desired and we have aRichard Smith2012-02-041-9/+4
| | | | | | | | | | | | | | | | | | value of class type, look for a unique conversion operator converting to integral or unscoped enumeration type and use that. Implements [expr.const]p5. Sema::VerifyIntegerConstantExpression now performs the conversion and returns the converted result. Some important callers of Expr::isIntegralConstantExpr have been switched over to using it (including all of those required for C++11 conformance); this switch brings a side-benefit of improved diagnostics and, in several cases, simpler code. However, some language extensions and attributes have not been moved across and will not perform implicit conversions on constant expressions of literal class type where an ICE is required. In passing, fix static_assert to perform a contextual conversion to bool on its argument. llvm-svn: 149776
* When we're substituting into a function parameter pack and expect toDouglas Gregor2012-01-251-1/+2
| | | | | | | get a function parameter pack (but don't due to weird substitutions), complain. Fixes the last bit of PR11848. llvm-svn: 148960
* Delayed template instantiation of late-parsed attributes.DeLesley Hutchins2012-01-201-6/+19
| | | | llvm-svn: 148595
* Instantiate dependent attributes when instantiating templates.DeLesley Hutchins2012-01-201-3/+5
| | | | llvm-svn: 148592
* Remove unused variables.Benjamin Kramer2012-01-201-2/+1
| | | | | | Found by clang's own static analyzer. llvm-svn: 148542
* An instantiation of a constexpr static data member in a class template isRichard Smith2012-01-191-0/+1
| | | | | | constexpr. llvm-svn: 148505
* De-virtualize getPreviousDecl() and getMostRecentDecl() when we knowDouglas Gregor2012-01-141-10/+10
| | | | | | | | | | | | we have a redeclarable type, and only use the new virtual versions (getPreviousDeclImpl() and getMostRecentDeclImpl()) when we don't have that type information. This keeps us from penalizing users with strict type information (and is the moral equivalent of a "final" method). Plus, settle on the names getPreviousDecl() and getMostRecentDecl() throughout. llvm-svn: 148187
* Tweak the fix to PR8977: an empty expression-list represents value ↵Eli Friedman2012-01-051-4/+3
| | | | | | initialization, not default initialization. Fixes PR11712. llvm-svn: 147620
* Delay checking of typedefs of dependent types. Fixes PR11630.Rafael Espindola2011-12-261-1/+6
| | | | llvm-svn: 147281
* C++ constant expression handling: eagerly instantiate static const integral dataRichard Smith2011-12-211-2/+1
| | | | | | | | members of class templates so that their values can be used in ICEs. This required reverting r105465, to get such instantiated members to be included in serialized ASTs. llvm-svn: 147023
* 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
OpenPOWER on IntegriCloud