summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaLookup.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Add basic, hackish support for instantiation of typedefs in a classDouglas Gregor2009-03-111-1/+1
| | | | | | | | | template. More importantly, start to sort out the issues regarding complete types and nested-name-specifiers, especially the question of: when do we instantiate a class template specialization that occurs to the left of a '::' in a nested-name-specifier? llvm-svn: 66662
* Eliminate CXXRecordTypeDouglas Gregor2009-02-281-7/+8
| | | | llvm-svn: 65671
* Create a new TypeNodes.def file that enumerates all of the types,Douglas Gregor2009-02-261-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | giving them rough classifications (normal types, never-canonical types, always-dependent types, abstract type representations) and making it far easier to make sure that we've hit all of the cases when decoding types. Switched some switch() statements on the type class over to using this mechanism, and filtering out those things we don't care about. For example, CodeGen should never see always-dependent or non-canonical types, while debug info generation should never see always-dependent types. More switch() statements on the type class need to be moved over to using this approach, so that we'll get warnings when we add a new type then fail to account for it somewhere in the compiler. As part of this, some types have been renamed: TypeOfExpr -> TypeOfExprType FunctionTypeProto -> FunctionProtoType FunctionTypeNoProto -> FunctionNoProtoType There shouldn't be any functionality change... llvm-svn: 65591
* When we're declaring an object or function with linkage, teach nameDouglas Gregor2009-02-241-1/+27
| | | | | | | lookup to skip over names without linkage. This finishes <rdar://problem/6127293>. llvm-svn: 65386
* Implicitly declare certain C library functions (malloc, strcpy, memmove,Douglas Gregor2009-02-131-14/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | etc.) when we perform name lookup on them. This ensures that we produce the correct signature for these functions, which has two practical impacts: 1) When we're supporting the "implicit function declaration" feature of C99, these functions will be implicitly declared with the right signature rather than as a function returning "int" with no prototype. See PR3541 for the reason why this is important (hint: GCC always predeclares these functions). 2) If users attempt to redeclare one of these library functions with an incompatible signature, we produce a hard error. This patch does a little bit of work to give reasonable error messages. For example, when we hit case #1 we complain that we're implicitly declaring this function with a specific signature, and then we give a note that asks the user to include the appropriate header (e.g., "please include <stdlib.h> or explicitly declare 'malloc'"). In case #2, we show the type of the implicit builtin that was incorrectly declared, so the user can see the problem. We could do better here: for example, when displaying this latter error message we say something like: 'strcpy' was implicitly declared here with type 'char *(char *, char const *)' but we should really print out a fake code line showing the declaration, like this: 'strcpy' was implicitly declared here as: char *strcpy(char *, char const *) This would also be good for printing built-in candidates with C++ operator overloading. The set of C library functions supported by this patch includes all functions from the C99 specification's <stdlib.h> and <string.h> that (a) are predefined by GCC and (b) have signatures that could cause codegen issues if they are treated as functions with no prototype returning and int. Future work could extend this set of functions to other C library functions that we know about. llvm-svn: 64504
* Initial implementation of function overloading in C.Douglas Gregor2009-02-111-1/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds a new attribute, "overloadable", that enables C++ function overloading in C. The attribute can only be added to function declarations, e.g., int *f(int) __attribute__((overloadable)); If the "overloadable" attribute exists on a function with a given name, *all* functions with that name (and in that scope) must have the "overloadable" attribute. Sets of overloaded functions with the "overloadable" attribute then follow the normal C++ rules for overloaded functions, e.g., overloads must have different parameter-type-lists from each other. When calling an overloaded function in C, we follow the same overloading rules as C++, with three extensions to the set of standard conversions: - A value of a given struct or union type T can be converted to the type T. This is just the identity conversion. (In C++, this would go through a copy constructor). - A value of pointer type T* can be converted to a value of type U* if T and U are compatible types. This conversion has Conversion rank (it's considered a pointer conversion in C). - A value of type T can be converted to a value of type U if T and U are compatible (and are not both pointer types). This conversion has Conversion rank (it's considered to be a new kind of conversion unique to C, a "compatible" conversion). Known defects (and, therefore, next steps): 1) The standard-conversion handling does not understand conversions involving _Complex or vector extensions, so it is likely to get these wrong. We need to add these conversions. 2) All overloadable functions with the same name will have the same linkage name, which means we'll get a collision in the linker (if not sooner). We'll need to mangle the names of these functions. llvm-svn: 64336
* Implement dereferencing of pointers-to-member.Sebastian Redl2009-02-071-3/+3
| | | | llvm-svn: 63983
* Improvements and fixes for name lookup with using directives, from Piotr Rak!Douglas Gregor2009-02-051-202/+181
| | | | | | | | Also, put Objective-C protocols into their own identifier namespace. Otherwise, we find protocols when we don't want to in C++ (but not in C). llvm-svn: 63877
* Basic representation of C++ class templates, from Andrew Sutton.Douglas Gregor2009-02-041-1/+1
| | | | llvm-svn: 63750
* Some name-lookup-related fixes, from Piotr Rak!Douglas Gregor2009-02-041-106/+45
| | | | | | | | | | | | | - Changes Lookup*Name functions to return NamedDecls, instead of Decls. Unfortunately my recent statement that it will simplify lot of code, was not quite right, but it simplifies some... - Makes MergeLookupResult SmallPtrSet instead of vector, following Douglas suggestions. - Adds %qN format for printing qualified names to Diagnostic. - Avoids searching for using-directives in Scopes, which are not DeclScope, during unqualified name lookup. llvm-svn: 63739
* Bring operator name lookup (as required for C++ operator overloading)Douglas Gregor2009-02-041-1/+4
| | | | | | | into the general name-lookup fold. This cleans up some ugly, not-quite-working code in the handling of operator overloading. llvm-svn: 63735
* Initial implementation of argument dependent lookup (a.k.a. ADL,Douglas Gregor2009-02-041-0/+261
| | | | | | | | | | | | a.k.a. Koenig lookup) in C++. Most of the pieces are in place, but for two: - In an unqualified call g(x), even if the name does not refer to anything in the current scope, we can still find functions named "g" based on ADL. We don't yet have this ability. - ADL will need updating for friend functions and templates. llvm-svn: 63692
* silence some warnings.Chris Lattner2009-02-031-2/+2
| | | | llvm-svn: 63662
* Semantic analysis, ASTs, and unqualified name lookup support for C++Douglas Gregor2009-02-031-120/+596
| | | | | | using directives, from Piotr Rak! llvm-svn: 63646
* Add iterators to LookupResult, allowing one to iterate over theDouglas Gregor2009-02-021-0/+60
| | | | | | | non-ambiguous name lookup results without allocating any memory, e.g., for sets of overloaded functions. llvm-svn: 63549
* Eliminated LookupCriteria, whose creation was causing a bottleneck forDouglas Gregor2009-01-301-105/+91
| | | | | | | | | | | | | | | | | | LookupName et al. Instead, use an enum and a bool to describe its contents. Optimized the C/Objective-C path through LookupName, eliminating any unnecessarily C++isms. Simplify IdentifierResolver::iterator, removing some code and arguments that are no longer used. Eliminated LookupDeclInScope/LookupDeclInContext, moving all callers over to LookupName, LookupQualifiedName, or LookupParsedName, as appropriate. All together, I'm seeing a 0.2% speedup on Cocoa.h with PTH and -disable-free. Plus, we're down to three name-lookup routines. llvm-svn: 63354
* Remove ScopedDecl, collapsing all of its functionality into Decl, soDouglas Gregor2009-01-201-5/+4
| | | | | | | | | | | | | | | | that every declaration lives inside a DeclContext. Moved several things that don't have names but were ScopedDecls (and, therefore, NamedDecls) to inherit from Decl rather than NamedDecl, including ObjCImplementationDecl and LinkageSpecDecl. Now, we don't store empty DeclarationNames for these things, nor do we try to insert them into DeclContext's lookup structure. The serialization tests are temporarily disabled. We'll re-enable them once we've sorted out the remaining ownership/serialiazation issues between DeclContexts and TranslationUnion, DeclGroups, etc. llvm-svn: 62562
* PODify LookupResult, for a measly 1% speedup on Cocoa.h.Douglas Gregor2009-01-171-72/+49
| | | | llvm-svn: 62391
* Teach DeclContext how to find the primary declaration for any TagDeclDouglas Gregor2009-01-171-0/+1
| | | | | | | | | | | | | even when we are still defining the TagDecl. This is required so that qualified name lookup of a class name within its definition works (see the new bits in test/SemaCXX/qualified-id-lookup.cpp). As part of this, move the nested redefinition checking code into ActOnTag. This gives us diagnostics earlier (when we try to perform the nested redefinition, rather than when we try to complete the 2nd definition) and removes some code duplication. llvm-svn: 62386
* Improve diagnostics for ambiguous name lookup resultsDouglas Gregor2009-01-161-5/+21
| | | | llvm-svn: 62287
* Fix some unused variable, control reaches end of non-void function,Daniel Dunbar2009-01-151-1/+1
| | | | | | and uninitialized use options. llvm-svn: 62270
* Deallocate the BasePaths structure that we allocate for LookupResult.Douglas Gregor2009-01-151-0/+35
| | | | llvm-svn: 62250
* Initial implementation of member name lookupDouglas Gregor2009-01-151-5/+178
| | | | llvm-svn: 62247
* Refactor name lookup.Douglas Gregor2009-01-141-0/+422
This change refactors and cleans up our handling of name lookup with LookupDecl. There are several aspects to this refactoring: - The criteria for name lookup is now encapsulated into the class LookupCriteria, which replaces the hideous set of boolean values that LookupDecl currently has. - The results of name lookup are returned in a new class LookupResult, which can lazily build OverloadedFunctionDecls for overloaded function sets (and, eventually, eliminate the need to allocate member for OverloadedFunctionDecls) and contains a placeholder for handling ambiguous name lookup (for C++). - The primary entry points for name lookup are now LookupName (for unqualified name lookup) and LookupQualifiedName (for qualified name lookup). There is also a convenience function LookupParsedName that handles qualified/unqualified name lookup when given a scope specifier. Together, these routines are meant to gradually replace the kludgy LookupDecl, but this won't happen until after we have base class lookup (which forces us to cope with ambiguities). - Documented the heck out of name lookup. Experimenting a little with using Doxygen's member groups to make some sense of the Sema class. Feedback welcome! - Fixes some lingering issues with name lookup for nested-name-specifiers, which now goes through LookupName/LookupQualifiedName. llvm-svn: 62245
OpenPOWER on IntegriCloud