r220208 - Revert most of r215810, which is no longer needed

Ben Langmuir blangmuir at apple.com
Mon Oct 20 09:27:33 PDT 2014


Author: benlangmuir
Date: Mon Oct 20 11:27:32 2014
New Revision: 220208

URL: http://llvm.org/viewvc/llvm-project?rev=220208&view=rev
Log:
Revert most of r215810, which is no longer needed

Now that we no longer add mappings when there are no local entities,
there is no need to always bump the size of the tables that correspond
to ContinuousRangeMaps.

Modified:
    cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=220208&r1=220207&r2=220208&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Mon Oct 20 11:27:32 2014
@@ -2620,9 +2620,9 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
         F.TypeRemap.insertOrReplace(
           std::make_pair(LocalBaseTypeIndex, 
                          F.BaseTypeIndex - LocalBaseTypeIndex));
+
+        TypesLoaded.resize(TypesLoaded.size() + F.LocalNumTypes);
       }
-      // Increase size by >= 1 so we get a unique base index in the next module.
-      TypesLoaded.resize(TypesLoaded.size() + std::max(F.LocalNumTypes, 1U));
       break;
     }
         
@@ -2650,10 +2650,9 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
         // Introduce the global -> local mapping for declarations within this
         // module.
         F.GlobalToLocalDeclIDs[&F] = LocalBaseDeclID;
-      }
 
-      // Increase size by >= 1 so we get a unique base index in the next module.
-      DeclsLoaded.resize(DeclsLoaded.size() + std::max(F.LocalNumDecls, 1U));
+        DeclsLoaded.resize(DeclsLoaded.size() + F.LocalNumDecls);
+      }
       break;
     }
         
@@ -2721,11 +2720,10 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
         F.IdentifierRemap.insertOrReplace(
           std::make_pair(LocalBaseIdentifierID,
                          F.BaseIdentifierID - LocalBaseIdentifierID));
-      }
 
-      // Increase size by >= 1 so we get a unique base index in the next module.
-      IdentifiersLoaded.resize(IdentifiersLoaded.size() +
-                               std::max(F.LocalNumIdentifiers, 1U));
+        IdentifiersLoaded.resize(IdentifiersLoaded.size()
+                                 + F.LocalNumIdentifiers);
+      }
       break;
     }
 
@@ -2815,10 +2813,9 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
         F.SelectorRemap.insertOrReplace(
           std::make_pair(LocalBaseSelectorID,
                          F.BaseSelectorID - LocalBaseSelectorID));
+
+        SelectorsLoaded.resize(SelectorsLoaded.size() + F.LocalNumSelectors);
       }
-      // Increase size by >= 1 so we get a unique base index in the next module.
-      SelectorsLoaded.resize(SelectorsLoaded.size() +
-                             std::max(F.LocalNumSelectors, 1U));
       break;
     }
         
@@ -2858,10 +2855,8 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
       F.SLocEntryOffsets = (const uint32_t *)Blob.data();
       F.LocalNumSLocEntries = Record[0];
       unsigned SLocSpaceSize = Record[1];
-
-      // Increase size by >= 1 so we get a unique base index in the next module.
       std::tie(F.SLocEntryBaseID, F.SLocEntryBaseOffset) =
-          SourceMgr.AllocateLoadedSLocEntries(std::max(F.LocalNumSLocEntries, 1U),
+          SourceMgr.AllocateLoadedSLocEntries(F.LocalNumSLocEntries,
                                               SLocSpaceSize);
       // Make our entry in the range map. BaseID is negative and growing, so
       // we invert it. Because we invert it, though, we need the other end of
@@ -3048,11 +3043,9 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
         PP.createPreprocessingRecord();
       if (!PP.getPreprocessingRecord()->getExternalSource())
         PP.getPreprocessingRecord()->SetExternalSource(*this);
-
-      // Increase size by >= 1 so we get a unique base index in the next module.
       StartingID 
         = PP.getPreprocessingRecord()
-            ->allocateLoadedEntities(std::max(F.NumPreprocessedEntities, 1U));
+            ->allocateLoadedEntities(F.NumPreprocessedEntities);
       F.BasePreprocessedEntityID = StartingID;
 
       if (F.NumPreprocessedEntities > 0) {
@@ -3256,9 +3249,9 @@ ASTReader::ReadASTBlock(ModuleFile &F, u
         F.MacroRemap.insertOrReplace(
           std::make_pair(LocalBaseMacroID,
                          F.BaseMacroID - LocalBaseMacroID));
+
+        MacrosLoaded.resize(MacrosLoaded.size() + F.LocalNumMacros);
       }
-      // Increase size by >= 1 so we get a unique base index in the next module.
-      MacrosLoaded.resize(MacrosLoaded.size() + std::max(F.LocalNumMacros, 1U));
       break;
     }
 
@@ -4515,11 +4508,9 @@ ASTReader::ReadSubmoduleBlock(ModuleFile
         F.SubmoduleRemap.insertOrReplace(
           std::make_pair(LocalBaseSubmoduleID,
                          F.BaseSubmoduleID - LocalBaseSubmoduleID));
-      }
 
-      // Increase size by >= 1 so we get a unique base index in the next module.
-      SubmodulesLoaded.resize(SubmodulesLoaded.size() +
-                              std::max(F.LocalNumSubmodules, 1U));
+        SubmodulesLoaded.resize(SubmodulesLoaded.size() + F.LocalNumSubmodules);
+      }
       break;
     }
         





More information about the cfe-commits mailing list