Convert Selector Maps/Sets to use stronger typing (now that we have DenseMapInfo in IdentifierTable.h).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42767 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Steve Naroff 2007-10-08 21:05:34 +00:00
Родитель c049e4f406
Коммит eefc418b8e
3 изменённых файлов: 16 добавлений и 20 удалений

Просмотреть файл

@ -220,7 +220,7 @@ private:
/// Declared in protocol, and those referenced by it.
void CheckProtocolMethodDefs(ObjcProtocolDecl *PDecl,
bool& IncompleteImpl,
const llvm::DenseSet<void *>& InsMap,
const llvm::DenseSet<Selector> &InsMap,
const llvm::DenseSet<Selector> &ClsMap);
/// CheckImplementationIvars - This routine checks if the instance variables

Просмотреть файл

@ -1240,13 +1240,12 @@ void Sema::CheckImplementationIvars(ObjcImplementationDecl *ImpDecl,
/// Declared in protocol, and those referenced by it.
void Sema::CheckProtocolMethodDefs(ObjcProtocolDecl *PDecl,
bool& IncompleteImpl,
const llvm::DenseSet<void *>& InsMap,
const llvm::DenseSet<Selector> &InsMap,
const llvm::DenseSet<Selector> &ClsMap) {
// check unimplemented instance methods.
ObjcMethodDecl** methods = PDecl->getInstanceMethods();
for (int j = 0; j < PDecl->getNumInstanceMethods(); j++) {
void * cpv = methods[j]->getSelector().getAsOpaquePtr();
if (!InsMap.count(cpv)) {
if (!InsMap.count(methods[j]->getSelector())) {
Diag(methods[j]->getLocation(), diag::warn_undef_method_impl,
methods[j]->getSelector().getName());
IncompleteImpl = true;
@ -1269,17 +1268,17 @@ void Sema::CheckProtocolMethodDefs(ObjcProtocolDecl *PDecl,
void Sema::ImplMethodsVsClassMethods(ObjcImplementationDecl* IMPDecl,
ObjcInterfaceDecl* IDecl) {
llvm::DenseSet<void *> InsMap;
llvm::DenseSet<Selector> InsMap;
// Check and see if instance methods in class interface have been
// implemented in the implementation class.
ObjcMethodDecl **methods = IMPDecl->getInstanceMethods();
for (int i=0; i < IMPDecl->getNumInstanceMethods(); i++)
InsMap.insert(methods[i]->getSelector().getAsOpaquePtr());
InsMap.insert(methods[i]->getSelector());
bool IncompleteImpl = false;
methods = IDecl->getInstanceMethods();
for (int j = 0; j < IDecl->getNumInstanceMethods(); j++)
if (!InsMap.count(methods[j]->getSelector().getAsOpaquePtr())) {
if (!InsMap.count(methods[j]->getSelector())) {
Diag(methods[j]->getLocation(), diag::warn_undef_method_impl,
methods[j]->getSelector().getName());
IncompleteImpl = true;
@ -1314,17 +1313,17 @@ void Sema::ImplMethodsVsClassMethods(ObjcImplementationDecl* IMPDecl,
/// category interface is implemented in the category @implementation.
void Sema::ImplCategoryMethodsVsIntfMethods(ObjcCategoryImplDecl *CatImplDecl,
ObjcCategoryDecl *CatClassDecl) {
llvm::DenseSet<void *> InsMap;
llvm::DenseSet<Selector> InsMap;
// Check and see if instance methods in category interface have been
// implemented in its implementation class.
ObjcMethodDecl **methods = CatImplDecl->getInstanceMethods();
for (int i=0; i < CatImplDecl->getNumInstanceMethods(); i++)
InsMap.insert(methods[i]->getSelector().getAsOpaquePtr());
InsMap.insert(methods[i]->getSelector());
bool IncompleteImpl = false;
methods = CatClassDecl->getInstanceMethods();
for (int j = 0; j < CatClassDecl->getNumInstanceMethods(); j++)
if (!InsMap.count(methods[j]->getSelector().getAsOpaquePtr())) {
if (!InsMap.count(methods[j]->getSelector())) {
Diag(methods[j]->getLocation(), diag::warn_undef_method_impl,
methods[j]->getSelector().getName());
IncompleteImpl = true;
@ -1725,8 +1724,8 @@ void Sema::ActOnAddMethodsToObjcDecl(Scope* S, DeclTy *classDecl,
llvm::SmallVector<ObjcMethodDecl*, 32> insMethods;
llvm::SmallVector<ObjcMethodDecl*, 16> clsMethods;
llvm::DenseMap<void *, const ObjcMethodDecl*> InsMap;
llvm::DenseMap<void *, const ObjcMethodDecl*> ClsMap;
llvm::DenseMap<Selector, const ObjcMethodDecl*> InsMap;
llvm::DenseMap<Selector, const ObjcMethodDecl*> ClsMap;
bool isClassDeclaration =
(isa<ObjcInterfaceDecl>(ClassDecl) || isa<ObjcCategoryDecl>(ClassDecl));
@ -1738,8 +1737,7 @@ void Sema::ActOnAddMethodsToObjcDecl(Scope* S, DeclTy *classDecl,
if (Method->isInstance()) {
if (isClassDeclaration) {
/// Check for instance method of the same name with incompatible types
const ObjcMethodDecl *&PrevMethod =
InsMap[Method->getSelector().getAsOpaquePtr()];
const ObjcMethodDecl *&PrevMethod = InsMap[Method->getSelector()];
if (PrevMethod && !MatchTwoMethodDeclarations(Method, PrevMethod)) {
Diag(Method->getLocation(), diag::error_duplicate_method_decl,
Method->getSelector().getName());
@ -1747,7 +1745,7 @@ void Sema::ActOnAddMethodsToObjcDecl(Scope* S, DeclTy *classDecl,
}
else {
insMethods.push_back(Method);
InsMap[Method->getSelector().getAsOpaquePtr()] = Method;
InsMap[Method->getSelector()] = Method;
}
}
else
@ -1756,8 +1754,7 @@ void Sema::ActOnAddMethodsToObjcDecl(Scope* S, DeclTy *classDecl,
else {
if (isClassDeclaration) {
/// Check for class method of the same name with incompatible types
const ObjcMethodDecl *&PrevMethod =
ClsMap[Method->getSelector().getAsOpaquePtr()];
const ObjcMethodDecl *&PrevMethod = ClsMap[Method->getSelector()];
if (PrevMethod && !MatchTwoMethodDeclarations(Method, PrevMethod)) {
Diag(Method->getLocation(), diag::error_duplicate_method_decl,
Method->getSelector().getName());
@ -1765,7 +1762,7 @@ void Sema::ActOnAddMethodsToObjcDecl(Scope* S, DeclTy *classDecl,
}
else {
clsMethods.push_back(Method);
ClsMap[Method->getSelector().getAsOpaquePtr()] = Method;
ClsMap[Method->getSelector()] = Method;
}
}
else

Просмотреть файл

@ -237,7 +237,7 @@
84AF36A00CB17A3B00C820A5 /* DeclObjC.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = DeclObjC.h; path = clang/AST/DeclObjC.h; sourceTree = "<group>"; };
84D9A8870C1A57E100AC7ABC /* AttributeList.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = AttributeList.cpp; path = Parse/AttributeList.cpp; sourceTree = "<group>"; };
84D9A88B0C1A581300AC7ABC /* AttributeList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = AttributeList.h; path = clang/Parse/AttributeList.h; sourceTree = "<group>"; };
8DD76F6C0486A84900D96B5E /* clang */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = clang; sourceTree = BUILT_PRODUCTS_DIR; };
8DD76F6C0486A84900D96B5E /* clang */ = {isa = PBXFileReference; includeInIndex = 0; lastKnownFileType = "compiled.mach-o.executable"; path = clang; sourceTree = BUILT_PRODUCTS_DIR; };
DE01DA480B12ADA300AC22CE /* PPCallbacks.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = PPCallbacks.h; sourceTree = "<group>"; };
DE06756B0C051CFE00EBBFD8 /* ParseExprCXX.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; name = ParseExprCXX.cpp; path = Parse/ParseExprCXX.cpp; sourceTree = "<group>"; };
DE06B73D0A8307640050E87E /* LangOptions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = LangOptions.h; sourceTree = "<group>"; };
@ -739,7 +739,6 @@
08FB7793FE84155DC02AAC07 /* Project object */ = {
isa = PBXProject;
buildConfigurationList = 1DEB923508733DC60010E9CD /* Build configuration list for PBXProject "clang" */;
compatibilityVersion = "Xcode 2.4";
hasScannedForEncodings = 1;
mainGroup = 08FB7794FE84155DC02AAC07 /* clang */;
projectDirPath = "";