aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-04-15 18:05:10 +0000
committerDouglas Gregor <dgregor@apple.com>2009-04-15 18:05:10 +0000
commitf60e9918690fcf02974bc1ebecd42c99d561855e (patch)
treec0cee978d4b0ad59d55c7acf821d38133a9fce6e
parent1f0d0133b0e8d1f01f63951ee04927796b34740d (diff)
For source location entries that describe instantiations, encode the
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
-rw-r--r--include/clang/Basic/SourceManager.h2
-rw-r--r--lib/Frontend/PCHReader.cpp4
-rw-r--r--lib/Frontend/PCHWriter.cpp8
3 files changed, 11 insertions, 3 deletions
diff --git a/include/clang/Basic/SourceManager.h b/include/clang/Basic/SourceManager.h
index 217640eaa5..e2c40a31c9 100644
--- a/include/clang/Basic/SourceManager.h
+++ b/include/clang/Basic/SourceManager.h
@@ -635,6 +635,8 @@ public:
return SLocEntryTable[FID.ID];
}
+ unsigned getNextOffset() const { return NextOffset; }
+
private:
friend class SrcMgr::ContentCache; // Used for deserialization.
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp
index 083d0d6082..5a01aee8b8 100644
--- a/lib/Frontend/PCHReader.cpp
+++ b/lib/Frontend/PCHReader.cpp
@@ -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;
}
diff --git a/lib/Frontend/PCHWriter.cpp b/lib/Frontend/PCHWriter.cpp
index 6c3056a1bb..0b5a2a65d1 100644
--- a/lib/Frontend/PCHWriter.cpp
+++ b/lib/Frontend/PCHWriter.cpp
@@ -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);