]> granicus.if.org Git - clang/commitdiff
For source location entries that describe instantiations, encode the
authorDouglas Gregor <dgregor@apple.com>
Wed, 15 Apr 2009 18:05:10 +0000 (18:05 +0000)
committerDouglas Gregor <dgregor@apple.com>
Wed, 15 Apr 2009 18:05:10 +0000 (18:05 +0000)
token length in the PCH file rather than trying (and failing) to
reconstruct it be getting the spelling token's length.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69191 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/SourceManager.h
lib/Frontend/PCHReader.cpp
lib/Frontend/PCHWriter.cpp

index 217640eaa5f1446eb30bbd65361d10620d3bab62..e2c40a31c9d4e128e8ba579596fcbdafec5ccb95 100644 (file)
@@ -635,6 +635,8 @@ public:
     return SLocEntryTable[FID.ID];
   }
 
+  unsigned getNextOffset() const { return NextOffset; }
+
 private:
   friend class SrcMgr::ContentCache; // Used for deserialization.
   
index 083d0d6082ddc4218e0f3b7c648a57e39b57ea55..5a01aee8b8b6c701e0cac9696757fb06b455e9ee 100644 (file)
@@ -612,9 +612,7 @@ PCHReader::PCHReadResult PCHReader::ReadSourceManagerBlock() {
                               SpellingLoc,
                               SourceLocation::getFromRawEncoding(Record[2]),
                               SourceLocation::getFromRawEncoding(Record[3]),
-                              Lexer::MeasureTokenLength(SpellingLoc, 
-                                                        SourceMgr,
-                                                        PP.getLangOptions()));
+                              Record[4]);
       break;
     }
 
index 6c3056a1bb7eb6981982d91e07290bd1cf95b5d9..0b5a2a65d15b7b5bc4a6f2c0fea319bd964e2016 100644 (file)
@@ -736,6 +736,7 @@ static unsigned CreateSLocInstantiationAbbrev(llvm::BitstreamWriter &S) {
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Spelling location
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // Start location
   Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 8)); // End location
+  Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 6)); // Token length
   return S.EmitAbbrev(Abbrev);
 }
 
@@ -818,6 +819,13 @@ void PCHWriter::WriteSourceManagerBlock(SourceManager &SourceMgr) {
       Record.push_back(Inst.getInstantiationLocStart().getRawEncoding());
       Record.push_back(Inst.getInstantiationLocEnd().getRawEncoding());
 
+      // Compute the token length for this macro expansion.
+      unsigned NextOffset = SourceMgr.getNextOffset();
+      SourceManager::sloc_entry_iterator NextSLoc = SLoc;
+      if (++NextSLoc != SLocEnd)
+        NextOffset = NextSLoc->getOffset();
+      Record.push_back(NextOffset - SLoc->getOffset() - 1);
+
       if (SLocInstantiationAbbrv == -1)
         SLocInstantiationAbbrv = CreateSLocInstantiationAbbrev(S);
       S.EmitRecordWithAbbrev(SLocInstantiationAbbrv, Record);