move ImplementationClassInfo out of ASTContext into Sema.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@42714 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Sema/Sema.h b/Sema/Sema.h
index 6d38e62..c4ad75b 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 <vector>
 #include <string>
 
@@ -83,6 +83,10 @@
   /// 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,
diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp
index 76c0002..6830d24 100644
--- a/Sema/SemaDecl.cpp
+++ b/Sema/SemaDecl.cpp
@@ -1176,16 +1176,8 @@
   }
   
   // 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 8be7fd1..3385ca8 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 @@
   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 @@
   /// 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
   //===--------------------------------------------------------------------===//