summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/Decl.cpp11
-rw-r--r--clang/lib/Frontend/PCHReader.cpp11
2 files changed, 16 insertions, 6 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index 5d49d706d7e..8bda32398fc 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -308,8 +308,8 @@ const Expr *VarDecl::getDefinition(const VarDecl *&Def) const {
//===----------------------------------------------------------------------===//
void FunctionDecl::Destroy(ASTContext& C) {
- if (Body)
- Body->Destroy(C);
+ if (Body && Body.isOffset())
+ Body.get(C.getExternalSource())->Destroy(C);
for (param_iterator I=param_begin(), E=param_end(); I!=E; ++I)
(*I)->Destroy(C);
@@ -325,7 +325,7 @@ CompoundStmt *FunctionDecl::getBody(ASTContext &Context,
for (const FunctionDecl *FD = this; FD != 0; FD = FD->PreviousDeclaration) {
if (FD->Body) {
Definition = FD;
- return cast<CompoundStmt>(FD->Body);
+ return cast<CompoundStmt>(FD->Body.get(Context.getExternalSource()));
}
}
@@ -334,8 +334,9 @@ CompoundStmt *FunctionDecl::getBody(ASTContext &Context,
CompoundStmt *FunctionDecl::getBodyIfAvailable() const {
for (const FunctionDecl *FD = this; FD != 0; FD = FD->PreviousDeclaration) {
- if (FD->Body)
- return cast<CompoundStmt>(FD->Body);
+ if (FD->Body && !FD->Body.isOffset()) {
+ return cast<CompoundStmt>(FD->Body.get(0));
+ }
}
return 0;
diff --git a/clang/lib/Frontend/PCHReader.cpp b/clang/lib/Frontend/PCHReader.cpp
index 5ea1f7c6c22..dc8d3fce34f 100644
--- a/clang/lib/Frontend/PCHReader.cpp
+++ b/clang/lib/Frontend/PCHReader.cpp
@@ -140,7 +140,7 @@ void PCHDeclReader::VisitEnumConstantDecl(EnumConstantDecl *ECD) {
void PCHDeclReader::VisitFunctionDecl(FunctionDecl *FD) {
VisitValueDecl(FD);
if (Record[Idx++])
- FD->setBody(cast<CompoundStmt>(Reader.ReadStmt()));
+ FD->setLazyBody(Reader.getStream().GetCurrentBitNo());
FD->setPreviousDeclaration(
cast_or_null<FunctionDecl>(Reader.GetDecl(Record[Idx++])));
FD->setStorageClass((FunctionDecl::StorageClass)Record[Idx++]);
@@ -1880,6 +1880,15 @@ Decl *PCHReader::GetDecl(pch::DeclID ID) {
return ReadDeclRecord(DeclOffsets[Index], Index);
}
+Stmt *PCHReader::GetStmt(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();
+}
+
bool PCHReader::ReadDeclsLexicallyInContext(DeclContext *DC,
llvm::SmallVectorImpl<pch::DeclID> &Decls) {
assert(DC->hasExternalLexicalStorage() &&
OpenPOWER on IntegriCloud