[PATCH] D20113: Fix mangled name of method with ns_consumed parameters.

Sylvain Defresne via cfe-commits cfe-commits at lists.llvm.org
Tue May 10 09:45:22 PDT 2016


sdefresne created this revision.
sdefresne added a reviewer: rjmccall.
sdefresne added a subscriber: cfe-commits.

When a function/method use a parameter with "ns_consumed" attribute,
ensure that the mangled name is the same whether -fobjc-arc is used
or not.

Since "ns_consumed" attribute is generally used to inform ARC that
a function/method does sink the reference, it mean it is usually
implemented in a compilation unit compiled without -fobjc-arc but
used form a compilation unit compiled with it.

Originally found while trying to use "ns_consumed" attribute in an
Objective-C++ file in Chromium (http://crbug.com/599980) where it
caused a linker error.

Regression introduced by revision 262278 (previously the attribute
was incorrectly not part of the mangled name).

http://reviews.llvm.org/D20113

Files:
  lib/Sema/SemaType.cpp
  test/CodeGenObjCXX/arc-mangle.mm
  test/CodeGenObjCXX/mangle.mm

Index: test/CodeGenObjCXX/mangle.mm
===================================================================
--- test/CodeGenObjCXX/mangle.mm
+++ test/CodeGenObjCXX/mangle.mm
@@ -113,3 +113,10 @@
 
 // CHECK-LABEL: define void @_Z19parameterized_test3P13Parameterized
 void parameterized_test3(Parameterized *p) {}
+
+// CHECK-LABEL: define {{.*}}void @_Z1fU11ns_consumedP11objc_object
+void f(id __attribute((ns_consumed))) {}
+// CHECK-LABEL: define {{.*}}void @_Z1fPFP11objc_objectU11ns_consumedS0_S0_E
+void f(id (*fn)(__attribute__((ns_consumed)) id, id)) {}
+// CHECK-LABEL: define {{.*}}void @_Z1fPFP11objc_objectS0_U11ns_consumedS0_E
+void f(__strong id (*fn)(id, __attribute__((ns_consumed)) id)) {}
Index: test/CodeGenObjCXX/arc-mangle.mm
===================================================================
--- test/CodeGenObjCXX/arc-mangle.mm
+++ test/CodeGenObjCXX/arc-mangle.mm
@@ -18,6 +18,8 @@
 void f(const __unsafe_unretained id *) {}
 // CHECK-LABEL: define {{.*}}void @_Z1fPFU19ns_returns_retainedP11objc_objectvE
 void f(__attribute__((ns_returns_retained)) id (*fn)()) {}
+// CHECK-LABEL: define {{.*}}void @_Z1fU11ns_consumedP11objc_object
+void f(id __attribute((ns_consumed))) {}
 // CHECK-LABEL: define {{.*}}void @_Z1fPFP11objc_objectU11ns_consumedS0_S0_E
 void f(id (*fn)(__attribute__((ns_consumed)) id, id)) {}
 // CHECK-LABEL: define {{.*}}void @_Z1fPFP11objc_objectS0_U11ns_consumedS0_E
Index: lib/Sema/SemaType.cpp
===================================================================
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -4229,7 +4229,7 @@
             }
           }
 
-          if (LangOpts.ObjCAutoRefCount && Param->hasAttr<NSConsumedAttr>()) {
+          if (Param->hasAttr<NSConsumedAttr>()) {
             ExtParameterInfos[i] = ExtParameterInfos[i].withIsConsumed(true);
             HasAnyInterestingExtParameterInfos = true;
           }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D20113.56735.patch
Type: text/x-patch
Size: 1893 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160510/c403ddee/attachment.bin>


More information about the cfe-commits mailing list