[cfe-commits] r69950 - in /cfe/trunk/lib/Sema: Sema.h SemaDecl.cpp SemaDeclObjC.cpp SemaLookup.cpp
Douglas Gregor
dgregor at apple.com
Thu Apr 23 19:57:34 PDT 2009
Author: dgregor
Date: Thu Apr 23 21:57:34 2009
New Revision: 69950
URL: http://llvm.org/viewvc/llvm-project?rev=69950&view=rev
Log:
Eliminate Sema::ObjCAliasDecls. This is based on Steve's fix, but also
updates name lookup so that we see through @compatibility_alias
declarations to their underlying interfaces.
Modified:
cfe/trunk/lib/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
Modified: cfe/trunk/lib/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/Sema.h?rev=69950&r1=69949&r2=69950&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/Sema.h (original)
+++ cfe/trunk/lib/Sema/Sema.h Thu Apr 23 21:57:34 2009
@@ -172,14 +172,6 @@
/// we can check for duplicates and find local method declarations.
llvm::SmallVector<ObjCCategoryImplDecl*, 8> ObjCCategoryImpls;
- /// ObjCAliasDecls - Keep track of all class declarations declared
- /// with @compatibility_alias, so that we can emit errors on duplicates and
- /// find the declarations when needed. This construct is ancient and will
- /// likely never be seen. Nevertheless, it is here for compatibility.
- typedef llvm::DenseMap<const IdentifierInfo*,
- ObjCCompatibleAliasDecl*> ObjCAliasTy;
- ObjCAliasTy ObjCAliasDecls;
-
/// FieldCollector - Collects CXXFieldDecls during parsing of C++ classes.
llvm::OwningPtr<CXXFieldCollector> FieldCollector;
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=69950&r1=69949&r2=69950&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu Apr 23 21:57:34 2009
@@ -299,6 +299,18 @@
S->RemoveDecl(DeclPtrTy::make(*Redecl));
IdResolver.RemoveDecl(*Redecl);
}
+ } else if (isa<ObjCInterfaceDecl>(D)) {
+ // We're pushing an Objective-C interface into the current
+ // context. If there is already an alias declaration, remove it first.
+ for (IdentifierResolver::iterator
+ I = IdResolver.begin(D->getDeclName()), IEnd = IdResolver.end();
+ I != IEnd; ++I) {
+ if (isa<ObjCCompatibleAliasDecl>(*I)) {
+ S->RemoveDecl(DeclPtrTy::make(*I));
+ IdResolver.RemoveDecl(*I);
+ break;
+ }
+ }
}
IdResolver.AddDecl(D);
Modified: cfe/trunk/lib/Sema/SemaDeclObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclObjC.cpp?rev=69950&r1=69949&r2=69950&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclObjC.cpp Thu Apr 23 21:57:34 2009
@@ -201,12 +201,8 @@
ObjCCompatibleAliasDecl *AliasDecl =
ObjCCompatibleAliasDecl::Create(Context, CurContext, AtLoc, AliasName, CDecl);
- ObjCAliasDecls[AliasName] = AliasDecl;
-
- // FIXME: PushOnScopeChains?
- CurContext->addDecl(Context, AliasDecl);
if (!CheckObjCDeclScope(AliasDecl))
- TUScope->AddDecl(DeclPtrTy::make(AliasDecl));
+ PushOnScopeChains(AliasDecl, TUScope);
return DeclPtrTy::make(AliasDecl);
}
Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=69950&r1=69949&r2=69950&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
+++ cfe/trunk/lib/Sema/SemaLookup.cpp Thu Apr 23 21:57:34 2009
@@ -311,6 +311,10 @@
Sema::LookupResult
Sema::LookupResult::CreateLookupResult(ASTContext &Context, NamedDecl *D) {
+ if (ObjCCompatibleAliasDecl *Alias
+ = dyn_cast_or_null<ObjCCompatibleAliasDecl>(D))
+ D = Alias->getClassInterface();
+
LookupResult Result;
Result.StoredKind = (D && isa<OverloadedFunctionDecl>(D))?
OverloadedDeclSingleDecl : SingleDecl;
@@ -338,9 +342,14 @@
return Result;
}
}
+
+ Decl *D = *F;
+ if (ObjCCompatibleAliasDecl *Alias
+ = dyn_cast_or_null<ObjCCompatibleAliasDecl>(D))
+ D = Alias->getClassInterface();
Result.StoredKind = SingleDecl;
- Result.First = reinterpret_cast<uintptr_t>(*F);
+ Result.First = reinterpret_cast<uintptr_t>(D);
Result.Last = 0;
return Result;
}
@@ -362,9 +371,14 @@
return Result;
}
}
+
+ Decl *D = *F;
+ if (ObjCCompatibleAliasDecl *Alias
+ = dyn_cast_or_null<ObjCCompatibleAliasDecl>(D))
+ D = Alias->getClassInterface();
Result.StoredKind = SingleDecl;
- Result.First = reinterpret_cast<uintptr_t>(*F);
+ Result.First = reinterpret_cast<uintptr_t>(D);
Result.Last = 0;
return Result;
}
@@ -930,16 +944,6 @@
S, RedeclarationOnly, Loc));
}
}
- if (getLangOptions().ObjC1 && II) {
- // @interface and @compatibility_alias introduce typedef-like names.
- // 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.
- ObjCAliasTy::iterator I = ObjCAliasDecls.find(II);
- if (I != ObjCAliasDecls.end())
- return LookupResult::CreateLookupResult(Context,
- I->second->getClassInterface());
- }
}
return LookupResult::CreateLookupResult(Context, 0);
}
More information about the cfe-commits
mailing list