diff options
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r-- | lib/AST/Decl.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index d733c8c929..5d49d706d7 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -320,7 +320,8 @@ void FunctionDecl::Destroy(ASTContext& C) { } -CompoundStmt *FunctionDecl::getBody(const FunctionDecl *&Definition) const { +CompoundStmt *FunctionDecl::getBody(ASTContext &Context, + const FunctionDecl *&Definition) const { for (const FunctionDecl *FD = this; FD != 0; FD = FD->PreviousDeclaration) { if (FD->Body) { Definition = FD; @@ -331,6 +332,15 @@ CompoundStmt *FunctionDecl::getBody(const FunctionDecl *&Definition) const { return 0; } +CompoundStmt *FunctionDecl::getBodyIfAvailable() const { + for (const FunctionDecl *FD = this; FD != 0; FD = FD->PreviousDeclaration) { + if (FD->Body) + return cast<CompoundStmt>(FD->Body); + } + + return 0; +} + bool FunctionDecl::isMain() const { return getDeclContext()->getLookupContext()->isTranslationUnit() && getIdentifier() && getIdentifier()->isStr("main"); |