[cfe-commits] r42714 - in /cfe/trunk: Sema/Sema.h Sema/SemaDecl.cpp include/clang/AST/ASTContext.h

Chris Lattner sabre at nondot.org
Sat Oct 6 18:13:46 PDT 2007


Author: lattner
Date: Sat Oct  6 20:13:46 2007
New Revision: 42714

URL: http://llvm.org/viewvc/llvm-project?rev=42714&view=rev
Log:
move ImplementationClassInfo out of ASTContext into Sema.

Modified:
    cfe/trunk/Sema/Sema.h
    cfe/trunk/Sema/SemaDecl.cpp
    cfe/trunk/include/clang/AST/ASTContext.h

Modified: cfe/trunk/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/Sema.h?rev=42714&r1=42713&r2=42714&view=diff

==============================================================================
--- cfe/trunk/Sema/Sema.h (original)
+++ cfe/trunk/Sema/Sema.h Sat Oct  6 20:13:46 2007
@@ -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,

Modified: cfe/trunk/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Sema/SemaDecl.cpp?rev=42714&r1=42713&r2=42714&view=diff

==============================================================================
--- cfe/trunk/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/Sema/SemaDecl.cpp Sat Oct  6 20:13:46 2007
@@ -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;
 }

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=42714&r1=42713&r2=42714&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Sat Oct  6 20:13:46 2007
@@ -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
   //===--------------------------------------------------------------------===//





More information about the cfe-commits mailing list