]> granicus.if.org Git - clang/commitdiff
Objective-c++ IR gen.
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 27 May 2010 16:05:06 +0000 (16:05 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 27 May 2010 16:05:06 +0000 (16:05 +0000)
Flag synthesized struct decl. as non-empty so
CXX side of ir gen does not skip its Null initialization.
Fixes radar 8027844 for objc++'s collection statement.

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

lib/AST/ASTContext.cpp
test/CodeGenObjCXX/foreach-statement.mm [new file with mode: 0644]

index 851f8d1c68bf14fb7ee6a69c9d413284de31c83a..60d7117bbf96eb7ccad0ee1cdaa5ace1e2c2593a 100644 (file)
@@ -2856,6 +2856,9 @@ QualType ASTContext::getObjCFastEnumerationStateType() {
       Field->setAccess(AS_public);
       ObjCFastEnumerationStateTypeDecl->addDecl(Field);
     }
+    if (getLangOptions().CPlusPlus)
+      if (CXXRecordDecl *CXXRD = dyn_cast<CXXRecordDecl>(ObjCFastEnumerationStateTypeDecl))
+        CXXRD->setEmpty(false);
 
     ObjCFastEnumerationStateTypeDecl->completeDefinition();
   }
diff --git a/test/CodeGenObjCXX/foreach-statement.mm b/test/CodeGenObjCXX/foreach-statement.mm
new file mode 100644 (file)
index 0000000..d0ad5b3
--- /dev/null
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 %s -triple=x86_64-apple-darwin10 -emit-llvm -o - | FileCheck %s
+// rdar: // 8027844
+
+// CHECK: call void @llvm.memset
+
+int main() {
+    id foo;
+    for (id a in foo) {
+    }
+}