From: Argyrios Kyrtzidis Date: Wed, 7 Jul 2010 11:31:34 +0000 (+0000) Subject: Remove Decl::getCompoundBody(). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5f1bfc10a12d9759444eb433f52a85d2e0058967;p=clang Remove Decl::getCompoundBody(). This has 2 (slight) advantages: -Make explicit at getBody()'s callsite that we expect/handle only CompoundStmt and not CXXTryStmt. -Better tracking of Decl::getBody()'s callsites. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@107771 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h index 317db014a6..2d2407ffb1 100644 --- a/include/clang/AST/DeclBase.h +++ b/include/clang/AST/DeclBase.h @@ -492,9 +492,6 @@ public: /// code, such as a function or method definition. virtual bool hasBody() const { return getBody() != 0; } - /// getCompoundBody - Returns getBody(), dyn_casted to a CompoundStmt. - CompoundStmt* getCompoundBody() const; - /// getBodyRBrace - Gets the right brace of the body, if a body exists. /// This works whether the body is a CompoundStmt or a CXXTryStmt. SourceLocation getBodyRBrace() const; diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 96c88c9b34..9027a13143 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -447,10 +447,6 @@ DeclContext *Decl::castToDeclContext(const Decl *D) { } } -CompoundStmt* Decl::getCompoundBody() const { - return dyn_cast_or_null(getBody()); -} - SourceLocation Decl::getBodyRBrace() const { // Special handling of FunctionDecl to avoid de-serializing the body from PCH. // FunctionDecl stores EndRangeLoc for this purpose. diff --git a/lib/Checker/BugReporter.cpp b/lib/Checker/BugReporter.cpp index 560953f358..0422d80ae2 100644 --- a/lib/Checker/BugReporter.cpp +++ b/lib/Checker/BugReporter.cpp @@ -925,7 +925,7 @@ public: // statement (if it doesn't already exist). // FIXME: Should handle CXXTryStmt if analyser starts supporting C++. if (const CompoundStmt *CS = - PDB.getCodeDecl().getCompoundBody()) + dyn_cast_or_null(PDB.getCodeDecl().getBody())) if (!CS->body_empty()) { SourceLocation Loc = (*CS->body_begin())->getLocStart(); rawAddEdge(PathDiagnosticLocation(Loc, PDB.getSourceManager())); diff --git a/lib/Rewrite/RewriteObjC.cpp b/lib/Rewrite/RewriteObjC.cpp index d6fe4e3b28..204ec26415 100644 --- a/lib/Rewrite/RewriteObjC.cpp +++ b/lib/Rewrite/RewriteObjC.cpp @@ -5651,7 +5651,7 @@ void RewriteObjC::HandleDeclInMainFile(Decl *D) { RewriteBlocksInFunctionProtoType(FD->getType(), FD); // FIXME: If this should support Obj-C++, support CXXTryStmt - if (CompoundStmt *Body = FD->getCompoundBody()) { + if (CompoundStmt *Body = dyn_cast_or_null(FD->getBody())) { CurFunctionDef = FD; CurFunctionDeclToDeclareForBlock = FD; CollectPropertySetters(Body);