summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaLookup.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Fix another assert related to using decls.Anders Carlsson2009-06-261-0/+3
| | | | llvm-svn: 74262
* When creating LookupResults, see through UsingDecls. Fixes PR4450.Anders Carlsson2009-06-261-2/+6
| | | | llvm-svn: 74258
* Improved semantic analysis and AST respresentation for functionDouglas Gregor2009-06-251-11/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | templates. For example, this now type-checks (but does not instantiate the body of deref<int>): template<typename T> T& deref(T* t) { return *t; } void test(int *ip) { int &ir = deref(ip); } Specific changes/additions: * Template argument deduction from a call to a function template. * Instantiation of a function template specializations (just the declarations) from the template arguments deduced from a call. * FunctionTemplateDecls are stored directly in declaration contexts and found via name lookup (all forms), rather than finding the FunctionDecl and then realizing it is a template. This is responsible for most of the churn, since some of the core declaration matching and lookup code assumes that all functions are FunctionDecls. llvm-svn: 74213
* Make sure that argument-dependent lookup looks into the global scopeDouglas Gregor2009-06-231-13/+45
| | | | | | when it should. llvm-svn: 73992
* Parsing and AST support for using declarations, from John Thompson!Douglas Gregor2009-06-201-2/+4
| | | | llvm-svn: 73812
* Move the static DeclAttrs map into ASTContext. Fixes <rdar://problem/6983177>.Douglas Gregor2009-06-181-1/+1
| | | | llvm-svn: 73702
* Diagnose class members that shadow a template parameter. FixesDouglas Gregor2009-06-171-2/+2
| | | | | | | | | | <rdar://problem/6952203>. To do this, we actually remove a not-quite-correct optimization in the C++ name lookup routines. We'll revisit this optimization for the general case once more C++ is working. llvm-svn: 73659
* Sink the BuiltinInfo object from ASTContext into theChris Lattner2009-06-141-0/+1
| | | | | | | | preprocessor and initialize it early in clang-cc. This ensures that __has_builtin works in all modes, not just when ASTContext is around. llvm-svn: 73319
* Improve name lookup for and template instantiation of declarationDouglas Gregor2009-05-271-1/+2
| | | | | | | | | | | | | | | | | | | | | | | references. There are several smallish fixes here: - Make sure we look through template parameter scope when determining whether we're parsing a nested class (or nested class *template*). This makes sure that we delay parsing the bodies of inline member functions until after we're out of the outermost class (template) scope. - Since the bodies of member functions are always parsed "out-of-line", even when they were declared in-line, teach unqualified name lookup to look into the (semantic) parents. - Use the new InstantiateDeclRef to handle the instantiation of a reference to a declaration (in DeclRefExpr), which drastically simplifies template instantiation for DeclRefExprs. - When we're instantiating a ParmVarDecl, it must be in the current instantiation scope, so only look there. Also, remove the #if 0's and FIXME's from the dynarray example, which now compiles and executes thanks to Anders and Eli. llvm-svn: 72481
* Fix sorting of using directives, from Jay FoadDouglas Gregor2009-05-181-1/+1
| | | | llvm-svn: 72048
* Reflow some comments.Mike Stump2009-05-161-13/+11
| | | | llvm-svn: 71936
* Implement the notions of the "current instantiation" and "unknownDouglas Gregor2009-05-111-6/+29
| | | | | | | | | | | | | | | | | | specialization" within a C++ template, and permit name lookup into the current instantiation. For example, given: template<typename T, typename U> struct X { typedef T type; X* x1; // current instantiation X<T, U> *x2; // current instantiation X<U, T> *x3; // not current instantiation ::X<type, U> *x4; // current instantiation X<typename X<type, U>::type, U>: *x5; // current instantiation }; llvm-svn: 71471
* Eliminate Sema::ObjCAliasDecls. This is based on Steve's fix, but alsoDouglas Gregor2009-04-241-12/+16
| | | | | | | updates name lookup so that we see through @compatibility_alias declarations to their underlying interfaces. llvm-svn: 69950
* Eliminate Sema::ObjCInterfaceDeclsDouglas Gregor2009-04-241-3/+0
| | | | llvm-svn: 69942
* Eliminate Sema::ObjCImplementations, relying instead on name lookup. What's ↵Douglas Gregor2009-04-241-5/+35
| | | | | | | | | | | good for uniformity is good for PCH (or is it the other way around?). As part of this, make ObjCImplDecl inherit from NamedDecl (since ObjCImplementationDecls now need to have names so that they can be found). This brings ObjCImplDecl very, very close to ObjCContainerDecl; we may be able to merge them soon. llvm-svn: 69941
* Eliminate Sema::ObjCProtocols. Instead, we place ObjCProtocolDecls inDouglas Gregor2009-04-231-0/+14
| | | | | | | | | | | | their own namespace (IDNS_Protocol) and use the normal name-lookup routines to find them. Aside from the simplification this provides (one less DenseMap!), it means that protocols will be lazily deserialized from PCH files. Make the code size of the selector table block match the code size of the type and decl blocks. llvm-svn: 69939
* Lazy deserialization of the declaration chains associated withDouglas Gregor2009-04-211-11/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | identifiers from a precompiled header. This patch changes the primary name lookup method for entities within a precompiled header. Previously, we would load all of the names of declarations at translation unit scope into a large DenseMap (inside the TranslationUnitDecl's DeclContext), and then perform a special "last resort" lookup into this DeclContext when we knew there was a PCH file (see Sema::LookupName). Now, when we see an identifier named for the first time, we load all of the declarations with that name that are visible from the translation unit into the IdentifierInfo's chain of declarations. Thus, the explicit "look into the translation unit's DeclContext" code is gone, and Sema effectively uses the same IdentifierInfo-based name lookup mechanism whether we are using a PCH file or not. This approach should help PCH scale with the size of the input program rather than the size of the PCH file. The "Hello, World!" application with Carbon.h as a PCH file now loads 20% of the identifiers in the PCH file rather than 85% of the identifiers. 90% of the 20% of identifiers loaded are actually loaded when we deserialize the preprocessor state. The next step is to make the preprocessor load macros lazily, which should drastically reduce the number of types, declarations, and identifiers loaded for "Hello, World". llvm-svn: 69737
* Implementation of pre-compiled headers (PCH) based on lazyDouglas Gregor2009-04-091-0/+11
| | | | | | | | | | | | | | | | | | | de-serialization of abstract syntax trees. PCH support serializes the contents of the abstract syntax tree (AST) to a bitstream. When the PCH file is read, declarations are serialized as-needed. For example, a declaration of a variable "x" will be deserialized only when its VarDecl can be found by a client, e.g., based on name lookup for "x" or traversing the entire contents of the owner of "x". This commit provides the framework for serialization and (lazy) deserialization, along with support for variable and typedef declarations (along with several kinds of types). More declarations/types, along with important auxiliary structures (source manager, preprocessor, etc.), will follow. llvm-svn: 68732
OpenPOWER on IntegriCloud