]> granicus.if.org Git - clang/commitdiff
move ImplementationClassInfo out of ASTContext into Sema.
authorChris Lattner <sabre@nondot.org>
Sun, 7 Oct 2007 01:13:46 +0000 (01:13 +0000)
committerChris Lattner <sabre@nondot.org>
Sun, 7 Oct 2007 01:13:46 +0000 (01:13 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42714 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/Sema.h
Sema/SemaDecl.cpp
include/clang/AST/ASTContext.h

index 6d38e629e383798d060d3e6a37df2e579bbacd70..c4ad75be86c8dd20466e080227e26844b1a564fc 100644 (file)
@@ -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 <vector>
 #include <string>
 
@@ -83,6 +83,10 @@ class Sema : public Action {
   /// This is only necessary for issuing pretty diagnostics.
   llvm::SmallVector<TypedefDecl*, 24> OCUVectorDecls;
 
+  /// ObjcImplementations - Keep track of all of the classes with
+  /// @implementation's, so that we can emit errors on duplicates.
+  llvm::SmallPtrSet<IdentifierInfo*, 8> ObjcImplementations;
+  
   // Enum values used by KnownFunctionIDs (see below).
   enum {
     id_printf,
index 76c00029eb8fd0a878e82afb21ac9875a9ac3ae1..6830d241f1c79df507062cede956beba05f8bdb2 100644 (file)
@@ -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;
 }
index 8be7fd1801e960b16675e965e4c40fba3886d434..3385ca8c228c9eb4d7d6300a2cadf7f74f3d2a65 100644 (file)
@@ -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<FunctionTypeNoProto> FunctionTypeNoProtos;
   llvm::FoldingSet<FunctionTypeProto> FunctionTypeProtos;
   llvm::DenseMap<const RecordDecl*, const RecordLayout*> RecordLayoutInfo;
-  llvm::SmallVector<ObjcImplementationDecl*, 8> 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
   //===--------------------------------------------------------------------===//