]> granicus.if.org Git - clang/commitdiff
Do not do the block-specific rewrite when there is no block literals.
authorFariborz Jahanian <fjahanian@apple.com>
Fri, 15 Jan 2010 18:14:52 +0000 (18:14 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Fri, 15 Jan 2010 18:14:52 +0000 (18:14 +0000)
Fixes radar 7546096.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@93519 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Frontend/RewriteObjC.cpp
test/Rewriter/rewrite-extern-c.mm [new file with mode: 0644]

index fc9401d2900177e9b2283427e0407bd84222f159..386d9b0812bbe6ed44f135b606b117ea77285541 100644 (file)
@@ -4043,7 +4043,7 @@ std::string RewriteObjC::SynthesizeBlockDescriptor(std::string DescTag,
 void RewriteObjC::SynthesizeBlockLiterals(SourceLocation FunLocStart,
                                           const char *FunName) {
   // Insert declaration for the function in which block literal is used.
-  if (CurFunctionDeclToDeclareForBlock)
+  if (CurFunctionDeclToDeclareForBlock && !Blocks.empty())
     RewriteBlockLiteralFunctionDecl(CurFunctionDeclToDeclareForBlock);
   // Insert closures that were part of the function.
   for (unsigned i = 0; i < Blocks.size(); i++) {
diff --git a/test/Rewriter/rewrite-extern-c.mm b/test/Rewriter/rewrite-extern-c.mm
new file mode 100644 (file)
index 0000000..1c8e90f
--- /dev/null
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -x objective-c++ -fblocks -rewrite-objc -o - %s
+// radar 7546096
+
+extern "C" {
+        short foo() { } 
+}
+typedef unsigned char Boolean;
+