aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/PCHReader.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-04-27 01:05:14 +0000
committerChris Lattner <sabre@nondot.org>2009-04-27 01:05:14 +0000
commit6367f6d06308ef29c28d2c1604ded45625caeec9 (patch)
tree3ad53b8faac29f6ab1da4afef1ded95ff4eff521 /lib/Frontend/PCHReader.cpp
parent0558df2da807646e65d4fa290f4e92114af1a746 (diff)
Set up DeclsCursor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70173 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/PCHReader.cpp')
-rw-r--r--lib/Frontend/PCHReader.cpp36
1 files changed, 35 insertions, 1 deletions
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp
index ebfe77ccd7..e9a4f54856 100644
--- a/lib/Frontend/PCHReader.cpp
+++ b/lib/Frontend/PCHReader.cpp
@@ -1683,6 +1683,27 @@ PCHReader::PCHReadResult PCHReader::ReadSourceManagerBlock() {
}
}
+/// ReadBlockAbbrevs - Enter a subblock of the specified BlockID with the
+/// specified cursor. Read the abbreviations that are at the top of the block
+/// and then leave the cursor pointing into the block.
+bool PCHReader::ReadBlockAbbrevs(llvm::BitstreamCursor &Cursor,
+ unsigned BlockID) {
+ if (Cursor.EnterSubBlock(BlockID)) {
+ Error("Malformed block record");
+ return Failure;
+ }
+
+ RecordData Record;
+ while (true) {
+ unsigned Code = Cursor.ReadCode();
+
+ // We expect all abbrevs to be at the start of the block.
+ if (Code != llvm::bitc::DEFINE_ABBREV)
+ return false;
+ Cursor.ReadAbbrevRecord();
+ }
+}
+
void PCHReader::ReadMacroRecord(uint64_t Offset) {
// Keep track of where we are in the stream, then jump back there
// after reading this macro.
@@ -1807,7 +1828,6 @@ PCHReader::ReadPCHBlock() {
if (Code == llvm::bitc::ENTER_SUBBLOCK) {
switch (Stream.ReadSubBlockID()) {
- case pch::DECLS_BLOCK_ID: // Skip decls block (lazily loaded)
case pch::TYPES_BLOCK_ID: // Skip types block (lazily loaded)
default: // Skip unknown content.
if (Stream.SkipBlock()) {
@@ -1816,6 +1836,20 @@ PCHReader::ReadPCHBlock() {
}
break;
+ case pch::DECLS_BLOCK_ID:
+ // We lazily load the decls block, but we want to set up the
+ // DeclsCursor cursor to point into it. Clone our current bitcode
+ // cursor to it, enter the block and read the abbrevs in that block.
+ // With the main cursor, we just skip over it.
+ DeclsCursor = Stream;
+ if (Stream.SkipBlock() || // Skip with the main cursor.
+ // Read the abbrevs.
+ ReadBlockAbbrevs(DeclsCursor, pch::DECLS_BLOCK_ID)) {
+ Error("Malformed block record");
+ return Failure;
+ }
+ break;
+
case pch::PREPROCESSOR_BLOCK_ID:
if (Stream.SkipBlock()) {
Error("Malformed block record");