]> granicus.if.org Git - clang/commitdiff
Remove Decl::getCompoundBody().
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 7 Jul 2010 11:31:34 +0000 (11:31 +0000)
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>
Wed, 7 Jul 2010 11:31:34 +0000 (11:31 +0000)
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

include/clang/AST/DeclBase.h
lib/AST/DeclBase.cpp
lib/Checker/BugReporter.cpp
lib/Rewrite/RewriteObjC.cpp

index 317db014a6245410ef4b8eee24e4d15f05c548ab..2d2407ffb18d67eeb49b29a056160d5c59ab5578 100644 (file)
@@ -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;
index 96c88c9b346186b51c173c357f78b058b7de790e..9027a131434b9a53e9ee9df91bd413e4b749d19a 100644 (file)
@@ -447,10 +447,6 @@ DeclContext *Decl::castToDeclContext(const Decl *D) {
   }
 }
 
-CompoundStmt* Decl::getCompoundBody() const {
-  return dyn_cast_or_null<CompoundStmt>(getBody());
-}
-
 SourceLocation Decl::getBodyRBrace() const {
   // Special handling of FunctionDecl to avoid de-serializing the body from PCH.
   // FunctionDecl stores EndRangeLoc for this purpose.
index 560953f358ac54e2802816f7ae006e94aa6cdf3a..0422d80ae26d2593c253311236196cfb9e9f7dbd 100644 (file)
@@ -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<CompoundStmt>(PDB.getCodeDecl().getBody()))
       if (!CS->body_empty()) {
         SourceLocation Loc = (*CS->body_begin())->getLocStart();
         rawAddEdge(PathDiagnosticLocation(Loc, PDB.getSourceManager()));
index d6fe4e3b2836fc4722b199c0f15b45256d64e95e..204ec2641569cd87426312ddecc9f911acf280be 100644 (file)
@@ -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<CompoundStmt>(FD->getBody())) {
       CurFunctionDef = FD;
       CurFunctionDeclToDeclareForBlock = FD;
       CollectPropertySetters(Body);