return getBody(Definition);
}
- /// \brief If the function has a body that is immediately available,
- /// return it.
- Stmt *getBodyIfAvailable() const;
-
/// isThisDeclarationADefinition - Returns whether this specific
/// declaration of the function is also a definition. This does not
/// determine whether the function has been defined (e.g., in a
return 0;
}
-Stmt *FunctionDecl::getBodyIfAvailable() const {
- for (redecl_iterator I = redecls_begin(), E = redecls_end(); I != E; ++I) {
- if (I->Body && !I->Body.isOffset()) {
- return I->Body.get(0);
- }
- }
-
- return 0;
-}
-
void FunctionDecl::setBody(Stmt *B) {
Body = B;
if (B)
// FIXME: We would like to always get the function body, even
// when it needs to be de-serialized, but getting the
// ASTContext here requires significant changes.
- if (Stmt *Body = FD->getBodyIfAvailable()) {
+ if (Stmt *Body = FD->getBody()) {
if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Body))
return CS->getSourceRange();
else
if (FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
FD->print(llvm::errs());
- if (FD->getBodyIfAvailable()) {
+ if (Stmt *Body = FD->getBody()) {
llvm::errs() << '\n';
- FD->getBodyIfAvailable()->viewAST();
+ Body->viewAST();
llvm::errs() << '\n';
}
return;