Use forward declarations for ASTDeclContextNameLookupTable and add a missing delete.

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
diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp
index f91b66c..05fcb4b 100644
--- a/lib/Serialization/ASTReader.cpp
+++ b/lib/Serialization/ASTReader.cpp
@@ -1911,7 +1911,8 @@
     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 @@
       
       // 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 @@
       
       // 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 @@
     for (DeclContextVisibleUpdates::iterator J = I->second.begin(),
                                              F = I->second.end();
          J != F; ++J)
-      delete static_cast<ASTDeclContextNameLookupTable*>(J->first);
+      delete J->first;
   }
 }
diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp
index 38b612c..8dd53ee 100644
--- a/lib/Serialization/ASTReaderDecl.cpp
+++ b/lib/Serialization/ASTReaderDecl.cpp
@@ -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 @@
       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);
     }
diff --git a/lib/Serialization/ASTReaderInternals.h b/lib/Serialization/ASTReaderInternals.h
index 3a1dfcf..da90c34 100644
--- a/lib/Serialization/ASTReaderInternals.h
+++ b/lib/Serialization/ASTReaderInternals.h
@@ -79,10 +79,6 @@
                      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;
diff --git a/lib/Serialization/Module.cpp b/lib/Serialization/Module.cpp
index 16b95e2..ff241d3 100644
--- a/lib/Serialization/Module.cpp
+++ b/lib/Serialization/Module.cpp
@@ -45,8 +45,7 @@
        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);