[PATCH] D20843: ObjC lifetime: pull sugar off when the qualifiers conflict.
Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 1 10:20:58 PDT 2016
This revision was automatically updated to reflect the committed changes.
Closed by commit rL271409: ObjC lifetime: pull sugar off when the qualifiers conflict. (authored by mren).
Changed prior to commit:
http://reviews.llvm.org/D20843?vs=59149&id=59249#toc
Repository:
rL LLVM
http://reviews.llvm.org/D20843
Files:
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/SemaObjC/arc-objc-lifetime-conflict.m
Index: cfe/trunk/test/SemaObjC/arc-objc-lifetime-conflict.m
===================================================================
--- cfe/trunk/test/SemaObjC/arc-objc-lifetime-conflict.m
+++ cfe/trunk/test/SemaObjC/arc-objc-lifetime-conflict.m
@@ -0,0 +1,32 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin11 -fobjc-arc -fobjc-runtime-has-weak %s -emit-llvm -o - | FileCheck %s
+
+// CHECK: bitcast {{.*}} %self_weak_s_w_s
+// CHECK-NEXT: objc_destroyWeak
+// CHECK-NEXT: bitcast {{.*}} %self_strong_w_s
+// CHECK-NEXT: objc_storeStrong
+// CHECK-NEXT: bitcast {{.*}} %self_weak_s
+// CHECK-NEXT: objc_destroyWeak
+// CHECK-NEXT: bitcast {{.*}} %self_weak_s3
+// CHECK-NEXT: objc_destroyWeak
+// CHECK-NEXT: bitcast {{.*}} %self_strong3
+// CHECK-NEXT: objc_storeStrong
+// CHECK-NEXT: bitcast {{.*}} %self_strong2
+// CHECK-NEXT: objc_storeStrong
+// CHECK-NEXT: bitcast {{.*}} %self_strong
+// CHECK-NEXT: objc_storeStrong
+ at interface NSObject
+ at end
+ at interface A : NSObject
+ at end
+ at implementation A
+- (void)test {
+ __attribute__((objc_ownership(strong))) __typeof__(self) self_strong;
+ __attribute__((objc_ownership(strong))) __typeof__(self_strong) self_strong2;
+ __attribute__((objc_ownership(strong))) __typeof__(self_strong2) self_strong3;
+ __attribute__((objc_ownership(weak))) __typeof__(self_strong3) self_weak_s3;
+
+ __attribute__((objc_ownership(weak))) __typeof__(self_strong) self_weak_s;
+ __attribute__((objc_ownership(strong))) __typeof__(self_weak_s) self_strong_w_s;
+ __attribute__((objc_ownership(weak))) __typeof__(self_strong_w_s) self_weak_s_w_s;
+}
+ at end
Index: cfe/trunk/lib/Sema/SemaType.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaType.cpp
+++ cfe/trunk/lib/Sema/SemaType.cpp
@@ -5415,11 +5415,13 @@
}
// Otherwise, if the qualifiers actually conflict, pull sugar off
- // until we reach a type that is directly qualified.
+ // and remove the ObjCLifetime qualifiers.
if (previousLifetime != lifetime) {
- // This should always terminate: the canonical type is
- // qualified, so some bit of sugar must be hiding it.
- while (!underlyingType.Quals.hasObjCLifetime()) {
+ // It's possible to have multiple local ObjCLifetime qualifiers. We
+ // can't stop after we reach a type that is directly qualified.
+ const Type *prevTy = nullptr;
+ while (!prevTy || prevTy != underlyingType.Ty) {
+ prevTy = underlyingType.Ty;
underlyingType = underlyingType.getSingleStepDesugaredType();
}
underlyingType.Quals.removeObjCLifetime();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20843.59249.patch
Type: text/x-patch
Size: 2610 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160601/db1d15cd/attachment.bin>
More information about the cfe-commits
mailing list