summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/DeclBase.cpp
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-07-07 11:31:19 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2010-07-07 11:31:19 +0000
commit36ea32257974baa08e0d10b4b44ffa1a2118a7b5 (patch)
tree08e6585f46beb9a33cd278305de545cffb271df5 /clang/lib/AST/DeclBase.cpp
parenta22e8148d40b3e68e19182839b2e7031408b4af7 (diff)
downloadbcm5719-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.cpp9
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();
OpenPOWER on IntegriCloud