summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplate.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Don't add attributes for "#pragma pack" and friends to tag declarations whichEli Friedman2012-08-081-2/+4
| | | | | | | are not definitions. This follows the behavior of both gcc and earlier versions of clang. Regression from r156531. <rdar://problem/12048621>. llvm-svn: 161523
* Comment parsing: add support for \tparam command on all levels.Dmitri Gribenko2012-07-311-1/+5
| | | | | | | | | | The only caveat is renumbering CXCommentKind enum for aesthetic reasons -- this breaks libclang binary compatibility, but should not be a problem since API is so new. This also fixes PR13372 as a side-effect. llvm-svn: 161087
* PR13365: Fix code which was trying to treat an array of DeducedTemplateArgumentRichard Smith2012-07-161-10/+7
| | | | | | | | as an array of its base class TemplateArgument. Switch the const TemplateArgument* parameters of InstantiatingTemplate's constructors to ArrayRef<TemplateArgument> to prevent this from happening again in the future. llvm-svn: 160245
* Apply visibility pragmas to class template declarations. This is needed becauseRafael Espindola2012-07-131-0/+2
| | | | | | we might use the declaration to build a type before seeing the definition. llvm-svn: 160176
* Fix a bug in my previous commit. The problem is not that we were not using theRafael Espindola2012-07-131-0/+3
| | | | | | | canonical decl for the template, but that we were not merging attributes for templates at all! llvm-svn: 160157
* PR9793: Treat substitution as an instantiation step for the purpose of theRichard Smith2012-07-081-0/+14
| | | | | | | | -ftemplate-depth limit. There are various ways to get an infinite (or merely huge) stack of substitutions with no intervening instantiations. This is also consistent with gcc's behavior. llvm-svn: 159907
* Documentation cleanup:James Dennett2012-06-151-5/+8
| | | | | | | | | * 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
* Documentation cleanup:James Dennett2012-06-151-1/+1
| | | | | | | | | * Removed \param comments for parameters that no longer exist; * Fixed a "\para" typo to "\param"; * Escaped @, # and \ symbols as needed in Doxygen comments; * Added use of \brief to output short summaries. llvm-svn: 158498
* Still more Doxygen documentation fixes:James Dennett2012-06-141-1/+1
| | | | | | | | * 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
* Fix up the 'typename' suggestion logic introduced in r157085, based onKaelyn Uhrain2012-06-081-11/+9
| | | | | | feedback from Doug Gregor. llvm-svn: 158185
* Plug a long standing memory leak in TemplateArgument.Benjamin Kramer2012-06-071-5/+6
| | | | | | | | | | | | | | | The integral APSInt value is now stored in a decomposed form and the backing store for large values is allocated via the ASTContext. This way its not leaked as TemplateArguments are never destructed when they are allocated in the ASTContext. Since the integral data is immutable it is now shared between instances, making copying TemplateArguments a trivial operation. Currently getting the integral data out of a TemplateArgument requires creating a new APSInt object. This is cheap when the value is small but can be expensive if it's not. If this turns out to be an issue a more efficient accessor could be added. llvm-svn: 158150
* Suggest adding 'typename' when it would make the compilerKaelyn Uhrain2012-05-181-0/+39
| | | | | | accept the template argument expression as a type. llvm-svn: 157085
* A little tweak to the SFINAE condition reporting. Don't say:Richard Smith2012-05-091-1/+47
| | | | | | | | | | | | | | candidate template ignored: substitution failed [with T = int]: no type named 'type' in 'std::enable_if<false, void>' Instead, just say: candidate template ignored: disabled by 'enable_if' [with T = int] ... and point at the enable_if condition which (we assume) failed. This is applied to all cases where the user writes 'typename enable_if<...>::type' (optionally prefixed with a nested name specifier), and 'enable_if<...>' names a complete class type which does not have a member named 'type', and this results in a candidate function being ignored in a SFINAE context. Thus it catches 'std::enable_if', 'std::__1::enable_if', 'boost::enable_if' and 'llvm::enable_if'. llvm-svn: 156463
* Move Sema::VerifyIntegerConstantExpression() andDouglas Gregor2012-05-041-2/+14
| | | | | | | | Sema::ConvertToIntegralOrEnumerationType() from PartialDiagnostics to abstract "diagnoser" classes. Not much of a win here, but we're -several PartialDiagnostics. llvm-svn: 156217
* In C++11 mode, implement the C++11 semantics forDouglas Gregor2012-05-011-2/+4
| | | | | | | | | | | [basic.lookup.classref]p1 and p4, which concerns name lookup for nested-name-specifiers and template names, respectively, in a member access expression. C++98/03 forces us to look both in the scope of the object and in the current scope, then compare the results. C++11 just takes the result from the scope of the object, if something is found. Fixes <rdar://problem/11328502>. llvm-svn: 155935
* Add a missing ExpressionEvaluationContext for template default arguments. ↵Eli Friedman2012-04-261-0/+1
| | | | | | Fixes PR12581. llvm-svn: 155670
* Two missing -Wc++98-compat warnings, for null pointers as non-type templateRichard Smith2012-04-261-0/+3
| | | | | | arguments, and 'this' in exception-specifications. llvm-svn: 155606
* When resolving default template arguments, it should be done in the ↵Argyrios Kyrtzidis2012-04-251-0/+3
| | | | | | | | | | declaration context of the template what we are going to instantiate. Fixes various crashes of rdar://11242625 & http://llvm.org/PR11421. llvm-svn: 155576
* PR12585: When processing a friend template inside a class template, don'tRichard Smith2012-04-221-15/+12
| | | | | | | | pretend there was no previous declaration -- that can lead us to injecting a class template (with no access specifier) into a class scope. Instead, just avoid the problematic checks. llvm-svn: 155303
* When declaring a template, check that the context doesn't already contain aRichard Smith2012-04-211-3/+22
| | | | | | | declaration of the same name. r155187 caused us to miss this if the prior declaration did not declare a type. llvm-svn: 155269
* Replace r155185 with a better fix, which also addresses PR12557. When lookingRichard Smith2012-04-201-3/+3
| | | | | | | | | up an elaborated type specifier in a friend declaration, only look for type declarations, per [basic.lookup.elab]p2. If we know that the redeclaration lookup for a friend class template in a dependent context finds a non-template, don't delay the diagnostic to instantiation time. llvm-svn: 155187
* Fix a bug which creduce found reducing PR12585.Richard Smith2012-04-201-1/+1
| | | | llvm-svn: 155185
* Improve diagnostics in C++11 when a non-type template argument for aDouglas Gregor2012-04-101-2/+27
| | | | | | non-type template parameter of pointer type is not a constant expression. llvm-svn: 154424
* Rework implementation of null non-type template arguments based onDouglas Gregor2012-04-101-118/+154
| | | | | | | Richard's feedback, to properly catch non-constant expressions and type mismatches. Finishes <rdar://problem/11193097>. llvm-svn: 154407
* Implement support for null non-type template arguments for non-typeDouglas Gregor2012-04-061-21/+87
| | | | | | | template parameters of pointer, pointer-to-member, or nullptr_t type in C++11. Fixes PR9700 / <rdar://problem/11193097>. llvm-svn: 154219
* Implement C++11 [temp.arg.nontype]'s permission to use the address of an objectRichard Smith2012-04-041-34/+40
| | | | | | or function with internal linkage as a non-type template argument. llvm-svn: 154053
* If we encounter a friend class template for which we cannot resolveDouglas Gregor2012-03-301-2/+6
| | | | | | | | | | | | | the nested-name-specifier (e.g., because it is dependent), do not error even though we can't represent it in the AST at this point. This is a horrible, horrible hack. The actual feature we still need to implement (for C++98!) is covered by PR12292. However, we used to silently accept this code, so when we recently started rejecting it we caused some regressions (e.g., <rdar://problem/11147355>). This hack brings us back to the passable-but-not-good state we had previously. llvm-svn: 153752
* Unify and fix our checking of C++ [dcl.meaning]p1's requirementsDouglas Gregor2012-03-281-3/+2
| | | | | | | | | concerning qualified declarator-ids. We now diagnose extraneous qualification at namespace scope (which we had previously missed) and diagnose these qualification errors for all kinds of declarations; it was rather uneven before. Fixes <rdar://problem/11135644>. llvm-svn: 153577
* Support for definitions of member enumerations of class templates outside theRichard Smith2012-03-231-8/+26
| | | | | | | class template's definition, and for explicit specializations of such enum members. llvm-svn: 153304
* Replace a FIXME with a diagnostic when we can't resolve theDouglas Gregor2012-03-181-1/+2
| | | | | | nested-name-specifier for a class template declaration. Fixes PR12291. llvm-svn: 153006
* Diagnose tag and class template declarations with qualifiedDouglas Gregor2012-03-171-2/+4
| | | | | | declarator-ids that occur at class scope. Fixes PR8019. llvm-svn: 153002
* Implement [temp.param]p5: the top-level cv-qualifiers on a non-type templateRichard Smith2012-03-131-2/+6
| | | | | | parameter's declaration are ignored when determining the parameter's type. llvm-svn: 152619
* Fix PR10447: lazily building name lookup tables for DeclContexts was broken.Richard Smith2012-03-131-1/+1
| | | | | | | | | | | | | | | | | | | | | | | 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-24/+24
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* When determining whether an identifier followed by a '<' in a memberDouglas Gregor2012-03-101-9/+21
| | | | | | | | access expression is the start of a template-id, ignore function templates found in the context of the entire postfix-expression. Fixes PR11856. llvm-svn: 152520
* [AST/Sema/libclang] Replace getSourceRange().getBegin() with getLocStart().Daniel Dunbar2012-03-091-27/+26
| | | | | | | | | - getSourceRange().getBegin() is about as awesome a pattern as .copy().size(). I already killed the hot paths so this doesn't seem to impact performance on my tests-of-the-day, but it is a much more sensible (and shorter) pattern. llvm-svn: 152419
* Two fixes to how we compute visibility:Rafael Espindola2012-02-231-0/+1
| | | | | | | | | | | | * Handle some situations where we should never make a decl more visible, even when merging in an explicit visibility. * Handle attributes in members of classes that are explicitly specialized. Thanks Nico for the report and testing, Eric for the initial review, and dgregor for the awesome test27 :-) llvm-svn: 151236
* Fix a constexpr FIXME: When implicitly instantiating the primary template for anRichard Smith2012-02-201-1/+6
| | | | | | | explicit specialization of a function template, mark the instantiation as constexpr if the specialization is, rather than requiring them to match. llvm-svn: 151001
* Introduce support for template instantiation of lambdaDouglas Gregor2012-02-131-0/+5
| | | | | | | | | | | | | | | | | | expressions. This is mostly a simple refact, splitting the main "start a lambda expression" function into smaller chunks that are driven either from the parser (Sema::ActOnLambdaExpr) or during AST transformation (TreeTransform::TransformLambdaExpr). A few minor interesting points: - Added new entry points for TreeTransform, so that we can explicitly establish the link between the lambda closure type in the template and the lambda closure type in the instantiation. - Added a bit into LambdaExpr specifying whether it had an explicit result type or not. We should have had this anyway. This code is 'lightly' tested. llvm-svn: 150417
* Make sure we convert struct layout pragmas to attributes for class templates ↵Eli Friedman2012-02-101-0/+5
| | | | | | the same way we do for non-template classes. <rdar://problem/10791194>. llvm-svn: 150221
* Added source location for the template keyword in ↵Abramo Bagnara2012-02-061-0/+3
| | | | | | | | | | DependentTemplateSpecializationTypeLoc nodes (DTSTLoc). The new info is propagated to TSTLoc on template instantiation, getting rid of 3 FIXMEs in TreeTransform.h and another one Parser.cpp. Simplified code in TypeSpecLocFiller visitor methods for DTSTLoc and DependentNameTypeLoc by removing what now seems to be dead code (adding corresponding assertions). llvm-svn: 149923
* Removed redundant location info from ElaboratedTypeLoc / DependentNameLoc / ↵Abramo Bagnara2012-02-061-6/+6
| | | | | | DependentTSTLoc. Uniformed names referencing elaborated keyword. No intended functionality changes. llvm-svn: 149889
* Added location for template keyword in TemplateSpecializationTypeLoc. In the ↵Abramo Bagnara2012-02-061-24/+26
| | | | | | process removed some naming ambiguities. llvm-svn: 149870
* Fixed instantiation of DependentScopeDeclRefExpr.Abramo Bagnara2012-02-061-4/+4
| | | | llvm-svn: 149868
* Basic: import SmallString<> into clang namespaceDylan Noblesmith2012-02-051-1/+1
| | | | | | | (I was going to fix the TODO about DenseMap too, but that would break self-host right now. See PR11922.) llvm-svn: 149799
* Move a method from IdentifierTable.h out of line and remove the SmallString ↵Benjamin Kramer2012-02-041-0/+1
| | | | | | | | include. Fix all the transitive include users. llvm-svn: 149783
* In C++11 mode, when an integral constant expression is desired and we have aRichard Smith2012-02-041-5/+5
| | | | | | | | | | | | | | | | | | 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 a pack expansion occurs in the template argument list of an aliasDouglas Gregor2012-02-031-5/+14
| | | | | | | | template without a corresponding parameter pack, don't immediately substitute the alias template. This is under discussion in the C++ committee, and may become ill-formed, but for now we match GCC. llvm-svn: 149697
* Implement support for a pack expansion into a fixed-lengthDouglas Gregor2012-02-031-45/+101
| | | | | | | | | template. Such pack expansions can easily fail at template instantiation time, if the expanded parameter packs are of the wrong length. Fixes <rdar://problem/10040867>, PR9021, and the example that came up today at Going Native. llvm-svn: 149685
* Split Sema::MarkDeclarationReferenced into multiple functions; the ↵Eli Friedman2012-02-021-1/+1
| | | | | | additional entry points are needed to implement C++11 odr-use marking correctly. No functional change in this patch; I'll actually make the change which fixes the odr-use marking in a followup patch. llvm-svn: 149586
OpenPOWER on IntegriCloud