[cfe-commits] r114913 - in /cfe/trunk: include/clang/Lex/PreprocessingRecord.h lib/Serialization/ASTReader.cpp lib/Serialization/ASTWriter.cpp

Sebastian Redl sebastian.redl at getdesigned.at
Mon Sep 27 15:18:47 PDT 2010


Author: cornedbee
Date: Mon Sep 27 17:18:47 2010
New Revision: 114913

URL: http://llvm.org/viewvc/llvm-project?rev=114913&view=rev
Log:
When chaining PCHs, only write PPRecords that don't come from PCH, and give them the correct IDs. Fixes a crash in XCode.

Modified:
    cfe/trunk/include/clang/Lex/PreprocessingRecord.h
    cfe/trunk/lib/Serialization/ASTReader.cpp
    cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/Lex/PreprocessingRecord.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessingRecord.h?rev=114913&r1=114912&r2=114913&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/PreprocessingRecord.h (original)
+++ cfe/trunk/include/clang/Lex/PreprocessingRecord.h Mon Sep 27 17:18:47 2010
@@ -236,6 +236,10 @@
     /// \brief Set the external source for preprocessed entities.
     void SetExternalSource(ExternalPreprocessingRecordSource &Source,
                            unsigned NumPreallocatedEntities);
+
+    unsigned getNumPreallocatedEntities() const {
+      return NumPreallocatedEntities;
+    }
     
     /// \brief Set the preallocated entry at the given index to the given
     /// preprocessed entity.

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=114913&r1=114912&r2=114913&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Mon Sep 27 17:18:47 2010
@@ -1474,7 +1474,7 @@
       MacroDefinitionsLoaded[Record[1]] = MD;
       return;
     }
-  }
+    }
   }
 }
 

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=114913&r1=114912&r2=114913&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Mon Sep 27 17:18:47 2010
@@ -1334,12 +1334,14 @@
   // If the preprocessor has a preprocessing record, emit it.
   unsigned NumPreprocessingRecords = 0;
   if (PPRec) {
-    for (PreprocessingRecord::iterator E = PPRec->begin(), EEnd = PPRec->end();
+    unsigned IndexBase = PPRec->getNumPreallocatedEntities();
+    for (PreprocessingRecord::iterator E = PPRec->begin(Chain),
+                                       EEnd = PPRec->end(Chain);
          E != EEnd; ++E) {
       Record.clear();
       
       if (MacroInstantiation *MI = dyn_cast<MacroInstantiation>(*E)) {
-        Record.push_back(NumPreprocessingRecords++);
+        Record.push_back(IndexBase + NumPreprocessingRecords++);
         AddSourceLocation(MI->getSourceRange().getBegin(), Record);
         AddSourceLocation(MI->getSourceRange().getEnd(), Record);
         AddIdentifierRef(MI->getName(), Record);
@@ -1359,7 +1361,7 @@
         } else
           MacroDefinitionOffsets.push_back(Stream.GetCurrentBitNo());
         
-        Record.push_back(NumPreprocessingRecords++);
+        Record.push_back(IndexBase + NumPreprocessingRecords++);
         Record.push_back(ID);
         AddSourceLocation(MD->getSourceRange().getBegin(), Record);
         AddSourceLocation(MD->getSourceRange().getEnd(), Record);





More information about the cfe-commits mailing list