]> granicus.if.org Git - clang/commitdiff
Added "Decl::getCodyBody()", a virtual method that returns the root AST node (Stmt...
authorTed Kremenek <kremenek@apple.com>
Fri, 20 Jun 2008 21:39:47 +0000 (21:39 +0000)
committerTed Kremenek <kremenek@apple.com>
Fri, 20 Jun 2008 21:39:47 +0000 (21:39 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@52552 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/AST/Decl.h
include/clang/AST/DeclBase.h
include/clang/AST/DeclObjC.h

index bf7efe8043d780cd2ed9541374257e36926e2dbd..a3713d5f3dc7c4a5106aa55c02231135c5727ba2 100644 (file)
@@ -438,6 +438,10 @@ public:
     return getBody(Definition);
   }
 
+  virtual Stmt* getCodeBody() const {
+    return getBody();
+  }
+  
   /// 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
index 55c2e61ff09b36d9c0fd33e975b1a3a19cb70246..69db09c11bef3fc14069656abd11c4306b974a8e 100644 (file)
@@ -195,6 +195,12 @@ public:
       return IdentifierNamespace(IDNS_Tag | IDNS_Ordinary);
     }
   }
+  
+  // getCodeBody - If this Decl represents a declaration for a body of code,
+  //  such as a function or method definition, this method returns the top-level
+  //  Stmt* of that body.  Otherwise this method returns null.
+  virtual Stmt* getCodeBody() const { return 0; }
+  
   // global temp stats (until we have a per-module visitor)
   static void addDeclKind(Kind k);
   static bool CollectingStats(bool Enable = false);
index 093a5cf1a20943e659c8eb0c0bdb3308804cc7e5..ed09eacfd9f437ae1434e5b92af9f47a9677b7eb 100644 (file)
@@ -185,9 +185,11 @@ public:
   ImplementationControl getImplementationControl() const { 
     return ImplementationControl(DeclImplementation); 
   }
-  Stmt *getBody() { return Body; }
-  const Stmt *getBody() const { return Body; }
+
+  Stmt *getBody() const { return Body; }
   void setBody(Stmt *B) { Body = B; }
+  
+  virtual Stmt* getCodeBody() const { return getBody(); }
 
   // Implement isa/cast/dyncast/etc.
   static bool classof(const Decl *D) { return D->getKind() == ObjCMethod; }