]> granicus.if.org Git - clang/commitdiff
Revert C++11ification in r203534 and r203536. Apparently our toolchains aren't
authorRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 11 Mar 2014 07:17:35 +0000 (07:17 +0000)
committerRichard Smith <richard-llvm@metafoo.co.uk>
Tue, 11 Mar 2014 07:17:35 +0000 (07:17 +0000)
ready for this yet.

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

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

index 33bfe22091819757f00215c61c34a05166521f02..469785de7c45e2dbe11cc9ffe061fedfc280b1b3 100644 (file)
@@ -44,20 +44,13 @@ enum ModuleKind {
   MK_MainFile  ///< File is a PCH file treated as the actual main file.
 };
 
-/// A custom deleter for DeclContextInfo::NameLookupTableData, to allow
-/// an incomplete type to be used there.
-struct NameLookupTableDataDeleter {
-  void operator()(
-      OnDiskChainedHashTable<reader::ASTDeclContextNameLookupTrait> *Ptr) const;
-};
-
 /// \brief Information about the contents of a DeclContext.
 struct DeclContextInfo {
-  DeclContextInfo();
+  DeclContextInfo()
+    : NameLookupTableData(), LexicalDecls(), NumLexicalDecls() {}
 
-  /// An ASTDeclContextNameLookupTable.
-  std::unique_ptr<OnDiskChainedHashTable<reader::ASTDeclContextNameLookupTrait>,
-                  NameLookupTableDataDeleter> NameLookupTableData;
+  OnDiskChainedHashTable<reader::ASTDeclContextNameLookupTrait>
+    *NameLookupTableData; // an ASTDeclContextNameLookupTable.
   const KindDeclIDPair *LexicalDecls;
   unsigned NumLexicalDecls;
 };
index b35a27c27ff3d87f0f606d7326bf2b1d54b038ed..24cb7a6ca42f84257a04191632ebf2b22dea4e26 100644 (file)
@@ -457,14 +457,6 @@ ASTReader::setDeserializationListener(ASTDeserializationListener *Listener) {
 }
 
 
-DeclContextInfo::DeclContextInfo()
-    : NameLookupTableData(), LexicalDecls(), NumLexicalDecls() {}
-
-void NameLookupTableDataDeleter::
-operator()(ASTDeclContextNameLookupTable *Ptr) const {
-  delete Ptr;
-}
-
 
 unsigned ASTSelectorLookupTrait::ComputeHash(Selector Sel) {
   return serialization::ComputeHash(Sel);
@@ -844,10 +836,11 @@ bool ASTReader::ReadDeclContextStorage(ModuleFile &M,
       Error("Expected visible lookup table block");
       return true;
     }
-    Info.NameLookupTableData.reset(ASTDeclContextNameLookupTable::Create(
-        (const unsigned char *)Blob.data() + Record[0],
-        (const unsigned char *)Blob.data(),
-        ASTDeclContextNameLookupTrait(*this, M)));
+    Info.NameLookupTableData
+      = ASTDeclContextNameLookupTable::Create(
+                    (const unsigned char *)Blob.data() + Record[0],
+                    (const unsigned char *)Blob.data(),
+                    ASTDeclContextNameLookupTrait(*this, M));
   }
 
   return false;
@@ -2500,12 +2493,14 @@ bool ASTReader::ReadASTBlock(ModuleFile &F) {
                         ASTDeclContextNameLookupTrait(*this, F));
       if (ID == PREDEF_DECL_TRANSLATION_UNIT_ID) { // Is it the TU?
         DeclContext *TU = Context.getTranslationUnitDecl();
-        F.DeclContextInfos[TU].NameLookupTableData.reset(Table);
+        F.DeclContextInfos[TU].NameLookupTableData = Table;
         TU->setHasExternalVisibleStorage(true);
       } else if (Decl *D = DeclsLoaded[ID - NUM_PREDEF_DECL_IDS]) {
         auto *DC = cast<DeclContext>(D);
         DC->getPrimaryContext()->setHasExternalVisibleStorage(true);
-        F.DeclContextInfos[DC].NameLookupTableData.reset(Table);
+        auto *&LookupTable = F.DeclContextInfos[DC].NameLookupTableData;
+        delete LookupTable;
+        LookupTable = Table;
       } else
         PendingVisibleUpdates[ID].push_back(std::make_pair(Table, &F));
       break;
@@ -6089,7 +6084,7 @@ namespace {
         return false;
       
       // Look for this name within this module.
-      const auto &LookupTable =
+      ASTDeclContextNameLookupTable *LookupTable =
         Info->second.NameLookupTableData;
       ASTDeclContextNameLookupTable::iterator Pos
         = LookupTable->find(This->Name);
@@ -6219,7 +6214,7 @@ namespace {
       if (!FoundInfo)
         return false;
 
-      const auto &LookupTable =
+      ASTDeclContextNameLookupTable *LookupTable =
         Info->second.NameLookupTableData;
       bool FoundAnything = false;
       for (ASTDeclContextNameLookupTable::data_iterator
index fef5f7b88901036730f71bec7c669327286110cb..11148ebc5efe49c97eeea71b584b9affdcadf64b 100644 (file)
@@ -2609,9 +2609,11 @@ Decl *ASTReader::ReadDeclRecord(DeclID ID) {
       // There are updates. This means the context has external visible
       // storage, even if the original stored version didn't.
       LookupDC->setHasExternalVisibleStorage(true);
-      for (const auto &Update : I->second)
-        Update.second->DeclContextInfos[DC].NameLookupTableData.reset(
-            Update.first);
+      for (const auto &Update : I->second) {
+        DeclContextInfo &Info = Update.second->DeclContextInfos[DC];
+        delete Info.NameLookupTableData;
+        Info.NameLookupTableData = Update.first;
+      }
       PendingVisibleUpdates.erase(I);
     }
   }
index 77dcc4f99e3b6f66045c1abc7ac5fd544d641fd1..2eb397176a1293cdd0976a9bd2beebf6c8b9d251 100644 (file)
@@ -45,6 +45,13 @@ ModuleFile::ModuleFile(ModuleKind Kind, unsigned Generation)
 {}
 
 ModuleFile::~ModuleFile() {
+  for (DeclContextInfosMap::iterator I = DeclContextInfos.begin(),
+       E = DeclContextInfos.end();
+       I != E; ++I) {
+    if (I->second.NameLookupTableData)
+      delete I->second.NameLookupTableData;
+  }
+  
   delete static_cast<ASTIdentifierLookupTable *>(IdentifierLookupTable);
   delete static_cast<HeaderFileInfoLookupTable *>(HeaderFileInfoTable);
   delete static_cast<ASTSelectorLookupTable *>(SelectorLookupTable);