]> granicus.if.org Git - clang/commitdiff
When chaining PCHs, only write PPRecords that don't come from PCH, and give them...
authorSebastian Redl <sebastian.redl@getdesigned.at>
Mon, 27 Sep 2010 22:18:47 +0000 (22:18 +0000)
committerSebastian Redl <sebastian.redl@getdesigned.at>
Mon, 27 Sep 2010 22:18:47 +0000 (22:18 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@114913 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Lex/PreprocessingRecord.h
lib/Serialization/ASTReader.cpp
lib/Serialization/ASTWriter.cpp

index 730f04f2fa0994da738853d2da1751d938c279ef..576b571a4ede361d26b99a6b4d6263bccf26d863 100644 (file)
@@ -236,6 +236,10 @@ namespace clang {
     /// \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.
index cc593e98271bc28610203a4c1da21f0e8212b6cc..1a42665d075f2f9060c87241269b932b78b50f4c 100644 (file)
@@ -1474,7 +1474,7 @@ void ASTReader::ReadMacroRecord(llvm::BitstreamCursor &Stream, uint64_t Offset){
       MacroDefinitionsLoaded[Record[1]] = MD;
       return;
     }
-  }
+    }
   }
 }
 
index 24ec7ea4b7c361a9829de90dfcfb8d5597f81463..61ba5ab71ba5a8bf7d0c511a83040347bd7325f3 100644 (file)
@@ -1334,12 +1334,14 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP) {
   // 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 @@ void ASTWriter::WritePreprocessor(const Preprocessor &PP) {
         } 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);