diff options
author | Douglas Gregor <dgregor@apple.com> | 2009-04-18 00:07:54 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2009-04-18 00:07:54 +0000 |
commit | 250fc9c859fdeed3f200ae911a7e7ea338f38436 (patch) | |
tree | e296b134cdb17a030e1c368397575060d5b60bcb /lib/AST/Decl.cpp | |
parent | 7297134f128423fce2e88f92421ed135bded7d4e (diff) |
Lazy deserialization of function bodies for PCH files. For the Carbon
"Hello, World!", this takes us from deserializing 6469
statements/expressions down to deserializing 1
statement/expression. It only translated into a 1% improvement on the
Carbon-prefixed 403.gcc, but (a) it's the right thing to do, and (b)
we expect this to matter more once we lazily deserialize identifiers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@69407 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r-- | lib/AST/Decl.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 5d49d706d7..8bda32398f 100644 --- a/lib/AST/Decl.cpp +++ b/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; |