From 75627ad8baf9f623953042a3204570a8d211ee94 Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Sun, 12 Feb 2012 04:48:45 +0000 Subject: Fix the rewriter that broke with r149987. r149987 changed the way parsing happens inside an @implementation; it aggregates the declarations inside and reports them together as a DeclGroup. This had the side effect that function declarations were reported together with their definition, while the rewriter expected for function declarations to be reported immediately to the consumer and thus not have a body. Fix this by having the rewriter actually check with isThisDeclarationADefinition() to make sure the body comes from the current decl before rewriting it. llvm-svn: 150325 --- clang/lib/Rewrite/RewriteObjC.cpp | 3 +++ 1 file changed, 3 insertions(+) (limited to 'clang/lib/Rewrite/RewriteObjC.cpp') diff --git a/clang/lib/Rewrite/RewriteObjC.cpp b/clang/lib/Rewrite/RewriteObjC.cpp index 50181126997..6e8789f6dbc 100644 --- a/clang/lib/Rewrite/RewriteObjC.cpp +++ b/clang/lib/Rewrite/RewriteObjC.cpp @@ -4922,6 +4922,9 @@ void RewriteObjC::HandleDeclInMainFile(Decl *D) { // definitions using the same code. RewriteBlocksInFunctionProtoType(FD->getType(), FD); + if (!FD->isThisDeclarationADefinition()) + break; + // FIXME: If this should support Obj-C++, support CXXTryStmt if (CompoundStmt *Body = dyn_cast_or_null(FD->getBody())) { CurFunctionDef = FD; -- cgit v1.2.3