From: Douglas Gregor Date: Tue, 3 Nov 2015 01:20:54 +0000 (+0000) Subject: Eliminate "rewritten decls" from the AST writer. NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9a3185dd71c30270b83069f569f95e8bbb5e032b;p=clang Eliminate "rewritten decls" from the AST writer. NFC git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@251877 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Serialization/ASTWriter.h b/include/clang/Serialization/ASTWriter.h index b00b7d2d06..45e29921a5 100644 --- a/include/clang/Serialization/ASTWriter.h +++ b/include/clang/Serialization/ASTWriter.h @@ -376,10 +376,6 @@ private: /// coming from another AST file. SmallVector UpdatingVisibleDecls; - typedef llvm::SmallSetVector DeclsToRewriteTy; - /// \brief Decls that will be replaced in the current dependent AST file. - DeclsToRewriteTy DeclsToRewrite; - /// \brief The set of Objective-C class that have categories we /// should serialize. llvm::SetVector ObjCClassesWithCategories; @@ -764,14 +760,6 @@ public: /// \brief Add a version tuple to the given record void AddVersionTuple(const VersionTuple &Version, RecordDataImpl &Record); - void RewriteDecl(const Decl *D) { - DeclsToRewrite.insert(D); - } - - bool isRewritten(const Decl *D) const { - return DeclsToRewrite.count(D); - } - /// \brief Infer the submodule ID that contains an entity at the given /// source location. serialization::SubmoduleID inferSubmoduleIDFromLocation(SourceLocation Loc); diff --git a/lib/Serialization/ASTWriter.cpp b/lib/Serialization/ASTWriter.cpp index 4399fdcb2f..01e9f220f9 100644 --- a/lib/Serialization/ASTWriter.cpp +++ b/lib/Serialization/ASTWriter.cpp @@ -3513,11 +3513,11 @@ ASTWriter::GenerateNameLookupTable(const DeclContext *ConstDC, auto &Name = Lookup.first; auto &Result = Lookup.second; - // If there are no local declarations in our lookup result, we don't - // need to write an entry for the name at all unless we're rewriting - // the decl context. If we can't write out a lookup set without - // performing more deserialization, just skip this entry. - if (isLookupResultExternal(Result, DC) && !isRewritten(cast(DC)) && + // If there are no local declarations in our lookup result, we + // don't need to write an entry for the name at all. If we can't + // write out a lookup set without performing more deserialization, + // just skip this entry. + if (isLookupResultExternal(Result, DC) && isLookupResultEntirelyExternal(Result, DC)) continue; @@ -3758,9 +3758,6 @@ uint64_t ASTWriter::WriteDeclContextVisibleBlock(ASTContext &Context, /// (in C++), for namespaces, and for classes with forward-declared unscoped /// enumeration members (in C++11). void ASTWriter::WriteDeclContextVisibleUpdate(const DeclContext *DC) { - if (isRewritten(cast(DC))) - return; - StoredDeclsMap *Map = DC->getLookupPtr(); if (!Map || Map->empty()) return; @@ -4376,10 +4373,6 @@ uint64_t ASTWriter::WriteASTCore(Sema &SemaRef, StringRef isysroot, Stream.EnterSubblock(DECLTYPES_BLOCK_ID, /*bits for abbreviations*/5); WriteTypeAbbrevs(); WriteDeclAbbrevs(); - for (DeclsToRewriteTy::iterator I = DeclsToRewrite.begin(), - E = DeclsToRewrite.end(); - I != E; ++I) - DeclTypesToEmit.push(const_cast(*I)); do { WriteDeclUpdatesBlocks(DeclUpdatesOffsetsRecord); while (!DeclTypesToEmit.empty()) { @@ -4545,8 +4538,6 @@ void ASTWriter::WriteDeclUpdatesBlocks(RecordDataImpl &OffsetsRecord) { for (auto &DeclUpdate : LocalUpdates) { const Decl *D = DeclUpdate.first; - if (isRewritten(D)) - continue; // The decl will be written completely,no need to store updates. bool HasUpdatedBody = false; RecordData Record; diff --git a/lib/Serialization/ASTWriterDecl.cpp b/lib/Serialization/ASTWriterDecl.cpp index 49eacea44e..cc67b172be 100644 --- a/lib/Serialization/ASTWriterDecl.cpp +++ b/lib/Serialization/ASTWriterDecl.cpp @@ -2093,16 +2093,12 @@ void ASTWriter::WriteDecl(ASTContext &Context, Decl *D) { // Determine the ID for this declaration. serialization::DeclID ID; - if (D->isFromASTFile()) { - assert(isRewritten(D) && "should not be emitting imported decl"); - ID = getDeclID(D); - } else { - serialization::DeclID &IDR = DeclIDs[D]; - if (IDR == 0) - IDR = NextDeclID++; + assert(!D->isFromASTFile() && "should not be emitting imported decl"); + serialization::DeclID &IDR = DeclIDs[D]; + if (IDR == 0) + IDR = NextDeclID++; - ID = IDR; - } + ID = IDR; bool isReplacingADecl = ID < FirstDeclID;