diff options
author | Chris Lattner <sabre@nondot.org> | 2009-04-27 05:58:23 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2009-04-27 05:58:23 +0000 |
commit | da93061f56d5820725b01a140879d047554e7d32 (patch) | |
tree | d43bf5cac925329ed6821fe702e3615849d7227e /lib/Frontend/PCHReader.cpp | |
parent | 887e2b375fc5e00084ec7bf3dd050c2ca399a6d2 (diff) |
read all decls (and attributes and stmts/exprs referenced by the decl)
from the DeclsCursor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@70190 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/PCHReader.cpp')
-rw-r--r-- | lib/Frontend/PCHReader.cpp | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index 4ec2a3a18a..4f60db9e68 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/lib/Frontend/PCHReader.cpp @@ -66,7 +66,11 @@ PCHReader::PCHReader(Preprocessor &PP, ASTContext &Context) PCHReader::~PCHReader() {} -Expr *PCHReader::ReadExpr() { +Expr *PCHReader::ReadDeclExpr() { + return dyn_cast_or_null<Expr>(ReadStmt(DeclsCursor)); +} + +Expr *PCHReader::ReadTypeExpr() { return dyn_cast_or_null<Expr>(ReadStmt(Stream)); } @@ -1167,7 +1171,7 @@ QualType PCHReader::ReadTypeRecord(uint64_t Offset) { QualType ElementType = GetType(Record[0]); ArrayType::ArraySizeModifier ASM = (ArrayType::ArraySizeModifier)Record[1]; unsigned IndexTypeQuals = Record[2]; - return Context.getVariableArrayType(ElementType, ReadExpr(), + return Context.getVariableArrayType(ElementType, ReadTypeExpr(), ASM, IndexTypeQuals); } @@ -1220,7 +1224,7 @@ QualType PCHReader::ReadTypeRecord(uint64_t Offset) { return Context.getTypeDeclType(cast<TypedefDecl>(GetDecl(Record[0]))); case pch::TYPE_TYPEOF_EXPR: - return Context.getTypeOfExprType(ReadExpr()); + return Context.getTypeOfExprType(ReadTypeExpr()); case pch::TYPE_TYPEOF: { if (Record.size() != 1) { @@ -1337,12 +1341,10 @@ Decl *PCHReader::GetDecl(pch::DeclID ID) { /// source each time it is called, and is meant to be used via a /// LazyOffsetPtr (which is used by Decls for the body of functions, etc). Stmt *PCHReader::GetDeclStmt(uint64_t Offset) { - // Keep track of where we are in the stream, then jump back there - // after reading this declaration. - SavedStreamPosition SavedPosition(Stream); - - Stream.JumpToBit(Offset); - return ReadStmt(Stream); + // Since we know tha this statement is part of a decl, make sure to use the + // decl cursor to read it. + DeclsCursor.JumpToBit(Offset); + return ReadStmt(DeclsCursor); } bool PCHReader::ReadDeclsLexicallyInContext(DeclContext *DC, @@ -1711,13 +1713,13 @@ std::string PCHReader::ReadString(const RecordData &Record, unsigned &Idx) { /// \brief Reads attributes from the current stream position. Attr *PCHReader::ReadAttributes() { - unsigned Code = Stream.ReadCode(); + unsigned Code = DeclsCursor.ReadCode(); assert(Code == llvm::bitc::UNABBREV_RECORD && "Expected unabbreviated record"); (void)Code; RecordData Record; unsigned Idx = 0; - unsigned RecCode = Stream.ReadRecord(Code, Record); + unsigned RecCode = DeclsCursor.ReadRecord(Code, Record); assert(RecCode == pch::DECL_ATTR && "Expected attribute record"); (void)RecCode; |