From: Richard Smith Date: Tue, 11 Mar 2014 07:17:35 +0000 (+0000) Subject: Revert C++11ification in r203534 and r203536. Apparently our toolchains aren't X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e1f0df8c37dc18e93e9b24d58b5c362a02b8951f;p=clang Revert C++11ification in r203534 and r203536. Apparently our toolchains aren't ready for this yet. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@203548 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Serialization/Module.h b/include/clang/Serialization/Module.h index 33bfe22091..469785de7c 100644 --- a/include/clang/Serialization/Module.h +++ b/include/clang/Serialization/Module.h @@ -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 *Ptr) const; -}; - /// \brief Information about the contents of a DeclContext. struct DeclContextInfo { - DeclContextInfo(); + DeclContextInfo() + : NameLookupTableData(), LexicalDecls(), NumLexicalDecls() {} - /// An ASTDeclContextNameLookupTable. - std::unique_ptr, - NameLookupTableDataDeleter> NameLookupTableData; + OnDiskChainedHashTable + *NameLookupTableData; // an ASTDeclContextNameLookupTable. const KindDeclIDPair *LexicalDecls; unsigned NumLexicalDecls; }; diff --git a/lib/Serialization/ASTReader.cpp b/lib/Serialization/ASTReader.cpp index b35a27c27f..24cb7a6ca4 100644 --- a/lib/Serialization/ASTReader.cpp +++ b/lib/Serialization/ASTReader.cpp @@ -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(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 diff --git a/lib/Serialization/ASTReaderDecl.cpp b/lib/Serialization/ASTReaderDecl.cpp index fef5f7b889..11148ebc5e 100644 --- a/lib/Serialization/ASTReaderDecl.cpp +++ b/lib/Serialization/ASTReaderDecl.cpp @@ -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); } } diff --git a/lib/Serialization/Module.cpp b/lib/Serialization/Module.cpp index 77dcc4f99e..2eb397176a 100644 --- a/lib/Serialization/Module.cpp +++ b/lib/Serialization/Module.cpp @@ -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(IdentifierLookupTable); delete static_cast(HeaderFileInfoTable); delete static_cast(SelectorLookupTable);