aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/DeclBase.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-02-17 07:13:24 +0000
committerDouglas Gregor <dgregor@apple.com>2011-02-17 07:13:24 +0000
commit1aa3d81c6e63959ef149489eca42b1520c521af4 (patch)
tree439fad8931715cca0a233425e76335bb43d604d1 /lib/AST/DeclBase.cpp
parentf4a03cc2b022fab0ffac6c65449555c52036dece (diff)
Devirtualize Decl::getBody() and Decl::hasBody().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125731 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/DeclBase.cpp')
-rw-r--r--lib/AST/DeclBase.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index a95ea3f646..110de64d8c 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -429,6 +429,24 @@ DeclContext *Decl::castToDeclContext(const Decl *D) {
}
}
+Stmt *Decl::getBody() const {
+ if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(this))
+ return FD->getBody();
+ if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(this))
+ return MD->getBody();
+ if (const BlockDecl *BD = dyn_cast<BlockDecl>(this))
+ return BD->getBody();
+
+ return 0;
+}
+
+bool Decl::hasBody() const {
+ if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(this))
+ return FD->hasBody();
+
+ return getBody() != 0;
+}
+
SourceLocation Decl::getBodyRBrace() const {
// Special handling of FunctionDecl to avoid de-serializing the body from PCH.
// FunctionDecl stores EndRangeLoc for this purpose.