diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-07-07 11:31:19 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-07-07 11:31:19 +0000 |
commit | 36ea32257974baa08e0d10b4b44ffa1a2118a7b5 (patch) | |
tree | 08e6585f46beb9a33cd278305de545cffb271df5 /clang/lib/AST/DeclBase.cpp | |
parent | a22e8148d40b3e68e19182839b2e7031408b4af7 (diff) | |
download | bcm5719-llvm-36ea32257974baa08e0d10b4b44ffa1a2118a7b5.tar.gz bcm5719-llvm-36ea32257974baa08e0d10b4b44ffa1a2118a7b5.zip |
Introduce Decl::hasBody() and FunctionDecl::hasBody() and use them instead of getBody() when we are just checking the existence of a body, to avoid de-serialization of the body from PCH.
Makes de-serialization of the function body even more "lazier".
llvm-svn: 107768
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index 7a104f4d574..0821da3b87d 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -452,6 +452,15 @@ CompoundStmt* Decl::getCompoundBody() const { } SourceLocation Decl::getBodyRBrace() const { + // Special handling of FunctionDecl to avoid de-serializing the body from PCH. + // FunctionDecl stores EndRangeLoc for this purpose. + if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(this)) { + const FunctionDecl *Definition; + if (FD->hasBody(Definition)) + return Definition->getSourceRange().getEnd(); + return SourceLocation(); + } + Stmt *Body = getBody(); if (!Body) return SourceLocation(); |