]> granicus.if.org Git - clang/commitdiff
Use forward declarations for ASTDeclContextNameLookupTable and add a missing delete.
authorBenjamin Kramer <benny.kra@googlemail.com>
Sun, 15 Apr 2012 12:36:49 +0000 (12:36 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sun, 15 Apr 2012 12:36:49 +0000 (12:36 +0000)
It would be nice to use OwningPtr here, but DeclContextInfo is stored in a DenseMap.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154763 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Serialization/ASTReader.h
include/clang/Serialization/Module.h
lib/Serialization/ASTReader.cpp
lib/Serialization/ASTReaderDecl.cpp
lib/Serialization/ASTReaderInternals.h
lib/Serialization/Module.cpp

index 9baaf4bcb52759da1eb4bfb44c10fa7e25cc97e9..a0bcecc93ae20b91c87484e0708de9f169f143b2 100644 (file)
@@ -170,6 +170,9 @@ class ReadMethodPoolVisitor;
 
 namespace reader {
   class ASTIdentifierLookupTrait;
+  /// \brief The on-disk hash table used for the DeclContext's Name lookup table.
+  typedef OnDiskChainedHashTable<ASTDeclContextNameLookupTrait>
+    ASTDeclContextNameLookupTable;
 }
 
 } // end namespace serialization
@@ -323,7 +326,9 @@ private:
   // TU, and when we read those update records, the actual context will not
   // be available yet (unless it's the TU), so have this pending map using the
   // ID as a key. It will be realized when the context is actually loaded.
-  typedef SmallVector<std::pair<void *, ModuleFile*>, 1> DeclContextVisibleUpdates;
+  typedef
+    SmallVector<std::pair<serialization::reader::ASTDeclContextNameLookupTable *,
+                          ModuleFile*>, 1> DeclContextVisibleUpdates;
   typedef llvm::DenseMap<serialization::DeclID, DeclContextVisibleUpdates>
       DeclContextVisibleUpdatesPending;
 
index 4c93c33842cf9857f3a522e7dd3675c8d05d36e0..786ecd33c1d3d21810cffc9b4431036e795f4565 100644 (file)
@@ -27,9 +27,14 @@ namespace clang {
 
 class DeclContext;
 class Module;
-  
+template<typename Info> class OnDiskChainedHashTable;
+
 namespace serialization {
 
+namespace reader {
+  class ASTDeclContextNameLookupTrait;
+}
+
 /// \brief Specifies the kind of module that has been loaded.
 enum ModuleKind {
   MK_Module,   ///< File is a module proper.
@@ -43,7 +48,8 @@ struct DeclContextInfo {
   DeclContextInfo()
     : NameLookupTableData(), LexicalDecls(), NumLexicalDecls() {}
 
-  void *NameLookupTableData; // an ASTDeclContextNameLookupTable.
+  OnDiskChainedHashTable<reader::ASTDeclContextNameLookupTrait>
+    *NameLookupTableData; // an ASTDeclContextNameLookupTable.
   const KindDeclIDPair *LexicalDecls;
   unsigned NumLexicalDecls;
 };
index f91b66cf54765b54905832c6c5d233fbb6316260..05fcb4ba9f808050ac86fd0fc2f3a6d39e287577 100644 (file)
@@ -1911,7 +1911,8 @@ ASTReader::ReadASTBlock(ModuleFile &F) {
     case UPDATE_VISIBLE: {
       unsigned Idx = 0;
       serialization::DeclID ID = ReadDeclID(F, Record, Idx);
-      void *Table = ASTDeclContextNameLookupTable::Create(
+      ASTDeclContextNameLookupTable *Table =
+        ASTDeclContextNameLookupTable::Create(
                         (const unsigned char *)BlobStart + Record[Idx++],
                         (const unsigned char *)BlobStart,
                         ASTDeclContextNameLookupTrait(*this, F));
@@ -4908,7 +4909,7 @@ namespace {
       
       // Look for this name within this module.
       ASTDeclContextNameLookupTable *LookupTable =
-        (ASTDeclContextNameLookupTable*)Info->second.NameLookupTableData;
+        Info->second.NameLookupTableData;
       ASTDeclContextNameLookupTable::iterator Pos
         = LookupTable->find(This->Name);
       if (Pos == LookupTable->end())
@@ -4997,7 +4998,7 @@ namespace {
       
       // Look for this name within this module.
       ASTDeclContextNameLookupTable *LookupTable =
-        (ASTDeclContextNameLookupTable*)Info->second.NameLookupTableData;
+        Info->second.NameLookupTableData;
       for (ASTDeclContextNameLookupTable::key_iterator
              I = LookupTable->key_begin(),
              E = LookupTable->key_end(); I != E; ++I) {
@@ -6364,6 +6365,6 @@ ASTReader::~ASTReader() {
     for (DeclContextVisibleUpdates::iterator J = I->second.begin(),
                                              F = I->second.end();
          J != F; ++J)
-      delete static_cast<ASTDeclContextNameLookupTable*>(J->first);
+      delete J->first;
   }
 }
index 38b612cbd9ea47a69ef98b0cb258db858d82fa78..8dd53ee7d206b0ade4315de880d2bd3311601038 100644 (file)
@@ -13,6 +13,7 @@
 //===----------------------------------------------------------------------===//
 
 #include "ASTCommon.h"
+#include "ASTReaderInternals.h"
 #include "clang/Serialization/ASTReader.h"
 #include "clang/Sema/IdentifierResolver.h"
 #include "clang/Sema/Sema.h"
@@ -2104,7 +2105,9 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
       DeclContextVisibleUpdates &U = I->second;
       for (DeclContextVisibleUpdates::iterator UI = U.begin(), UE = U.end();
            UI != UE; ++UI) {
-        UI->second->DeclContextInfos[DC].NameLookupTableData = UI->first;
+        DeclContextInfo &Info = UI->second->DeclContextInfos[DC];
+        delete Info.NameLookupTableData;
+        Info.NameLookupTableData = UI->first;
       }
       PendingVisibleUpdates.erase(I);
     }
index 3a1dfcf4b74a62438c382837226fa59cc40742da..da90c3400a25d6be2e8c1f773d19f19b765a2d24 100644 (file)
@@ -79,10 +79,6 @@ public:
                      unsigned DataLen);
 };
 
-/// \brief The on-disk hash table used for the DeclContext's Name lookup table.
-typedef OnDiskChainedHashTable<ASTDeclContextNameLookupTrait>
-  ASTDeclContextNameLookupTable;
-
 /// \brief Class that performs lookup for an identifier stored in an AST file.
 class ASTIdentifierLookupTrait {
   ASTReader &Reader;
index 16b95e2a68345bf002b7c86d79b554f8c1609afb..ff241d3d4105f547352f6e7417ede689028aafd3 100644 (file)
@@ -45,8 +45,7 @@ ModuleFile::~ModuleFile() {
        E = DeclContextInfos.end();
        I != E; ++I) {
     if (I->second.NameLookupTableData)
-      delete static_cast<ASTDeclContextNameLookupTable*>(
-                                                 I->second.NameLookupTableData);
+      delete I->second.NameLookupTableData;
   }
   
   delete static_cast<ASTIdentifierLookupTable *>(IdentifierLookupTable);