API fix: All "bodies" for functions, Objective-C methods, blocks, are assumed to
be CompoundStmts. I think this is a valid assumption, and felt that the API
should reflect it. Others please validate this assumption to make sure I didn't
break anything.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66814 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/Driver/RewriteBlocks.cpp b/Driver/RewriteBlocks.cpp
index 7eacc0a..2672d32 100644
--- a/Driver/RewriteBlocks.cpp
+++ b/Driver/RewriteBlocks.cpp
@@ -1076,9 +1076,9 @@
// 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);
diff --git a/Driver/RewriteObjC.cpp b/Driver/RewriteObjC.cpp
index c4f6762..1e2cac3 100644
--- a/Driver/RewriteObjC.cpp
+++ b/Driver/RewriteObjC.cpp
@@ -4426,11 +4426,13 @@
// 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;
@@ -4444,11 +4446,13 @@
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;