[cfe-commits] r52552 - in /cfe/trunk/include/clang/AST: Decl.h DeclBase.h DeclObjC.h

Ted Kremenek kremenek at apple.com
Fri Jun 20 14:39:47 PDT 2008


Author: kremenek
Date: Fri Jun 20 16:39:47 2008
New Revision: 52552

URL: http://llvm.org/viewvc/llvm-project?rev=52552&view=rev
Log:
Added "Decl::getCodyBody()", a virtual method that returns the root AST node (Stmt*) that the Decl wraps (if any).  Currently this only returns a non-null value for FunctionDecl and ObjCMethodDecl.

Modified:
    cfe/trunk/include/clang/AST/Decl.h
    cfe/trunk/include/clang/AST/DeclBase.h
    cfe/trunk/include/clang/AST/DeclObjC.h

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=52552&r1=52551&r2=52552&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Fri Jun 20 16:39:47 2008
@@ -438,6 +438,10 @@
     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

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=52552&r1=52551&r2=52552&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Fri Jun 20 16:39:47 2008
@@ -195,6 +195,12 @@
       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);

Modified: cfe/trunk/include/clang/AST/DeclObjC.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclObjC.h?rev=52552&r1=52551&r2=52552&view=diff

==============================================================================
--- cfe/trunk/include/clang/AST/DeclObjC.h (original)
+++ cfe/trunk/include/clang/AST/DeclObjC.h Fri Jun 20 16:39:47 2008
@@ -185,9 +185,11 @@
   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; }





More information about the cfe-commits mailing list