From f38766870882b8cdd3d9de05f734c024f556b5bc Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sun, 7 Oct 2007 01:13:46 +0000 Subject: [PATCH] move ImplementationClassInfo out of ASTContext into Sema. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42714 91177308-0d34-0410-b5e6-96231b3b80d8 --- Sema/Sema.h | 6 +++++- Sema/SemaDecl.cpp | 12 ++---------- include/clang/AST/ASTContext.h | 12 ------------ 3 files changed, 7 insertions(+), 23 deletions(-) diff --git a/Sema/Sema.h b/Sema/Sema.h index 6d38e629e3..c4ad75be86 100644 --- a/Sema/Sema.h +++ b/Sema/Sema.h @@ -16,9 +16,9 @@ #define LLVM_CLANG_AST_SEMA_H #include "clang/Parse/Action.h" -#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/DenseSet.h" +#include "llvm/ADT/SmallPtrSet.h" #include #include @@ -83,6 +83,10 @@ class Sema : public Action { /// This is only necessary for issuing pretty diagnostics. llvm::SmallVector OCUVectorDecls; + /// ObjcImplementations - Keep track of all of the classes with + /// @implementation's, so that we can emit errors on duplicates. + llvm::SmallPtrSet ObjcImplementations; + // Enum values used by KnownFunctionIDs (see below). enum { id_printf, diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp index 76c00029eb..6830d241f1 100644 --- a/Sema/SemaDecl.cpp +++ b/Sema/SemaDecl.cpp @@ -1176,16 +1176,8 @@ Sema::DeclTy *Sema::ActOnStartClassImplementation(Scope *S, } // Check that there is no duplicate implementation of this class. - bool err = false; - for (unsigned i = 0; i != Context.sizeObjcImplementationClass(); i++) { - if (Context.getObjcImplementationClass(i)->getIdentifier() == ClassName) { - Diag(ClassLoc, diag::err_dup_implementation_class, ClassName->getName()); - err = true; - break; - } - } - if (!err) - Context.setObjcImplementationClass(IMPDecl); + if (!ObjcImplementations.insert(ClassName)) + Diag(ClassLoc, diag::err_dup_implementation_class, ClassName->getName()); return IMPDecl; } diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h index 8be7fd1801..3385ca8c22 100644 --- a/include/clang/AST/ASTContext.h +++ b/include/clang/AST/ASTContext.h @@ -26,7 +26,6 @@ namespace clang { class TargetInfo; - class ObjcImplementationDecl; /// ASTContext - This class holds long-lived AST nodes (such as types and /// decls) that can be referred to throughout the semantic analysis of a file. @@ -40,7 +39,6 @@ class ASTContext { llvm::FoldingSet FunctionTypeNoProtos; llvm::FoldingSet FunctionTypeProtos; llvm::DenseMap RecordLayoutInfo; - llvm::SmallVector ImplementationClassInfo; RecordDecl *CFConstantStringTypeDecl; public: @@ -165,16 +163,6 @@ public: /// position information. const RecordLayout &getRecordLayout(const RecordDecl *D, SourceLocation L); - ObjcImplementationDecl* getObjcImplementationClass(unsigned ix) { - return ImplementationClassInfo[ix]; - } - void setObjcImplementationClass(ObjcImplementationDecl* ImplDecl) { - ImplementationClassInfo.push_back(ImplDecl); - } - unsigned sizeObjcImplementationClass() const { - return ImplementationClassInfo.size(); - } - //===--------------------------------------------------------------------===// // Type Operators //===--------------------------------------------------------------------===// -- 2.40.0