r251877 - Eliminate "rewritten decls" from the AST writer. NFC

Douglas Gregor via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 2 17:20:54 PST 2015


Author: dgregor
Date: Mon Nov  2 19:20:54 2015
New Revision: 251877

URL: http://llvm.org/viewvc/llvm-project?rev=251877&view=rev
Log:
Eliminate "rewritten decls" from the AST writer. NFC


Modified:
    cfe/trunk/include/clang/Serialization/ASTWriter.h
    cfe/trunk/lib/Serialization/ASTWriter.cpp
    cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=251877&r1=251876&r2=251877&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Mon Nov  2 19:20:54 2015
@@ -376,10 +376,6 @@ private:
   /// coming from another AST file.
   SmallVector<const Decl *, 16> UpdatingVisibleDecls;
 
-  typedef llvm::SmallSetVector<const Decl *, 16> 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<ObjCInterfaceDecl *> 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);

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=251877&r1=251876&r2=251877&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Mon Nov  2 19:20:54 2015
@@ -3513,11 +3513,11 @@ ASTWriter::GenerateNameLookupTable(const
     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<Decl>(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::WriteDeclContextVisi
 /// (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<Decl>(DC)))
-    return;
-
   StoredDeclsMap *Map = DC->getLookupPtr();
   if (!Map || Map->empty())
     return;
@@ -4376,10 +4373,6 @@ uint64_t ASTWriter::WriteASTCore(Sema &S
   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<Decl*>(*I));
   do {
     WriteDeclUpdatesBlocks(DeclUpdatesOffsetsRecord);
     while (!DeclTypesToEmit.empty()) {
@@ -4545,8 +4538,6 @@ void ASTWriter::WriteDeclUpdatesBlocks(R
 
   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;

Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=251877&r1=251876&r2=251877&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Mon Nov  2 19:20:54 2015
@@ -2093,16 +2093,12 @@ void ASTWriter::WriteDecl(ASTContext &Co
 
   // 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;
 




More information about the cfe-commits mailing list