summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplate.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Robustify callers that rebuild typename type nodes again NULL returnDouglas Gregor2010-03-071-0/+3
| | | | | | types. Fixes PR6463. llvm-svn: 97924
* Suppress implicit member redeclarations arising from explicit instantiationJohn McCall2010-03-021-0/+1
| | | | | | | | | | | | declarations after the member has been explicitly specialized. We already did this after explicit instantiation definitions; not doing it for declarations meant that subsequent definitions would see a previous member declaration with specialization kind "explicit instantiation decl", which would then happily get overridden. Fixes PR 6458. llvm-svn: 97605
* An explicit specialization is allowed following an explicitDouglas Gregor2010-02-261-7/+41
| | | | | | | instantiation so long as that explicit specialization was declared previously. Fixes PR6160. llvm-svn: 97210
* Restore the invariant that a nested-name-specifier can only containDouglas Gregor2010-02-251-1/+0
| | | | | | | | | class types, dependent types, and namespaces. I had previously weakened this invariant while working on parsing pseudo-destructor expressions, but recent work in that area has made these changes unnecessary. llvm-svn: 97112
* Implement support for parsing pseudo-destructor expression with a ↵Douglas Gregor2010-02-211-0/+1
| | | | | | | | | | | | nested-name-specifier, e.g., typedef int Int; int *p; p->Int::~Int(); This weakens the invariant that the only types in nested-name-specifiers are tag types (restricted to class types in C++98/03). However, we weaken this invariant as little as possible, accepting arbitrary types in nested-name-specifiers only when we're in a member access expression that looks like a pseudo-destructor expression. llvm-svn: 96743
* Improve parsing and instantiation of destructor names, so that we canDouglas Gregor2010-02-161-3/+6
| | | | | | | | | | | | | | | | | | | | | | | now cope with the destruction of types named as dependent templates, e.g., y->template Y<T>::~Y() Nominally, we implement C++0x [basic.lookup.qual]p6. However, we don't follow the letter of the standard here because that would fail to parse template<typename T, typename U> X0<T, U>::~X0() { } properly. The problem is captured in core issue 339, which gives some (but not enough!) guidance. I expect to revisit this code when the resolution of 339 is clear, and/or we start capturing better source information for DeclarationNames. Fixes PR6152. llvm-svn: 96367
* Permit the use of typedefs of class template specializations inDouglas Gregor2010-02-131-10/+6
| | | | | | | qualified declarator-ids. This patch is actually due to Cornelius; fixes PR6179. llvm-svn: 96082
* Strip attributes and 'inline' off the "previous declaration" of aJohn McCall2010-02-111-15/+27
| | | | | | | template explicit specialization. Complete an apparently stalled refactor towards using CheckSpecializationInstantiationRedecl(). llvm-svn: 95845
* Eliminate a bunch of unnecessary ASTContexts from members functions ofDouglas Gregor2010-02-111-2/+1
| | | | | | Decl subclasses. No functionality change. llvm-svn: 95841
* Eliminate the ASTContext parameter from RecordDecl::getDefinition()Douglas Gregor2010-02-111-8/+8
| | | | | | | and CXXRecordDecl::getDefinition(); it's totally unnecessary. No functionality change. llvm-svn: 95836
* Implement a specific diagnostic when a class template partialDouglas Gregor2010-02-091-9/+20
| | | | | | | specialization does not use any of its template parameters, then recover far more gracefully. Fixes PR6181. llvm-svn: 95629
* Thread a source location into the template-argument deduction routines. ThereJohn McCall2010-02-081-2/+2
| | | | | | | may be some other places that could take advantage of this new information, but I haven't really looked yet. llvm-svn: 95600
* Fix PR6149 by looking at the qualifiers on the referred to type for non-typeChandler Carruth2010-02-031-2/+3
| | | | | | | reference template arguments. Adds test cases for the cv-quals of reference arguments. llvm-svn: 95217
* When a function or variable somehow depends on a type or declarationDouglas Gregor2010-02-031-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | that is in an anonymous namespace, give that function or variable internal linkage. This change models an oddity of the C++ standard, where names declared in an anonymous namespace have external linkage but, because anonymous namespace are really "uniquely-named" namespaces, the names cannot be referenced from other translation units. That means that they have external linkage for semantic analysis, but the only sensible implementation for code generation is to give them internal linkage. We now model this notion via the UniqueExternalLinkage linkage type. There are several changes here: - Extended NamedDecl::getLinkage() to produce UniqueExternalLinkage when the declaration is in an anonymous namespace. - Added Type::getLinkage() to determine the linkage of a type, which is defined as the minimum linkage of the types (when we're dealing with a compound type that is not a struct/class/union). - Extended NamedDecl::getLinkage() to consider the linkage of the template arguments and template parameters of function template specializations and class template specializations. - Taught code generation to rely on NamedDecl::getLinkage() when determining the linkage of variables and functions, also considering the linkage of the types of those variables and functions (C++ only). Map UniqueExternalLinkage to internal linkage, taking out the explicit checks for isInAnonymousNamespace(). This fixes much of PR5792, which, as discovered by Anders Carlsson, is actually the reason behind the pass-manager assertion that causes the majority of clang-on-clang regression test failures. With this fix, Clang-built-Clang+LLVM passes 88% of its regression tests (up from 67%). The specific numbers are: LLVM: Expected Passes : 4006 Expected Failures : 32 Unsupported Tests : 40 Unexpected Failures: 736 Clang: Expected Passes : 1903 Expected Failures : 14 Unexpected Failures: 75 Overall: Expected Passes : 5909 Expected Failures : 46 Unsupported Tests : 40 Unexpected Failures: 811 Still to do: - Improve testing - Check whether we should allow the presence of types with InternalLinkage (in addition to UniqueExternalLinkage) given variables/functions internal linkage in C++, as mentioned in PR5792. - Determine how expensive the getLinkage() calls are in practice; consider caching the result in NamedDecl. - Assess the feasibility of Chris's idea in comment #1 of PR5792. llvm-svn: 95216
* Fix PR6159 and several other problems with value-dependent non-type templateChandler Carruth2010-01-311-9/+31
| | | | | | | | | | | | | arguments. This both prevents meaningless checks on these arguments and ensures that they are represented as an expression by the instantiation. Cleaned up and added standard text to the relevant test case. Also started adding tests for *rejected* cases. At least one FIXME here where (I think) we allow something we shouldn't. More to come in the area of rejecting crazy arguments with decent diagnostics. Suggestions welcome for still better diagnostics on these errors! llvm-svn: 94953
* Implement access control for overloaded functions. Suppress access controlJohn McCall2010-01-271-17/+23
| | | | | | | diagnostics in "early" lookups, such as during typename checks and when building unresolved lookup expressions. llvm-svn: 94647
* Create function, block, and template parameters in the context of theJohn McCall2010-01-221-5/+6
| | | | | | | | | 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
* Teach Sema::ActOnDependentTemplateName that a dependent template nameDouglas Gregor2010-01-191-5/+9
| | | | | | | | in a member access expression referring into the current instantiation need not be resolved at template definition *if* the current instantiation has any dependent base classes. Fixes PR6081. llvm-svn: 93877
* When performing qualified name lookup into the current instantiation,Douglas Gregor2010-01-151-8/+4
| | | | | | | | | | | | | do not look into base classes if there are any dependent base classes. Instead, note in the lookup result that we couldn't look into any dependent bases. Use that new result kind to detect when this case occurs, so that we can fall back to treating the type/value/etc. as a member of an unknown specialization. Fixes an issue where we were resolving lookup at template definition time and then missing an ambiguity at template instantiation time. llvm-svn: 93497
* When qualified lookup into the current instantiation fails (because itDouglas Gregor2010-01-141-3/+15
| | | | | | | | finds nothing), and the current instantiation has dependent base classes, treat the qualified lookup as if it referred to an unknown specialization. Fixes PR6031. llvm-svn: 93433
* Improve recovery for template-ids whose template-name doesn't actuallyDouglas Gregor2010-01-121-0/+24
| | | | | | | | | | | | | | | | | | | | | | name a template, when they occur in a base-specifier. This is one of the (few) places where we know for sure that an identifier followed by a '<' must be a template name, so we can diagnose and recover well: test/SemaTemplate/dependent-base-classes.cpp:9:16: error: missing 'template' keyword prior to dependent template name 'T::apply' struct X1 : T::apply<U> { }; // expected-error{{missing 'template' ... ^ template test/SemaTemplate/dependent-base-classes.cpp:12:13: error: unknown template name 'vector' struct X2 : vector<T> { }; // expected-error{{unknown template name 'vector'}} ^ 2 diagnostics generated. llvm-svn: 93257
* When determining whether a given name is a template in a dependentDouglas Gregor2010-01-121-2/+3
| | | | | | | | context, do not attempt typo correction. This harms performance (as Abramo noted) and can cause some amusing errors, as in this new testcase. llvm-svn: 93240
* Eliminate an embarrassing performance regression in C/ObjC, where weDouglas Gregor2010-01-111-0/+2
| | | | | | | | | | were performing name lookup for template names in C/ObjC and always finding nothing. Turn off such lookup unless we're in C++ mode, along with the check that determines whether the given identifier is a "current class name", and assert that we don't make this mistake again. llvm-svn: 93207
* Implement name lookup for conversion function template specializationsDouglas Gregor2010-01-111-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | (C++ [temp.mem]p5-6), which involves template argument deduction based on the type named, e.g., given struct X { template<typename T> operator T*(); } x; when we call x.operator int*(); we perform template argument deduction to determine that T=int. This template argument deduction is needed for template specialization and explicit instantiation, e.g., template<> X::operator float*() { /* ... */ } and when calling or otherwise naming a conversion function (as in the first example). This fixes PR5742 and PR5762, although there's some remaining ugliness that's causing out-of-line definitions of conversion function templates to fail. I'll look into that separately. llvm-svn: 93162
* Whenever we emit a typo-correction diagnostic, also emit a noteDouglas Gregor2010-01-071-0/+3
| | | | | | | pointing to the declaration that we found that has that name (if it is unique). llvm-svn: 92877
* Typo correction for template names, e.g.,Douglas Gregor2009-12-311-1/+25
| | | | | | | | | | typo.cpp:27:8: error: no template named 'basic_sting' in namespace 'std'; did you mean 'basic_string'? std::basic_sting<char> b2; ~~~~~^~~~~~~~~~~ basic_string llvm-svn: 92348
* Fix the overflow calculation in Sema::CheckTemplateArgument to be a bit moreEli Friedman2009-12-231-1/+8
| | | | | | accurate. llvm-svn: 92018
* When a template-id refers to a single function template, and theDouglas Gregor2009-12-211-0/+3
| | | | | | | | | | explicitly-specified template arguments are enough to determine the instantiation, and either template argument deduction fails or is not performed in that context, we can resolve the template-id down to a function template specialization (so sayeth C++0x [temp.arg.explicit]p3). Fixes PR5811. llvm-svn: 91852
* Set up the semantic context correctly when declaring a friend class template.John McCall2009-12-181-4/+5
| | | | llvm-svn: 91678
* Patch over yet more problems with friend declarations which were provokingJohn McCall2009-12-171-23/+23
| | | | | | | 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
* Diagnose the use of typedefs for template specialization types in the scopeJohn McCall2009-12-151-1/+20
| | | | | | | | specifiers for out-of-line declarations, e.g. typedef Temp<int> MyTemp; template <> MyTemp::foo; llvm-svn: 91395
* Un-namespace-qualify llvm_unreachable. It's a macro, so the qualification gaveJeffrey Yasskin2009-12-121-6/+6
| | | | | | no extra safety anyway. llvm-svn: 91207
* DeclaratorInfo -> TypeSourceInfo. Makes an effort to rename associated ↵John McCall2009-12-071-19/+19
| | | | | | | | | | | | | | | | | | | | | 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
* remove some extraneous syntax: sourceloc implicitly converts to sourcerange.Chris Lattner2009-12-061-2/+1
| | | | llvm-svn: 90710
* Rip out the last remaining implicit use of OverloadedFunctionDecl in Sema:John McCall2009-12-021-2/+1
| | | | | | | LookupResult::getAsSingleDecl() is no more. Shift Sema::LookupSingleName to return null on overloaded results. llvm-svn: 90309
* Push overloaded function templates through the parser using a totally differentJohn McCall2009-12-021-27/+27
| | | | | | | leaked data structure than before. This kills off the last remaining explicit uses of OverloadedFunctionDecl in Sema. llvm-svn: 90306
* Stop trying to analyze class-hierarchies for dependently-scoped id-expressions;John McCall2009-12-021-105/+9
| | | | | | | | | | | | | there's nothing interesting we can say now that we're correctly not requiring the qualifier to name a known base class in dependent contexts. Require scope specifiers on member access expressions to name complete types if they're not dependent; delay lookup when they are dependent. Use more appropriate diagnostics when qualified implicit member access expressions find declarations from unrelated classes. llvm-svn: 90289
* Rework how we support C++ implicit member accesses. If we can resolve anJohn McCall2009-12-011-3/+3
| | | | | | | | | | | | | | | implicit member access to a specific declaration, go ahead and create it as a DeclRefExpr or a MemberExpr (with implicit CXXThisExpr base) as appropriate. Otherwise, create an UnresolvedMemberExpr or DependentScopeMemberExpr with a null base expression. By representing implicit accesses directly in the AST, we get the ability to correctly delay the decision about whether it's actually an instance member access or not until resolution is complete. This permits us to correctly avoid diagnosing the 'problem' of 'MyType::foo()' where the relationship to the type isn't really known until instantiation. llvm-svn: 90266
* Remove all of Sema's explicit uses of OverloadedFunctionDecl except forJohn McCall2009-11-301-37/+0
| | | | | | those associated with TemplateNames. llvm-svn: 90162
* Add DeclarationName support for C++0x operator literals. They should now work asAlexis Hunt2009-11-291-2/+2
| | | | | | | function names outside of templates - they'll probably cause some damage there as they're largely untested. llvm-svn: 90064
* Remove remaining VISIBILITY_HIDDEN from anonymous namespaces.Benjamin Kramer2009-11-281-2/+1
| | | | llvm-svn: 90044
* Fix test and handle IK_LiteralOperatorId in a few more places.Alexis Hunt2009-11-281-1/+8
| | | | llvm-svn: 90030
* Implement the rules in C++ [basic.link] and C99 6.2.2 for computingDouglas Gregor2009-11-251-2/+2
| | | | | | | | | | | the linkage of a declaration. Switch the lame (and completely wrong) NamedDecl::hasLinkage() over to using the new NamedDecl::getLinkage(), along with the "can this declaration be a template argument?" check that started all of this. Fixes -fsyntax-only for PR5597. llvm-svn: 89891
* Implement support for default template arguments of function templates.Douglas Gregor2009-11-251-1/+60
| | | | llvm-svn: 89874
* Diagnose ill-formed uses of default template arguments inDouglas Gregor2009-11-251-4/+84
| | | | | | | | | | | function templates (in C++98), friend function templates, and out-of-line definitions of members of class templates. Also handles merging of default template arguments from previous declarations of function templates, for C++0x. However, we don't yet make use of those default template arguments. llvm-svn: 89872
* Don't crash when we re-use a template specialization node for an explicit ↵Douglas Gregor2009-11-251-5/+9
| | | | | | instantiation. lib/Support/CommandLine.cpp is our test case llvm-svn: 89845
* Fix some major problems dealing with dependently-qualified names in implicitJohn McCall2009-11-241-4/+11
| | | | | | member-reference contexts. Fixes some clang-on-clang asserts. llvm-svn: 89796
* Rip out TemplateIdRefExpr and make UnresolvedLookupExpr and John McCall2009-11-241-94/+272
| | | | | | | | | | | | DependentScopeDeclRefExpr support storing templateids. Unite the common code paths between ActOnDeclarationNameExpr and ActOnTemplateIdExpr. This gets us to a point where we don't need to store function templates in the AST using TemplateNames, which is critical to ripping out OverloadedFunction. Also resolves a few FIXMEs. llvm-svn: 89785
* Set the template specialization kind before instantiating the function ↵Anders Carlsson2009-11-241-2/+2
| | | | | | definition so that the function will have the right linkage. llvm-svn: 89740
* Tolerate extraneous "template<>" headers better, downgrading theDouglas Gregor2009-11-231-4/+16
| | | | | | | | | | complaint to a warning and providing a helpful node in the case where the "template<>" header is redundant because the corresponding template-id refers to an explicit specialization. C++0x might still change this behavior, and existing practice is all over the place on the number of "template<>" headers actually needed. llvm-svn: 89651
OpenPOWER on IntegriCloud