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.

llvm-svn: 52552
This commit is contained in:
Ted Kremenek 2008-06-20 21:39:47 +00:00
parent e4645615d3
commit d50c7a4b0d
3 changed files with 14 additions and 2 deletions

View 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

View 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);

View 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; }