summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/IdentifierResolver.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Rework the way we find locally-scoped external declarations when weDouglas Gregor2009-03-021-0/+33
| | | | | | | | | | | need them to evaluate redeclarations or call a function that hasn't already been declared. We now keep a DenseMap of these locally-scoped declarations so that they are not visible but can be quickly found, e.g., when we're looking for previous declarations or before we go ahead and implicitly declare a function that's being called. Fixes PR3672. llvm-svn: 65792
* Now that ObjC decls have DeclContexts too, remove an ugly hack from ↵Argyrios Kyrtzidis2009-02-171-34/+1
| | | | | | IdentifierResolver. llvm-svn: 64802
* Eliminated LookupCriteria, whose creation was causing a bottleneck forDouglas Gregor2009-01-301-23/+3
| | | | | | | | | | | | | | | | | | 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-11/+2
| | | | | | | | | | | | | | | | 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
* Unify the code for defining tags in C and C++, so that we alwaysDouglas Gregor2009-01-081-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | introduce a Scope for the body of a tag. This reduces the number of semantic differences between C and C++ structs and unions, and will help with other features (e.g., anonymous unions) in C. Some important points: - Fields are now in the "member" namespace (IDNS_Member), to keep them separate from tags and ordinary names in C. See the new test in Sema/member-reference.c for an example of why this matters. In C++, ordinary and member name lookup will find members in both the ordinary and member namespace, so the difference between IDNS_Member and IDNS_Ordinary is erased by Sema::LookupDecl (but only in C++!). - We always introduce a Scope and push a DeclContext when we're defining a tag, in both C and C++. Previously, we had different actions and different Scope/CurContext behavior for enums, C structs/unions, and C++ structs/unions/classes. Now, it's one pair of actions. (Yay!) There's still some fuzziness in the handling of struct/union/enum definitions within other struct/union/enum definitions in C. We'll need to do some more cleanup to eliminate some reliance on CurContext before we can solve this issue for real. What we want is for something like this: struct X { struct T { int x; } t; }; to introduce T into translation unit scope (placing it at the appropriate point in the IdentifierResolver chain, too), but it should still have struct X as its lexical declaration context. PushOnScopeChains isn't smart enough to do that yet, though, so there's a FIXME test in nested-redef.c llvm-svn: 61940
* This is a large/messy diff that unifies the ObjC AST's with DeclContext.Steve Naroff2009-01-081-1/+1
| | | | | | | | | | | | | | | - ObjCContainerDecl's (ObjCInterfaceDecl/ObjCCategoryDecl/ObjCProtocolDecl), ObjCCategoryImpl, & ObjCImplementation are all DeclContexts. - ObjCMethodDecl is now a ScopedDecl (so it can play nicely with DeclContext). - ObjCContainerDecl now does iteration/lookup using DeclContext infrastructure (no more linear search:-) - Removed ASTContext argument to DeclContext::lookup(). It wasn't being used and complicated it's use from an ObjC AST perspective. - Added Sema::ProcessPropertyDecl() and removed Sema::diagnosePropertySetterGetterMismatch(). - Simplified Sema::ActOnAtEnd() considerably. Still more work to do. - Fixed an incorrect casting assumption in Sema::getCurFunctionOrMethodDecl(), now that ObjCMethodDecl is a ScopedDecl. - Removed addPropertyMethods from ObjCInterfaceDecl/ObjCCategoryDecl/ObjCProtocolDecl. This passes all the tests on my machine. Since many of the changes are central to the way ObjC finds it's methods, I expect some fallout (and there are still a handful of FIXME's). Nevertheless, this should be a step in the right direction. llvm-svn: 61929
* Allow Objective-C entities to be declared within a transparent contextDouglas Gregor2009-01-061-4/+2
| | | | | | nested in the translation unit. This fixes <rdar://problem/6476070>. llvm-svn: 61832
* Introduce support for "transparent" DeclContexts, which areDouglas Gregor2009-01-051-48/+13
| | | | | | | | | | | | | | | | | | | | | | DeclContexts whose members are visible from enclosing DeclContexts up to (and including) the innermost enclosing non-transparent DeclContexts. Transparent DeclContexts unify the mechanism to be used for various language features, including C enumerations, anonymous unions, C++0x inline namespaces, and C++ linkage specifications. Please refer to the documentation in the Clang internals manual for more information. Only enumerations and linkage specifications currently use transparent DeclContexts. Still to do: use transparent DeclContexts to implement anonymous unions and GCC's anonymous structs extension, and, later, the C++0x features. We also need to tighten up the DeclContext/ScopedDecl link to ensure that every ScopedDecl is in a single DeclContext, which will ensure that we can then enforce ownership and reduce the memory footprint of DeclContext. llvm-svn: 61735
* Parser support for C++ try-catch.Sebastian Redl2008-12-211-0/+4
| | | | llvm-svn: 61312
* Unifies the name-lookup mechanisms used in various parts of the ASTDouglas Gregor2008-12-111-5/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | and separates lexical name lookup from qualified name lookup. In particular: * Make DeclContext the central data structure for storing and looking up declarations within existing declarations, e.g., members of structs/unions/classes, enumerators in C++0x enums, members of C++ namespaces, and (later) members of Objective-C interfaces/implementations. DeclContext uses a lazily-constructed data structure optimized for fast lookup (array for small contexts, hash table for larger contexts). * Implement C++ qualified name lookup in terms of lookup into DeclContext. * Implement C++ unqualified name lookup in terms of qualified+unqualified name lookup (since unqualified lookup is not purely lexical in C++!) * Limit the use of the chains of declarations stored in IdentifierInfo to those names declared lexically. * Eliminate CXXFieldDecl, collapsing its behavior into FieldDecl. (FieldDecl is now a ScopedDecl). * Make RecordDecl into a DeclContext and eliminates its Members/NumMembers fields (since one can just iterate through the DeclContext to get the fields). llvm-svn: 60878
* Rename: FindContext -> FindDeclVisibleInContext.Zhongxing Xu2008-12-051-3/+4
| | | | llvm-svn: 60574
* Updated IdentifierResolver to deal with DeclarationNames. The names ofDouglas Gregor2008-11-171-26/+25
| | | | | | | | | | | | | | | | | | | | | C++ constructors, destructors, and conversion functions now have a FETokenInfo field that IdentifierResolver can access, so that these special names are handled just like ordinary identifiers. A few other Sema routines now use DeclarationNames instead of IdentifierInfo*'s. To validate this design, this code also implements parsing and semantic analysis for id-expressions that name conversion functions, e.g., return operator bool(); The new parser action ActOnConversionFunctionExpr takes the result of parsing "operator type-id" and turning it into an expression, using the IdentifierResolver with the DeclarationName of the conversion function. ActOnDeclarator pushes those conversion function names into scope so that the IdentifierResolver can find them, of course. llvm-svn: 59462
* Implement C++ 'typeid' parsing and sema.Sebastian Redl2008-11-111-1/+1
| | | | llvm-svn: 59042
* Preliminary support for function overloadingDouglas Gregor2008-10-211-1/+3
| | | | llvm-svn: 57909
* Make IdentifierResolver::isDeclInScope regard declarations of a parent ↵Argyrios Kyrtzidis2008-09-091-3/+21
| | | | | | | | | | | | | | | 'control' scope as part of the current scope. The 'control' scope is the 'condition' scope of if/switch/while statements and the scope that contains the for-init-statement and 'condition' of a for statement. e.g: if (int x = 0 /*'control' scope*/) { // x will be regarded as part of this substatement scope. } else { // and as part of this substatement scope too. } llvm-svn: 56020
* Add a LangOptions member to IdentifierResolver.Argyrios Kyrtzidis2008-09-091-1/+3
| | | | | | Make Sema pass the LangOptions to IdentifierResolver's constructor. llvm-svn: 56015
* IdentifierResolver cleanup. Make some methods out-of-line.Argyrios Kyrtzidis2008-09-091-0/+110
| | | | llvm-svn: 56002
* Unify ctx_iterator/ctx_begin()/ctx_end() and iterator/begin()/end() so that ↵Argyrios Kyrtzidis2008-07-171-33/+45
| | | | | | a single iterator type is used for both traversing decls of the same declaration context *and* of the parent declaration contexts, depending on the value of the bool parameter 'LookInParentCtx' that is passed to IdentifierResolver::begin(). llvm-svn: 53724
* Comments fix.Argyrios Kyrtzidis2008-05-151-1/+1
| | | | llvm-svn: 51151
* -Implement proper name lookup for namespaces.Argyrios Kyrtzidis2008-05-091-137/+68
| | | | | | | -identifierResolver exposes an iterator interface to get all decls through the scope chain. -The semantic staff (checking IdentifierNamespace and Doug's checking for shadowed tags were moved out of IdentifierResolver and back into Sema. IdentifierResolver just gives an iterator for all reachable decls of an identifier. llvm-svn: 50923
* Argiris Kirtzidis's fix for handling empty IdDeclInfo's in ↵Douglas Gregor2008-04-141-1/+1
| | | | | | IdentifierResolver::AddDecl llvm-svn: 49631
* Move IdDeclInfoMap class in an anonymous namespace. Suggestion by Chris Lattner.Argyrios Kyrtzidis2008-04-141-8/+12
| | | | llvm-svn: 49628
* Introduce support for finding class and enum names via ordinary name lookup ↵Douglas Gregor2008-04-131-4/+23
| | | | | | in C++ llvm-svn: 49621
* Use std::list's push_back instead of resize to add an element.Argyrios Kyrtzidis2008-04-121-2/+2
| | | | llvm-svn: 49582
* Fixed comments.Argyrios Kyrtzidis2008-04-121-27/+29
| | | | | | | Moved IdDeclInfo class to anonymous namespace. Replaced array with a std::vector. llvm-svn: 49570
* two new files for previous patch, by Argiris KirtzidisChris Lattner2008-04-111-0/+235
llvm-svn: 49521
OpenPOWER on IntegriCloud