[cfe-commits] r134993 - in /cfe/trunk: lib/AST/Type.cpp test/ARCMT/cxx-checking.mm test/CodeGenObjC/arc.m test/SemaObjC/arc.m test/SemaObjCXX/arc-non-pod.mm

Douglas Gregor dgregor at apple.com
Tue Jul 12 10:28:52 PDT 2011


Author: dgregor
Date: Tue Jul 12 12:28:52 2011
New Revision: 134993

URL: http://llvm.org/viewvc/llvm-project?rev=134993&view=rev
Log:
In ARC mode, consider Objective-C lifetime types (object pointers and
block pointers) that don't have any qualification to be POD types. We
were previously considering them to be non-POD types, because this was
convenient in C++ for is_pod-like traits. However, we now end up
inferring lifetime in such cases (template arguments infer __strong),
so it is not necessary.

Moreover, we want rvalues of object type (which have their lifetime
stripped) to be PODs to allow, e.g., va_arg(arglist, id) to function
properly. Fixes <rdar://problem/9758798>.


Modified:
    cfe/trunk/lib/AST/Type.cpp
    cfe/trunk/test/ARCMT/cxx-checking.mm
    cfe/trunk/test/CodeGenObjC/arc.m
    cfe/trunk/test/SemaObjC/arc.m
    cfe/trunk/test/SemaObjCXX/arc-non-pod.mm

Modified: cfe/trunk/lib/AST/Type.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Type.cpp?rev=134993&r1=134992&r2=134993&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Type.cpp (original)
+++ cfe/trunk/lib/AST/Type.cpp Tue Jul 12 12:28:52 2011
@@ -915,8 +915,6 @@
       return false;
 
     case Qualifiers::OCL_None:
-      if ((*this)->isObjCLifetimeType())
-        return false;
       break;
     }        
   }

Modified: cfe/trunk/test/ARCMT/cxx-checking.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ARCMT/cxx-checking.mm?rev=134993&r1=134992&r2=134993&view=diff
==============================================================================
--- cfe/trunk/test/ARCMT/cxx-checking.mm (original)
+++ cfe/trunk/test/ARCMT/cxx-checking.mm Tue Jul 12 12:28:52 2011
@@ -75,12 +75,12 @@
   int (^bp[2][3])(int);
 };
 
-int check_non_pod_objc_pointer0[__is_pod(id)? -1 : 1];
+int check_non_pod_objc_pointer0[__is_pod(id)? 1 : -1];
 int check_non_pod_objc_pointer1[__is_pod(__strong id)? -1 : 1];
 int check_non_pod_objc_pointer2[__is_pod(__unsafe_unretained id)? 1 : -1];
-int check_non_pod_objc_pointer3[__is_pod(id[2][3])? -1 : 1];
+int check_non_pod_objc_pointer3[__is_pod(id[2][3])? 1 : -1];
 int check_non_pod_objc_pointer4[__is_pod(__unsafe_unretained id[2][3])? 1 : -1];
-int check_non_pod_block0[__is_pod(int (^)(int))? -1 : 1];
+int check_non_pod_block0[__is_pod(int (^)(int))? 1 : -1];
 int check_non_pod_block1[__is_pod(int (^ __unsafe_unretained)(int))? 1 : -1];
 
 struct FlexibleArrayMember0 {

Modified: cfe/trunk/test/CodeGenObjC/arc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc.m?rev=134993&r1=134992&r2=134993&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenObjC/arc.m (original)
+++ cfe/trunk/test/CodeGenObjC/arc.m Tue Jul 12 12:28:52 2011
@@ -1526,3 +1526,17 @@
 // CHECK-NEXT: call void @objc_release(i8* [[T0]])
 // CHECK-NEXT: ret void
 }
+
+// <rdar://problem/9758798>
+// CHECK: define void @test54(i32 %first, ...)
+void test54(int first, ...) {
+  __builtin_va_list arglist;
+  // CHECK: call void @llvm.va_start
+  __builtin_va_start(arglist, first);
+  // CHECK: call i8* @objc_retain
+  id obj = __builtin_va_arg(arglist, id);
+  // CHECK: call void @llvm.va_end
+  __builtin_va_end(arglist);
+  // CHECK: call void @objc_release
+  // CHECK: ret void
+}

Modified: cfe/trunk/test/SemaObjC/arc.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc.m?rev=134993&r1=134992&r2=134993&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/arc.m (original)
+++ cfe/trunk/test/SemaObjC/arc.m Tue Jul 12 12:28:52 2011
@@ -618,3 +618,11 @@
 
   __strong int non_objc_type; // expected-warning {{'__strong' only applies to objective-c object or block pointer types}} 
 }
+
+void test36(int first, ...) {
+  // <rdar://problem/9758798>
+  __builtin_va_list arglist;
+  __builtin_va_start(arglist, first);
+  id obj = __builtin_va_arg(arglist, id);
+  __builtin_va_end(arglist);
+}

Modified: cfe/trunk/test/SemaObjCXX/arc-non-pod.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjCXX/arc-non-pod.mm?rev=134993&r1=134992&r2=134993&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjCXX/arc-non-pod.mm (original)
+++ cfe/trunk/test/SemaObjCXX/arc-non-pod.mm Tue Jul 12 12:28:52 2011
@@ -75,13 +75,14 @@
   int (^bp[2][3])(int);
 };
 
-int check_non_pod_objc_pointer0[__is_pod(id)? -1 : 1];
+int check_non_pod_objc_pointer0[__is_pod(id)? 1 : -1];
 int check_non_pod_objc_pointer1[__is_pod(__strong id)? -1 : 1];
 int check_non_pod_objc_pointer2[__is_pod(__unsafe_unretained id)? 1 : -1];
-int check_non_pod_objc_pointer3[__is_pod(id[2][3])? -1 : 1];
+int check_non_pod_objc_pointer3[__is_pod(id[2][3])? 1 : -1];
 int check_non_pod_objc_pointer4[__is_pod(__unsafe_unretained id[2][3])? 1 : -1];
-int check_non_pod_block0[__is_pod(int (^)(int))? -1 : 1];
+int check_non_pod_block0[__is_pod(int (^)(int))? 1 : -1];
 int check_non_pod_block1[__is_pod(int (^ __unsafe_unretained)(int))? 1 : -1];
+int check_non_pod_block2[__is_pod(int (^ __strong)(int))? -1 : 1];
 
 struct FlexibleArrayMember0 {
   int length;





More information about the cfe-commits mailing list