// definitions using the same code.
RewriteFunctionProtoType(FD->getType(), FD);
- if (Stmt *Body = FD->getBody()) {
+ if (CompoundStmt *Body = FD->getBody()) {
CurFunctionDef = FD;
- FD->setBody(RewriteFunctionBody(Body));
+ FD->setBody(cast_or_null<CompoundStmt>(RewriteFunctionBody(Body)));
// This synthesizes and inserts the block "impl" struct, invoke function,
// and any copy/dispose helper functions.
InsertBlockLiteralsWithinFunction(FD);
// definitions using the same code.
RewriteBlocksInFunctionProtoType(FD->getType(), FD);
- if (Stmt *Body = FD->getBody()) {
+ if (CompoundStmt *Body = FD->getBody()) {
CurFunctionDef = FD;
CollectPropertySetters(Body);
CurrentBody = Body;
- FD->setBody(RewriteFunctionBodyOrGlobalInitializer(Body));
+ Body =
+ cast_or_null<CompoundStmt>(RewriteFunctionBodyOrGlobalInitializer(Body));
+ FD->setBody(Body);
CurrentBody = 0;
if (PropParentMap) {
delete PropParentMap;
return;
}
if (ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) {
- if (Stmt *Body = MD->getBody()) {
+ if (CompoundStmt *Body = MD->getBody()) {
CurMethodDef = MD;
CollectPropertySetters(Body);
CurrentBody = Body;
- MD->setBody(RewriteFunctionBodyOrGlobalInitializer(Body));
+ Body =
+ cast_or_null<CompoundStmt>(RewriteFunctionBodyOrGlobalInitializer(Body));
+ MD->setBody(Body);
CurrentBody = 0;
if (PropParentMap) {
delete PropParentMap;
/// function. The variant that accepts a FunctionDecl pointer will
/// set that function declaration to the actual declaration
/// containing the body (if there is one).
- Stmt *getBody(const FunctionDecl *&Definition) const;
+ CompoundStmt *getBody(const FunctionDecl *&Definition) const;
- virtual Stmt *getBody() const {
+ virtual CompoundStmt *getBody() const {
const FunctionDecl* Definition;
return getBody(Definition);
}
/// previous definition); for that information, use getBody.
bool isThisDeclarationADefinition() const { return Body != 0; }
- void setBody(Stmt *B) { Body = B; }
+ void setBody(CompoundStmt *B) { Body = (Stmt*) B; }
/// Whether this function is virtual, either by explicit marking, or by
/// overriding a virtual function. Only valid on C++ member functions.
SourceLocation getCaretLocation() const { return getLocation(); }
- Stmt *getBody() const { return Body; }
- void setBody(Stmt *B) { Body = B; }
+ CompoundStmt *getBody() const { return (CompoundStmt*) Body; }
+ void setBody(CompoundStmt *B) { Body = (Stmt*) B; }
void setArgs(ParmVarDecl **args, unsigned numargs) {
Args.clear();
class LinkageSpecDecl;
class BlockDecl;
class DeclarationName;
+class CompoundStmt;
/// Decl - This represents one declaration (or definition), e.g. a variable,
/// typedef, function, struct, etc.
// getBody - 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* getBody() const { return 0; }
+ virtual CompoundStmt* getBody() const { return 0; }
// global temp stats (until we have a per-module visitor)
static void addDeclKind(Kind k);
}
-Stmt *FunctionDecl::getBody(const FunctionDecl *&Definition) const {
+CompoundStmt *FunctionDecl::getBody(const FunctionDecl *&Definition) const {
for (const FunctionDecl *FD = this; FD != 0; FD = FD->PreviousDeclaration) {
if (FD->Body) {
Definition = FD;
- return FD->Body;
+ return cast<CompoundStmt>(FD->Body);
}
}
Decl *dcl = static_cast<Decl *>(D);
Stmt *Body = static_cast<Stmt*>(BodyArg.release());
if (FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(dcl)) {
- FD->setBody(Body);
+ FD->setBody(cast<CompoundStmt>(Body));
assert(FD == getCurFunctionDecl() && "Function parsing confused");
} else if (ObjCMethodDecl *MD = dyn_cast_or_null<ObjCMethodDecl>(dcl)) {
assert(MD == getCurMethodDecl() && "Method parsing confused");
- MD->setBody((Stmt*)Body);
+ MD->setBody(cast<CompoundStmt>(Body));
} else {
Body->Destroy(Context);
return 0;