[cfe-commits] r49628 - in /cfe/trunk/lib/Sema: IdentifierResolver.cpp IdentifierResolver.h

Argiris Kirtzidis akyrtzi at gmail.com
Sun Apr 13 17:09:23 PDT 2008


Author: akirtzidis
Date: Sun Apr 13 19:09:21 2008
New Revision: 49628

URL: http://llvm.org/viewvc/llvm-project?rev=49628&view=rev
Log:
Move IdDeclInfoMap class in an anonymous namespace. Suggestion by Chris Lattner.

Modified:
    cfe/trunk/lib/Sema/IdentifierResolver.cpp
    cfe/trunk/lib/Sema/IdentifierResolver.h

Modified: cfe/trunk/lib/Sema/IdentifierResolver.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/IdentifierResolver.cpp?rev=49628&r1=49627&r2=49628&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/IdentifierResolver.cpp (original)
+++ cfe/trunk/lib/Sema/IdentifierResolver.cpp Sun Apr 13 19:09:21 2008
@@ -69,13 +69,11 @@
   void RemoveShadowed(NamedDecl *D);
 };
 
-} // end anonymous namespace
-
 
 /// IdDeclInfoMap - Associates IdDeclInfos with Identifiers.
 /// Allocates 'pools' (vectors of IdDeclInfos) to avoid allocating each
 /// individual IdDeclInfo to heap.
-class IdentifierResolver::IdDeclInfoMap {
+class IdDeclInfoMap {
   static const unsigned int VECTOR_SIZE = 512;
   // Holds vectors of IdDeclInfos that serve as 'pools'.
   // New vectors are added when the current one is full.
@@ -90,9 +88,13 @@
   IdDeclInfo &operator[](IdentifierInfo *II);
 };
 
+} // end anonymous namespace
 
-IdentifierResolver::IdentifierResolver() : IdDeclInfos(*new IdDeclInfoMap) {}
-IdentifierResolver::~IdentifierResolver() { delete &IdDeclInfos; }
+
+IdentifierResolver::IdentifierResolver() : IdDeclInfos(new IdDeclInfoMap) {}
+IdentifierResolver::~IdentifierResolver() {
+  delete static_cast<IdDeclInfoMap*>(IdDeclInfos);
+}
 
 /// AddDecl - Link the decl to its shadowed decl chain.
 void IdentifierResolver::AddDecl(NamedDecl *D, Scope *S) {
@@ -109,7 +111,8 @@
 
   if (isDeclPtr(Ptr)) {
     II->setFETokenInfo(NULL);
-    IDI = &IdDeclInfos[II];
+    IdDeclInfoMap &Map = *static_cast<IdDeclInfoMap*>(IdDeclInfos);
+    IDI = &Map[II];
     IDI->PushShadowed(static_cast<NamedDecl*>(Ptr));
   } else
     IDI = toIdDeclInfo(Ptr);
@@ -151,7 +154,8 @@
 
   if (isDeclPtr(Ptr)) {
     II->setFETokenInfo(NULL);
-    IDI = &IdDeclInfos[II];
+    IdDeclInfoMap &Map = *static_cast<IdDeclInfoMap*>(IdDeclInfos);
+    IDI = &Map[II];
     IDI->PushShadowed(static_cast<NamedDecl*>(Ptr));
   } else
     IDI = toIdDeclInfo(Ptr);
@@ -231,7 +235,7 @@
 
 /// Returns the IdDeclInfo associated to the IdentifierInfo.
 /// It creates a new IdDeclInfo if one was not created before for this id.
-IdDeclInfo &IdentifierResolver::IdDeclInfoMap::operator[](IdentifierInfo *II) {
+IdDeclInfo &IdDeclInfoMap::operator[](IdentifierInfo *II) {
   assert (II && "null IdentifierInfo passed");
   void *Ptr = II->getFETokenInfo<void>();
 

Modified: cfe/trunk/lib/Sema/IdentifierResolver.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/IdentifierResolver.h?rev=49628&r1=49627&r2=49628&view=diff

==============================================================================
--- cfe/trunk/lib/Sema/IdentifierResolver.h (original)
+++ cfe/trunk/lib/Sema/IdentifierResolver.h Sun Apr 13 19:09:21 2008
@@ -43,8 +43,9 @@
   NamedDecl *Lookup(const IdentifierInfo *II, unsigned NSI);
 
 private:
-  class IdDeclInfoMap;
-  IdDeclInfoMap &IdDeclInfos;
+  // An instance of IdDeclInfoMap class, that's hidden away in the
+  // implementation file.
+  void *IdDeclInfos;
 };
 
 } // end namespace clang





More information about the cfe-commits mailing list