[cfe-commits] r140209 - in /cfe/trunk/lib/Serialization: ASTReader.cpp ASTWriter.cpp

Argyrios Kyrtzidis akyrtzi at gmail.com
Tue Sep 20 16:27:41 PDT 2011


Author: akirtzidis
Date: Tue Sep 20 18:27:41 2011
New Revision: 140209

URL: http://llvm.org/viewvc/llvm-project?rev=140209&view=rev
Log:
[PCH] Don't store the source range for each preprocessed entity since
we already have the range in the PPEntityOffsets array.

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

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=140209&r1=140208&r2=140209&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Sep 20 18:27:41 2011
@@ -2784,10 +2784,10 @@
          "Corrupted global preprocessed entity map");
   Module &M = *I->second;
   unsigned LocalIndex = Index - M.BasePreprocessedEntityID;
+  const PPEntityOffset &PPOffs = M.PreprocessedEntityOffsets[LocalIndex];
 
   SavedStreamPosition SavedPosition(M.PreprocessorDetailCursor);  
-  M.PreprocessorDetailCursor.JumpToBit(
-                             M.PreprocessedEntityOffsets[LocalIndex].BitOffset);
+  M.PreprocessorDetailCursor.JumpToBit(PPOffs.BitOffset);
 
   unsigned Code = M.PreprocessorDetailCursor.ReadCode();
   switch (Code) {
@@ -2812,6 +2812,8 @@
   }
   
   // Read the record.
+  SourceRange Range(ReadSourceLocation(M, PPOffs.Begin),
+                    ReadSourceLocation(M, PPOffs.End));
   PreprocessingRecord &PPRec = *PP.getPreprocessingRecord();
   const char *BlobStart = 0;
   unsigned BlobLen = 0;
@@ -2821,16 +2823,14 @@
                                              Code, Record, BlobStart, BlobLen);
   switch (RecType) {
   case PPD_MACRO_EXPANSION: {
-    SourceRange Range(ReadSourceLocation(M, Record[0]),
-                      ReadSourceLocation(M, Record[1]));
-    bool isBuiltin = Record[2];
+    bool isBuiltin = Record[0];
     IdentifierInfo *Name = 0;
     MacroDefinition *Def = 0;
     if (isBuiltin)
-      Name = getLocalIdentifier(M, Record[3]);
+      Name = getLocalIdentifier(M, Record[1]);
     else {
       PreprocessedEntityID
-          GlobalID = getGlobalPreprocessedEntityID(M, Record[3]);
+          GlobalID = getGlobalPreprocessedEntityID(M, Record[1]);
       Def =cast<MacroDefinition>(PPRec.getLoadedPreprocessedEntity(GlobalID-1));
     }
 
@@ -2846,12 +2846,9 @@
   case PPD_MACRO_DEFINITION: {
     // Decode the identifier info and then check again; if the macro is
     // still defined and associated with the identifier,
-    IdentifierInfo *II = getLocalIdentifier(M, Record[2]);
+    IdentifierInfo *II = getLocalIdentifier(M, Record[0]);
     MacroDefinition *MD
-      = new (PPRec) MacroDefinition(II,
-                                    SourceRange(
-                                          ReadSourceLocation(M, Record[0]),
-                                          ReadSourceLocation(M, Record[1])));
+      = new (PPRec) MacroDefinition(II, Range);
 
     if (DeserializationListener)
       DeserializationListener->MacroDefinitionRead(PPID, MD);
@@ -2860,21 +2857,20 @@
   }
       
   case PPD_INCLUSION_DIRECTIVE: {
-    const char *FullFileNameStart = BlobStart + Record[2];
+    const char *FullFileNameStart = BlobStart + Record[0];
     const FileEntry *File
       = PP.getFileManager().getFile(StringRef(FullFileNameStart,
-                                               BlobLen - Record[2]));
+                                               BlobLen - Record[0]));
     
     // FIXME: Stable encoding
     InclusionDirective::InclusionKind Kind
-      = static_cast<InclusionDirective::InclusionKind>(Record[4]);
+      = static_cast<InclusionDirective::InclusionKind>(Record[2]);
     InclusionDirective *ID
       = new (PPRec) InclusionDirective(PPRec, Kind,
-                                       StringRef(BlobStart, Record[2]),
-                                       Record[3],
+                                       StringRef(BlobStart, Record[0]),
+                                       Record[1],
                                        File,
-                                 SourceRange(ReadSourceLocation(M, Record[0]),
-                                             ReadSourceLocation(M, Record[1])));
+                                       Range);
     return ID;
   }
   }

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=140209&r1=140208&r2=140209&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Tue Sep 20 18:27:41 2011
@@ -1727,8 +1727,6 @@
   {
     BitCodeAbbrev *Abbrev = new BitCodeAbbrev();
     Abbrev->Add(BitCodeAbbrevOp(PPD_INCLUSION_DIRECTIVE));
-    Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // start location
-    Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // end location
     Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // filename length
     Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 1)); // in quotes
     Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 2)); // kind
@@ -1754,16 +1752,12 @@
       // Record this macro definition's ID.
       MacroDefinitions[MD] = NextPreprocessorEntityID;
       
-      AddSourceLocation(MD->getSourceRange().getBegin(), Record);
-      AddSourceLocation(MD->getSourceRange().getEnd(), Record);
       AddIdentifierRef(MD->getName(), Record);
       Stream.EmitRecord(PPD_MACRO_DEFINITION, Record);
       continue;
     }
 
     if (MacroExpansion *ME = dyn_cast<MacroExpansion>(*E)) {
-      AddSourceLocation(ME->getSourceRange().getBegin(), Record);
-      AddSourceLocation(ME->getSourceRange().getEnd(), Record);
       Record.push_back(ME->isBuiltinMacro());
       if (ME->isBuiltinMacro())
         AddIdentifierRef(ME->getName(), Record);
@@ -1775,8 +1769,6 @@
 
     if (InclusionDirective *ID = dyn_cast<InclusionDirective>(*E)) {
       Record.push_back(PPD_INCLUSION_DIRECTIVE);
-      AddSourceLocation(ID->getSourceRange().getBegin(), Record);
-      AddSourceLocation(ID->getSourceRange().getEnd(), Record);
       Record.push_back(ID->getFileName().size());
       Record.push_back(ID->wasInQuotes());
       Record.push_back(static_cast<unsigned>(ID->getKind()));





More information about the cfe-commits mailing list