summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaTemplate.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Partial and full specializations of a class template may have aDouglas Gregor2010-05-061-7/+8
| | | | | | | | | different tag kind ("struct" vs. "class") than the primary template, which has an affect on access control. Should fix the last remaining Boost.Accumulors failure. llvm-svn: 103144
* Support for 'template' as a disambiguator (PR7030)Douglas Gregor2010-05-051-2/+4
| | | | | | | | | | | | | ParseOptionalCXXScopeSpecifier() only annotates the subset of template-ids which are not subject to lexical ambiguity. Add support for the more general case in ParseUnqualifiedId() to handle cases such as A::template B(). Also improve some diagnostic locations. Fixes PR7030, from Alp Toker! llvm-svn: 103081
* It turns out that basically every caller to RequireCompleteDeclContextJohn McCall2010-05-011-32/+22
| | | | | | | already knows what context it's looking in. Just pass that context in instead of (questionably) recalculating it. llvm-svn: 102818
* After substituting a template argument for a non-type templateDouglas Gregor2010-04-301-1/+13
| | | | | | | | | parameter with pointer-to-member type, we may have to perform a qualification conversion, since the pointee type of the parameter might be more qualified than the pointee type of the argument we form from the declaration. Fixes PR6986. llvm-svn: 102777
* Clean up our handling of local instantiation scopes, which keep trackDouglas Gregor2010-04-301-1/+3
| | | | | | | | | | | | | | | | | | | | | of the mapping from local declarations to their instantiated counterparts during template instantiation. Previously, we tried to do some unholy merging of local instantiation scopes that involved storing a single hash table along with an "undo" list on the side... which was ugly, and never handled function parameters properly. Now, we just keep separate hash tables for each local instantiation scope, and "combining" two scopes means that we'll look in each of the combined hash tables. The combined scope stack is rarely deep, and this makes it easy to avoid the "undo" issues we were hitting. Also, I've simplified the logic for function parameters: if we're declaring a function and we need the function parameters to live longer, we just push them back into the local instantiation scope where we need them. Fixes PR6990. llvm-svn: 102732
* Introduce a sequence number into class template partialDouglas Gregor2010-04-301-1/+4
| | | | | | | | | | | specializations, which keeps track of the order in which they were originally declared. We use this number so that we can always walk the list of partial specializations in a predictable order during matching or template instantiation. This also fixes a failure in Boost.Proto, where SourceManager::isBeforeInTranslationUnit was behaving poorly in inconsistent ways. llvm-svn: 102693
* Rebuild the nested name specifiers in member-pointer declarator chunks whenJohn McCall2010-04-291-10/+50
| | | | | | | | | entering the current instantiation. Set up a little to preserve type location information for typename types while we're in there. Fixes a Boost failure. llvm-svn: 102673
* It turns out that we *can* end up having to display template argumentDouglas Gregor2010-04-291-2/+9
| | | | | | | | bindings when the template argument is still an expression; it happens while checking the template arguments of a class template partial specializations. Fixes PR6964. llvm-svn: 102595
* Make the InjectedClassNameType the canonical type of the current instantiationJohn McCall2010-04-271-20/+70
| | | | | | | | | | | | | | | | of a class template or class template partial specialization. That is to say, in template <class T> class A { ... }; or template <class T> class B<const T*> { ... }; make 'A<T>' and 'B<const T*>' sugar for the corresponding InjectedClassNameType when written inside the appropriate context. This allows us to track the current instantiation appropriately even inside AST routines. It also allows us to compute a DeclContext for a type much more efficiently, at some extra cost every time we write a template specialization (which can be optimized, but I've left it simple in this patch). llvm-svn: 102407
* When we take the address of a declaration to bind it to a non-typeDouglas Gregor2010-04-241-0/+1
| | | | | | | template parameter, by sure to mark that declaration as "referenced". The Boost.Iterator library now passes all tests. llvm-svn: 102256
* CastExpr should not hold a pointer to the base path. More cleanup.Anders Carlsson2010-04-241-2/+0
| | | | llvm-svn: 102249
* Be more careful around dependent nested-name-specifiers, complainingDouglas Gregor2010-04-241-0/+7
| | | | | | | | when they are not complete (since we could not match them up to anything) and ensuring that enum parsing can cope with dependent elaborated-type-specifiers. Fixes PR6915 and PR6649. llvm-svn: 102247
* Keep track of when DependentNameTypes have no associated keywordDouglas Gregor2010-04-241-4/+6
| | | | | | | (e.g., no typename, enum, class, etc.), e.g., because the context is one that is known to refer to a type. Patch from Enea Zaffanella! llvm-svn: 102243
* Add an InheritancePath parameter to the ImplicitCastExpr constructor.Anders Carlsson2010-04-231-0/+2
| | | | llvm-svn: 102218
* C++ [namespace.memdef]p3 only applies when the friend is not named viaDouglas Gregor2010-04-181-15/+17
| | | | | | | | | a qualified name. We weren't checking for an empty nested-name-specifier when dealing with friend class templates (although we were checking in the other places where we deal with this paragraph). Fixes a Boost.Serialization showstopper. llvm-svn: 101724
* Audit uses of Sema::LookupSingleName for those lookups that areDouglas Gregor2010-04-151-2/+4
| | | | | | | | | | | intended for redeclarations, fixing those that need it. Fixes PR6831. This uncovered an issue where the C++ type-specifier-seq parsing logic would try to perform name lookup on an identifier after it already had a type-specifier, which could also lead to spurious ambiguity errors (as in PR6831, but with a different test case). llvm-svn: 101419
* Feed proper source-location information into Sema::LookupSingleResult,Douglas Gregor2010-04-151-2/+4
| | | | | | | | in case it ends up doing something that might trigger diagnostics (template instantiation, ambiguity reporting, access reporting). Noticed while working on PR6831. llvm-svn: 101412
* Always diagnose and complain about problems inDouglas Gregor2010-04-141-25/+25
| | | | | | | | | | ResolveAddressOfOverloadedFunction when asked to complain. Previously, we had some weird handshake where ResolveAddressOfOverloadedFunction expected its caller to handle some of the diagnostics but not others, and yet there was no way for the caller to know which case we were in. Eliminate this madness, fixing <rdar://problem/7765884>. llvm-svn: 101312
* Teach typo correction about various language keywords. We can'tDouglas Gregor2010-04-141-1/+2
| | | | | | | | | | | | | generally recover from typos in keywords (since we would effectively have to mangle the token stream). However, there are still benefits to typo-correcting with keywords: - We don't make stupid suggestions when the user typed something that is similar to a keyword. - We can suggest the keyword in a diagnostic (did you mean "static_cast"?), even if we can't recover and therefore don't have a fix-it. llvm-svn: 101274
* Support befriending members of class template specializations.John McCall2010-04-131-1/+33
| | | | llvm-svn: 101173
* Implement C++ [temp.local]p4, which specifies how we eliminateDouglas Gregor2010-04-121-8/+23
| | | | | | | | | name-lookup ambiguities when there are multiple base classes that are all specializations of the same class template. This is part of a general cleanup for ambiguities in template-name lookup. Fixes PR6717. llvm-svn: 101065
* Fix a crash-on-invalid involving name lookup of tag names, where weDouglas Gregor2010-04-121-6/+14
| | | | | | | ended up finding a function template that we didn't expect. Recover more gracefully, and fix a similar issue for class templates. llvm-svn: 101040
* Only complain about explicit instantiations following explicitDouglas Gregor2010-04-091-1/+2
| | | | | | | | | | | | specializations when the explicit instantiation was... explicitly written, i.e., not the product of an explicit instantiation of an enclosing class. Fixes this spurious warning when Clang builds LLVM: /Volumes/Data/dgregor/Projects/llvm/lib/CodeGen/MachineDominators.cpp:22:1: warning: explicit instantiation of 'addRoot' that occurs after an explicit specialization will be ignored (C++0x extension) [-pedantic] llvm-svn: 100900
* Make CXXScopeSpec invalid when incomplete, and propagate that into anyJeffrey Yasskin2010-04-081-7/+7
| | | | | | | Declarator that depends on it. This fixes several redundant errors and bad recoveries. llvm-svn: 100779
* Implement dependent friend function template specializations.John McCall2010-04-081-0/+36
| | | | llvm-svn: 100753
* When a template (without arguments) is passed as a template typeJeffrey Yasskin2010-04-081-1/+16
| | | | | | | parameter, explicitly ask the user to give it arguments. We used to complain that it wasn't a type and expect the user to figure it out. llvm-svn: 100729
* Overhaul checking of non-type template arguments that should refer toDouglas Gregor2010-04-011-170/+247
| | | | | | | | | | | an object or function. Our previous checking was too lax, and ended up allowing missing or extraneous address-of operators, among other evils. The new checking provides better diagnostics and adheres more closely to the standard. Fixes PR6563 and PR6749. llvm-svn: 100125
* Fix -Asserts warning, and protect against missing case.Daniel Dunbar2010-04-011-2/+3
| | | | llvm-svn: 100115
* Change the representation of dependent elaborated-type-specifiersDouglas Gregor2010-03-311-8/+9
| | | | | | | | | | | | | | (such as "class T::foo") from an ElaboratedType of a TypenameType to a DependentNameType, which more accurately models the underlying concept. Improve template instantiation for DependentNameType nodes that represent nested-name-specifiers, by performing tag name lookup and checking the resulting tag appropriately. Fixes PR5681. There is still much testing and cleanup to do in this area. llvm-svn: 100054
* Extend DependentNameType with a keyword enum that specifies whetherDouglas Gregor2010-03-311-6/+9
| | | | | | | this was parsed as a typename-specifier, elaborated-type-specifier (including the kind), or just a dependent qualified type name. llvm-svn: 100039
* Reinstate my CodeModificationHint -> FixItHint renaming patch, withoutDouglas Gregor2010-03-311-16/+12
| | | | | | the C-only "optimization". llvm-svn: 100022
* Rename TypenameType to DependentNameType in anticipation of someDouglas Gregor2010-03-311-11/+11
| | | | | | refactoring work in this area. llvm-svn: 100019
* Revert r100008, which inexplicably breaks the clang-i686-darwin10 builderDouglas Gregor2010-03-311-12/+16
| | | | llvm-svn: 100018
* Rename CodeModificationHint to FixItHint, since we've been using theDouglas Gregor2010-03-311-16/+12
| | | | | | | term "fix-it" everywhere and even *I* get tired of long names sometimes. No functionality change. llvm-svn: 100008
* Propagate the "found declaration" (i.e. the using declaration instead ofJohn McCall2010-03-301-2/+5
| | | | | | | | | | | | | the underlying/instantiated decl) through a lot of API, including "intermediate" MemberExprs required for (e.g.) template instantiation. This is necessary because of the access semantics of member accesses to using declarations: only the base class *containing the using decl* need be accessible from the naming class. This allows us to complete an access-controlled selfhost, if there are no recent regressions. llvm-svn: 99936
* Optimize PartialDiagnostic's memory-allocation behavior by placing aDouglas Gregor2010-03-291-6/+6
| | | | | | | | | | | | | | cache of PartialDiagnostic::Storage objects into an allocator within the ASTContext. This eliminates a significant amount of malloc traffic, for a 10% performance improvement in -fsyntax-only wall-clock time with 403.gcc's combine.c. Also, eliminate the RequireNonAbstractType hack I put in earlier, which was but a symptom of this larger problem. Fixes <rdar://problem/7806091>. llvm-svn: 99849
* After performing template argument deduction for a function template,Douglas Gregor2010-03-281-10/+128
| | | | | | | | | | | | | | | | | | | | check deduced non-type template arguments and template template arguments against the template parameters for which they were deduced, performing conversions as appropriate so that deduced template arguments get the same treatment as explicitly-specified template arguments. This is the bulk of PR6723. Also keep track of whether deduction of a non-type template argument came from an array bound (vs. anywhere else). With this information, we enforce C++ [temp.deduct.type]p17, which requires exact type matches when deduction deduces a non-type template argument from something that is not an array bound. Finally, when in a SFINAE context, translate the "zero sized arrays are an extension" extension diagnostic into a hard error (for better standard conformance), which was a minor part of PR6723. llvm-svn: 99734
* Reinstate change to non-type template arguments of integral type, soDouglas Gregor2010-03-261-19/+20
| | | | | | | | | that we extend/truncate then correct the sign to convert the non-type template argument to the template parameter's type. Previously, we reported an error when the non-type template argument was out of range; now we just warn. llvm-svn: 99600
* Revert attempted fix for integral template arguments. It seems to have ↵Douglas Gregor2010-03-261-20/+19
| | | | | | broken tramp3d-v4. llvm-svn: 99583
* Warn when the conversion of an integral non-type template argument toDouglas Gregor2010-03-251-19/+20
| | | | | | | | | | | | | | | | | | the type of its corresponding non-type template parameter changes the value. Previously, we were diagnosing this as an error, which was wrong. We give reasonably nice warnings like: test/SemaTemplate/temp_arg_nontype.cpp:100:10: warning: non-type template argument value '256' truncated to '0' for template parameter of type 'unsigned char' Overflow<256> *overflow3; // expected-warning{{non-type template ... ^~~ test/SemaTemplate/temp_arg_nontype.cpp:96:24: note: template parameter is declared here template<unsigned char C> struct Overflow; ^ llvm-svn: 99561
* Preserve type-source information in friend declarations.John McCall2010-03-251-1/+1
| | | | llvm-svn: 99525
* Support friend function specializations.John McCall2010-03-241-4/+11
| | | | llvm-svn: 99389
* revert 99311. Looks like it broke darwin bootstrap.Rafael Espindola2010-03-231-1/+7
| | | | llvm-svn: 99317
* Avoid producing implicit methods when we have a explicit template instantiationRafael Espindola2010-03-231-7/+1
| | | | | | declaration. llvm-svn: 99311
* A fixed version of r99174 which also includes a test that we emit vtables whenRafael Espindola2010-03-221-1/+10
| | | | | | we see an specialization definition ever if we then see a extern template declaration. llvm-svn: 99226
* revert r99174. It caused PR6677. Will try to debug why tonight.Rafael Espindola2010-03-221-5/+1
| | | | llvm-svn: 99188
* When handling a TSK_ExplicitInstantiationDefinition after aRafael Espindola2010-03-221-1/+5
| | | | | | | | | TSK_ExplicitInstantiationDeclaration make sure we call MaybeMarkVirtualMembersReferenced with a method attached to the definition. Remove the hack that forced vtable emition with declarations. llvm-svn: 99174
* Remember declaration scope qualifiers in the AST. Imposes no memory overheadJohn McCall2010-03-151-0/+10
| | | | | | | | | | | on unqualified declarations. Patch by Enea Zaffanella! Minimal adjustments: allocate the ExtInfo nodes with the ASTContext and delete them during Destroy(). I audited a bunch of Destroy methods at the same time, to ensure that the correct teardown was being done. llvm-svn: 98540
* Split C++ friend declarations into their own header/implementation file.John McCall2010-03-111-0/+1
| | | | | | | | | I'm expecting this portion of the AST to grow and change, and I'd like to be able to do that with minimal recompilation. If this proves unnecessary when access control is fully-implemented, I'll fold the classes back into DeclCXX.h. llvm-svn: 98249
* Create a new InjectedClassNameType to represent bare-word references to the John McCall2010-03-101-10/+13
| | | | | | | | | | | | | 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
OpenPOWER on IntegriCloud