summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2008-04-02 18:30:49 +0000
committerSteve Naroff <snaroff@apple.com>2008-04-02 18:30:49 +0000
commit778927532d9624a5dd7c7b552f949d3d61aa3729 (patch)
tree5d7845053b0b32874a77389790ee48fded19b4c2 /clang/lib/Sema/SemaDecl.cpp
parent586740f4011e0c2015cdfbb2c25ee13caca24bb8 (diff)
downloadbcm5719-llvm-778927532d9624a5dd7c7b552f949d3d61aa3729.tar.gz
bcm5719-llvm-778927532d9624a5dd7c7b552f949d3d61aa3729.zip
Change ObjCInterfaceDecl to inherit from NamedDecl (not TypeDecl). While ObjCInterfaceDecl is arguably a TypeDecl, it isn't a ScopedDecl. Since TypeDecl's are scoped, it makes sense to simply treat them as NamedDecl's. I could have fiddled a bit more with the hierarchy (in terms of creating a non-scoped TypeDecl), however this probably isn't worth the effort.
I also finished unifying access to scope decl change by converting Sema::getObjCInterfaceDecl() to use Sema::LookupDecl(). This is much cleaner now:-) llvm-svn: 49107
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index c5901f0b913..c9ea54fa0e9 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -86,19 +86,11 @@ void Sema::ActOnPopScope(SourceLocation Loc, Scope *S) {
/// getObjCInterfaceDecl - Look up a for a class declaration in the scope.
/// return 0 if one not found.
-/// FIXME: removed this when ObjCInterfaceDecl's aren't ScopedDecl's.
ObjCInterfaceDecl *Sema::getObjCInterfaceDecl(IdentifierInfo *Id) {
- ScopedDecl *IDecl;
- // Scan up the scope chain looking for a decl that matches this identifier
- // that is in the appropriate namespace.
- for (IDecl = Id->getFETokenInfo<ScopedDecl>(); IDecl;
- IDecl = IDecl->getNext())
- if (IDecl->getIdentifierNamespace() == Decl::IDNS_Ordinary)
- break;
-
- if (ObjCCompatibleAliasDecl *ADecl =
- dyn_cast_or_null<ObjCCompatibleAliasDecl>(IDecl))
- return ADecl->getClassInterface();
+ // The third "scope" argument is 0 since we aren't enabling lazy built-in
+ // creation from this context.
+ Decl *IDecl = LookupDecl(Id, Decl::IDNS_Ordinary, 0, false);
+
return dyn_cast_or_null<ObjCInterfaceDecl>(IDecl);
}
@@ -130,6 +122,9 @@ Decl *Sema::LookupDecl(const IdentifierInfo *II, unsigned NSI,
// Unlike typedef's, they can only be introduced at file-scope (and are
// therefore not scoped decls). They can, however, be shadowed by
// other names in IDNS_Ordinary.
+ ObjCInterfaceDeclsTy::iterator IDI = ObjCInterfaceDecls.find(II);
+ if (IDI != ObjCInterfaceDecls.end())
+ return IDI->second;
ObjCAliasTy::iterator I = ObjCAliasDecls.find(II);
if (I != ObjCAliasDecls.end())
return I->second->getClassInterface();
OpenPOWER on IntegriCloud