summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaLookup.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Rip out TemplateIdRefExpr and make UnresolvedLookupExpr and John McCall2009-11-241-5/+1
| | | | | | | | | | | | 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
* Consider a FunctionTemplate to be an overload all on its lonesome. TrackJohn McCall2009-11-221-4/+12
| | | | | | this information through lookup rather than rederiving it. llvm-svn: 89570
* "Incremental" progress on using expressions, by which I mean totally rippingJohn McCall2009-11-211-23/+19
| | | | | | | | | | | | | | | | | | | | | | into pretty much everything about overload resolution in order to wean BuildDeclarationNameExpr off LookupResult::getAsSingleDecl(). Replace UnresolvedFunctionNameExpr with UnresolvedLookupExpr, which generalizes the idea of a non-member lookup that we haven't totally resolved yet, whether by overloading, argument-dependent lookup, or (eventually) the presence of a function template in the lookup results. Incidentally fixes a problem with argument-dependent lookup where we were still performing ADL even when the lookup results contained something from a block scope. Incidentally improves a diagnostic when using an ObjC ivar from a class method. This just fell out from rewriting BuildDeclarationNameExpr's interaction with lookup, and I'm too apathetic to break it out. The only remaining uses of OverloadedFunctionDecl that I know of are in TemplateName and MemberExpr. llvm-svn: 89544
* Overhaul previous-declaration and overload checking to work on lookup resultsJohn McCall2009-11-181-1/+5
| | | | | | | rather than NamedDecl*. This is a major step towards eliminating OverloadedFunctionDecl. llvm-svn: 89263
* Split LookupResult into its own header.John McCall2009-11-181-13/+21
| | | | llvm-svn: 89199
* Incremental progress on using declarations. Split UnresolvedUsingDecl intoJohn McCall2009-11-181-5/+17
| | | | | | | | | | two classes, one for typenames and one for values; this seems to have some support from Doug if not necessarily from the extremely-vague-on-this-point standard. Track the location of the 'typename' keyword in a using-typename decl. Make a new lookup result for unresolved values and deal with it in most places. llvm-svn: 89184
* Temporarily unbreak the clang-on-llvm tests. :) Not going to fix unresolvedJohn McCall2009-11-171-9/+1
| | | | | | lookup all in a night. llvm-svn: 89089
* Store "sugared" decls in LookupResults (i.e. decl aliases like using ↵John McCall2009-11-171-9/+14
| | | | | | | | | | | | declarations); strip the sugar off in getFoundDecl() and getAsSingleDecl(), but leave it on for clients like overload resolution who want to use the iterators. Refactor a few pieces of overload resolution to strip off using declarations in a single place. Don't do anything useful with the extra context knowledge yet. llvm-svn: 89061
* Instead of hanging a using declaration's target decls directly off the using John McCall2009-11-171-1/+1
| | | | | | | decl, create shadow declarations and put them in scope like normal. Work in progress. llvm-svn: 89048
* Carry lookup configuration throughout lookup on the LookupResult. GiveJohn McCall2009-11-171-54/+54
| | | | | | | | | | | | | LookupResult RAII powers to diagnose ambiguity in the results. Other diagnostics (e.g. access control and deprecation) will be moved to automatically trigger during lookup as part of this same mechanism. This abstraction makes it much easier to encapsulate aliasing declarations (e.g. using declarations) inside the lookup system: eventually, lookup will just produce the aliases in the LookupResult, and the standard access methods will naturally strip the aliases off. llvm-svn: 89027
* First part of changes to eliminate problems with cv-qualifiers andDouglas Gregor2009-11-161-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | sugared types. The basic problem is that our qualifier accessors (getQualifiers, getCVRQualifiers, isConstQualified, etc.) only look at the current QualType and not at any qualifiers that come from sugared types, meaning that we won't see these qualifiers through, e.g., typedefs: typedef const int CInt; typedef CInt Self; Self.isConstQualified() currently returns false! Various bugs (e.g., PR5383) have cropped up all over the front end due to such problems. I'm addressing this problem by splitting each qualifier accessor into two versions: - the "local" version only returns qualifiers on this particular QualType instance - the "normal" version that will eventually combine qualifiers from this QualType instance with the qualifiers on the canonical type to produce the full set of qualifiers. This commit adds the local versions and switches a few callers from the "normal" version (e.g., isConstQualified) over to the "local" version (e.g., isLocalConstQualified) when that is the right thing to do, e.g., because we're printing or serializing the qualifiers. Also, switch a bunch of Context.getCanonicalType(T1).getUnqualifiedType() == Context.getCanonicalType(T2).getQualifiedType() expressions over to Context.hasSameUnqualifiedType(T1, T2) llvm-svn: 88969
* Introduce a new representation for template templateDouglas Gregor2009-11-111-3/+6
| | | | | | | | | | | | | | | | | | | | | | | | | parameters. Rather than storing them as either declarations (for the non-dependent case) or expressions (for the dependent case), we now (always) store them as TemplateNames. The primary change here is to add a new kind of TemplateArgument, which stores a TemplateName. However, making that change ripples to every switch on a TemplateArgument's kind, also affecting TemplateArgumentLocInfo/TemplateArgumentLoc, default template arguments for template template parameters, type-checking of template template arguments, etc. This change is light on testing. It should fix several pre-existing problems with template template parameters, such as: - the inability to use dependent template names as template template arguments - template template parameter default arguments cannot be instantiation However, there are enough pieces missing that more implementation is required before we can adequately test template template parameters. llvm-svn: 86777
* Create a new Scope when parsing a declaration with a C++ scope specifier.John McCall2009-11-111-3/+0
| | | | llvm-svn: 86764
* Fix a similar problem with qualified lookup through using directives,John McCall2009-11-101-1/+1
| | | | | | | although in this case we probably just run a risk of duplicating work; I can't think of how this could cause a bug. llvm-svn: 86680
* Make a somewhat more convincing test case for unqualified lookup throughJohn McCall2009-11-101-1/+2
| | | | | | | | | using directives, and fix a bug thereby exposed: since we're playing tricks with pointers, we need to make certain we're always using the same pointers for things. Also tweak an existing error message. llvm-svn: 86679
* Fix unqualified lookup through using directives.John McCall2009-11-101-83/+168
| | | | | | This is a pretty minimal test case; I'll make a better one later. llvm-svn: 86669
* Ignore dependent bases in ADL. Fixes PR5271.Sebastian Redl2009-10-251-0/+8
| | | | llvm-svn: 85054
* Apply the special enum restrictions from [over.match.oper]p3b2 in ↵Sebastian Redl2009-10-231-2/+12
| | | | | | argument-dependent lookup too. This fixes PR5244. llvm-svn: 84963
* Qualified lookup through using declarations. Diagnose a new type of ambiguity.John McCall2009-10-101-33/+194
| | | | | | | Split the various ambiguous result enumerators into their own enum. Tests for most of C++ [namespace.qual]. llvm-svn: 83700
* Dead Code EliminationDouglas Gregor2009-10-091-20/+0
| | | | llvm-svn: 83686
* Refactor the LookupResult API to simplify most common operations. Require ↵John McCall2009-10-091-545/+226
| | | | | | | | | users to pass a LookupResult reference to lookup routines. Call out uses which assume a single result. llvm-svn: 83674
* Dead code elimination.John McCall2009-10-071-20/+1
| | | | llvm-svn: 83492
* Refactor the code that walks a C++ inheritance hierarchy, searchingDouglas Gregor2009-10-061-14/+39
| | | | | | | | | for bases, members, overridden virtual methods, etc. The operations isDerivedFrom and lookupInBases are now provided by CXXRecordDecl, rather than by Sema, so that CodeGen and other clients can use them directly. llvm-svn: 83396
* Change all the Type::getAsFoo() methods to specializations of Type::getAs().John McCall2009-09-211-6/+6
| | | | | | | | | | | Several of the existing methods were identical to their respective specializations, and so have been removed entirely. Several more 'leaf' optimizations were introduced. The getAsFoo() methods which imposed extra conditions, like getAsObjCInterfacePointerType(), have been left in place. llvm-svn: 82501
* When performing name lookup within a class template or class templateDouglas Gregor2009-09-111-3/+2
| | | | | | | partial specialization, make sure we look into non-dependent base classes (but not dependent base classes). Fixes PR4951. llvm-svn: 81584
* When performing unqualified name lookup into a DeclContext, also look intoDouglas Gregor2009-09-101-20/+22
| | | | | | | | all of the parent DeclContexts that aren't represented within the Scope chain. This fixes some name-lookup problems in out-of-line definitions of members of nested classes. llvm-svn: 81451
* Remove tabs, and whitespace cleanups.Mike Stump2009-09-091-128/+128
| | | | llvm-svn: 81346
* Rewrite of our handling of name lookup in C++ member access expressions, e.g.,Douglas Gregor2009-09-021-23/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | x->Base::f We no longer try to "enter" the context of the type that "x" points to. Instead, we drag that object type through the parser and pass it into the Sema routines that need to know how to perform lookup within member access expressions. We now implement most of the crazy name lookup rules in C++ [basic.lookup.classref] for non-templated code, including performing lookup both in the context of the type referred to by the member access and in the scope of the member access itself and then detecting ambiguities when the two lookups collide (p1 and p4; p3 and p7 are still TODO). This change also corrects our handling of name lookup within template arguments of template-ids inside the nested-name-specifier (p6; we used to look into the scope of the object expression for them) and fixes PR4703. I have disabled some tests that involve member access expressions where the object expression has dependent type, because we don't yet have the ability to describe dependent nested-name-specifiers starting with an identifier. llvm-svn: 80843
* Omnibus friend decl refactoring. Instead of cloning AST classes for friendJohn McCall2009-08-281-3/+10
| | | | | | | | | | | | | | declarations of same, introduce a single AST class and add appropriate bits (encoded in the namespace) for whether a decl is "real" or not. Much hackery about previously-declared / not-previously-declared, but it's essentially mandated by the standard that friends alter lookup, and this is at least fairly non-intrusive. Refactor the Sema methods specific to friends for cleaner flow and less nesting. Incidentally solve a few bugs, but I remain confident that we can put them back. llvm-svn: 80353
* Improve support for out-of-line definitions of nested templates andDouglas Gregor2009-08-251-33/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | their members, including member class template, member function templates, and member classes and functions of member templates. To actually parse the nested-name-specifiers that qualify the name of an out-of-line definition of a member template, e.g., template<typename X> template<typename Y> X Outer<X>::Inner1<Y>::foo(Y) { return X(); } we need to look for the template names (e.g., "Inner1") as a member of the current instantiation (Outer<X>), even before we have entered the scope of the current instantiation. Since we can't do this in general (i.e., we should not be looking into all dependent nested-name-specifiers as if they were the current instantiation), we rely on the parser to tell us when it is parsing a declaration specifier sequence, and, therefore, when we should consider the current scope specifier to be a current instantiation. Printing of complicated, dependent nested-name-specifiers may be somewhat broken by this commit; I'll add tests for this issue and fix the problem (if it still exists) in a subsequent commit. llvm-svn: 80044
* Skip transparent contexts when performing C++ name lookupDouglas Gregor2009-08-241-0/+3
| | | | llvm-svn: 79931
* Argument-dependent lookup for friend declarations. Add a new decl type,John McCall2009-08-111-20/+9
| | | | | | | | | | | | FriendFunctionDecl, and create instances as appropriate. The design of FriendFunctionDecl is still somewhat up in the air; you can befriend arbitrary types of functions --- methods, constructors, etc. --- and it's not clear that this representation captures that very well. We'll have a better picture when we start consuming this data in access control. llvm-svn: 78653
* Just add global scope to the associated namespaces set instead of tracking itJohn McCall2009-08-071-74/+62
| | | | | | | separately. Add the framework (currently unfed) for finding friend declarations during argument-dependent lookup. llvm-svn: 78414
* First pass at friend semantics.John McCall2009-08-061-0/+20
| | | | llvm-svn: 78274
* Get rid of "smart" quotes. Per report on cfe-dev.Eli Friedman2009-08-051-5/+5
| | | | llvm-svn: 78230
* Change uses of:Ted Kremenek2009-07-291-5/+5
| | | | | | | | | | | | | | | | | | | | Type::getAsReferenceType() -> Type::getAs<ReferenceType>() Type::getAsRecordType() -> Type::getAs<RecordType>() Type::getAsPointerType() -> Type::getAs<PointerType>() Type::getAsBlockPointerType() -> Type::getAs<BlockPointerType>() Type::getAsLValueReferenceType() -> Type::getAs<LValueReferenceType>() Type::getAsRValueReferenceType() -> Type::getAs<RValueReferenceType>() Type::getAsMemberPointerType() -> Type::getAs<MemberPointerType>() Type::getAsReferenceType() -> Type::getAs<ReferenceType>() Type::getAsTagType() -> Type::getAs<TagType>() And remove Type::getAsReferenceType(), etc. This change is similar to one I made a couple weeks ago, but that was partly reverted pending some additional design discussion. With Doug's pending smart pointer changes for Types, it seemed natural to take this approach. llvm-svn: 77510
* [llvm up]Douglas Gregor2009-07-291-2/+1
| | | | | | | | | A template name can refer to a set of overloaded function templates. Model this in TemplateName, which can now refer to an OverloadedFunctionDecl that contains function templates. This removes an unspeakable hack in Sema::isTemplateName. llvm-svn: 77488
* Remove Sema::LookupObjCImplementation and replace it with just calling ↵Argyrios Kyrtzidis2009-07-211-7/+0
| | | | | | ObjCInterfaceDecl::getImplementation(). llvm-svn: 76509
* Remove ASTContext::getCanonicalDecl() and use Decl::getCanonicalDecl in its ↵Argyrios Kyrtzidis2009-07-181-1/+1
| | | | | | place. llvm-svn: 76274
* Per offline discussion with Steve Naroff, add back Type::getAsXXXType() methodsTed Kremenek2009-07-171-5/+5
| | | | | | | | | until Doug Gregor's Type smart pointer code lands (or more discussion occurs). These methods just call the new Type::getAs<XXX> methods, so we still have reduced implementation redundancy. Having explicit getAsXXXType() methods makes it easier to set breakpoints in the debugger. llvm-svn: 76193
* Replaced Type::getAsLValueReferenceType(), Type::getAsRValueReferenceType(), ↵Ted Kremenek2009-07-171-4/+4
| | | | | | Type::getAsMemberPointerType(), Type::getAsTagType(), and Type::getAsRecordType() with their Type::getAs<XXX> equivalents. llvm-svn: 76139
* Add member template 'Type::getAs<T>', which converts a Type* to a respective T*.Ted Kremenek2009-07-161-1/+1
| | | | | | | | | | | | | | | | | | | | | This method is intended to eventually replace the individual Type::getAsXXXType<> methods. The motivation behind this change is twofold: 1) Reduce redundant implementations of Type::getAsXXXType() methods. Most of them are basically copy-and-paste. 2) By centralizing the implementation of the getAs<Type> logic we can more smoothly move over to Doug Gregor's proposed canonical type smart pointer scheme. Along with this patch: a) Removed 'Type::getAsPointerType()'; now clients use getAs<PointerType>. b) Removed 'Type::getAsBlockPointerTypE()'; now clients use getAs<BlockPointerType>. llvm-svn: 76098
* Fix a corner case with argument-dependent lookup and overloaded function sets.Douglas Gregor2009-07-081-9/+16
| | | | llvm-svn: 74999
* Improve argument-dependent lookup to find associated classes andDouglas Gregor2009-07-081-3/+102
| | | | | | | namespaces based on the template arguments of a class template specialization type. llvm-svn: 74993
* De-ASTContext-ify DeclContext.Argyrios Kyrtzidis2009-06-301-6/+6
| | | | | | | Remove ASTContext parameter from DeclContext's methods. This change cascaded down to other Decl's methods and changes to call sites started "escalating". Timings using pre-tokenized "cocoa.h" showed only a ~1% increase in time run between and after this commit. llvm-svn: 74506
* Remove the ASTContext parameter from the attribute-related methods of Decl.Argyrios Kyrtzidis2009-06-301-1/+1
| | | | | | | | | The implementations of these methods can Use Decl::getASTContext() to get the ASTContext. This commit touches a lot of files since call sites for these methods are everywhere. I used pre-tokenized "carbon.h" and "cocoa.h" headers to do some timings, and there was no real time difference between before the commit and after it. llvm-svn: 74501
* Improve support for overloaded operator templates.Douglas Gregor2009-06-271-11/+17
| | | | llvm-svn: 74390
* Add NamedDecl::getUnderlyingDecl that can see through UsingDecl and ↵Anders Carlsson2009-06-261-29/+12
| | | | | | ObjCCompatibleAliasDecl. llvm-svn: 74279
* See through UsingDecls in more places.Anders Carlsson2009-06-261-6/+14
| | | | llvm-svn: 74269
* Fix failing test.Anders Carlsson2009-06-261-1/+3
| | | | llvm-svn: 74268
OpenPOWER on IntegriCloud