aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/PCHReader.cpp
diff options
context:
space:
mode:
authorSebastian Redl <sebastian.redl@getdesigned.at>2010-07-20 21:50:20 +0000
committerSebastian Redl <sebastian.redl@getdesigned.at>2010-07-20 21:50:20 +0000
commit190faf7c30890479925193b074571e5dc30c3f53 (patch)
tree68e868033220f510b0ddc68e802803a13336de14 /lib/Frontend/PCHReader.cpp
parentc11787fc247ec49f7c651be4b2c1be096cf4970a (diff)
Allow loading source locations from any file in the chain. WIP
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@108942 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/PCHReader.cpp')
-rw-r--r--lib/Frontend/PCHReader.cpp23
1 files changed, 21 insertions, 2 deletions
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp
index b12025fdb8..126036ac4e 100644
--- a/lib/Frontend/PCHReader.cpp
+++ b/lib/Frontend/PCHReader.cpp
@@ -953,6 +953,26 @@ PCHReader::PCHReadResult PCHReader::ReadSourceManagerBlock(PerFileData &F) {
}
}
+/// \brief Get a cursor that's correctly positioned for reading the source
+/// location entry with the given ID.
+llvm::BitstreamCursor &PCHReader::SLocCursorForID(unsigned ID) {
+ assert(ID != 0 && ID <= TotalNumSLocEntries &&
+ "SLocCursorForID should only be called for real IDs.");
+
+ ID -= 1;
+ PerFileData *F = 0;
+ for (unsigned I = 0, N = Chain.size(); I != N; ++I) {
+ F = Chain[N - I - 1];
+ if (ID < F->LocalNumSLocEntries)
+ break;
+ ID -= F->LocalNumSLocEntries;
+ }
+ assert(F && F->LocalNumSLocEntries > ID && "Chain corrupted");
+
+ F->SLocEntryCursor.JumpToBit(F->SLocOffsets[ID]);
+ return F->SLocEntryCursor;
+}
+
/// \brief Read in the source location entry with the given ID.
PCHReader::PCHReadResult PCHReader::ReadSLocEntryRecord(unsigned ID) {
if (ID == 0)
@@ -963,10 +983,9 @@ PCHReader::PCHReadResult PCHReader::ReadSLocEntryRecord(unsigned ID) {
return Failure;
}
- llvm::BitstreamCursor &SLocEntryCursor = Chain[0]->SLocEntryCursor;
+ llvm::BitstreamCursor &SLocEntryCursor = SLocCursorForID(ID);
++NumSLocEntriesRead;
- SLocEntryCursor.JumpToBit(Chain[0]->SLocOffsets[ID - 1]);
unsigned Code = SLocEntryCursor.ReadCode();
if (Code == llvm::bitc::END_BLOCK ||
Code == llvm::bitc::ENTER_SUBBLOCK ||