r293787 - [CodeGen][ObjC] Avoid asserting on block pointer types in

Alex Lorenz via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 1 09:37:28 PST 2017


Author: arphaman
Date: Wed Feb  1 11:37:28 2017
New Revision: 293787

URL: http://llvm.org/viewvc/llvm-project?rev=293787&view=rev
Log:
[CodeGen][ObjC] Avoid asserting on block pointer types in
isPointerZeroInitializable

rdar://30111891

Added:
    cfe/trunk/test/CodeGenObjC/block-ptr-type-crash.m
Modified:
    cfe/trunk/lib/CodeGen/CodeGenTypes.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.cpp?rev=293787&r1=293786&r2=293787&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Wed Feb  1 11:37:28 2017
@@ -738,7 +738,7 @@ CodeGenTypes::getCGRecordLayout(const Re
 }
 
 bool CodeGenTypes::isPointerZeroInitializable(QualType T) {
-  assert (T->isAnyPointerType() && "Invalid type");
+  assert((T->isAnyPointerType() || T->isBlockPointerType()) && "Invalid type");
   return isZeroInitializable(T);
 }
 

Added: cfe/trunk/test/CodeGenObjC/block-ptr-type-crash.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/block-ptr-type-crash.m?rev=293787&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenObjC/block-ptr-type-crash.m (added)
+++ cfe/trunk/test/CodeGenObjC/block-ptr-type-crash.m Wed Feb  1 11:37:28 2017
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -Wno-objc-root-class -fblocks -o /dev/null -triple x86_64-- -emit-llvm %s
+// REQUIRES: asserts
+// Verify there is no assertion.
+
+// rdar://30111891
+
+typedef unsigned long long uint64_t;
+typedef enum AnEnum : uint64_t AnEnum;
+enum AnEnum: uint64_t {
+    AnEnumA
+};
+
+typedef void (^BlockType)();
+ at interface MyClass
+ at end
+ at implementation MyClass
+- (void)_doStuff {
+  struct {
+    int identifier;
+    AnEnum type;
+    BlockType handler;
+  } var = {
+    "hello",
+    AnEnumA,
+    ((void *)0)
+  };
+}
+ at end




More information about the cfe-commits mailing list