This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rG22c7a6ddddec: [objcxx] Fix `std::addressof` for `id`. 
(authored by zoecarver).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129384/new/

https://reviews.llvm.org/D129384

Files:
  clang/lib/Sema/SemaChecking.cpp
  clang/test/SemaObjCXX/unsupported-signature-std-addressof-id.mm


Index: clang/test/SemaObjCXX/unsupported-signature-std-addressof-id.mm
===================================================================
--- /dev/null
+++ clang/test/SemaObjCXX/unsupported-signature-std-addressof-id.mm
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify %s
+// expected-no-diagnostics
+
+namespace std {
+    template <class T>
+    T* addressof(T&);
+}
+
+void f(id obj) {
+    (void)std::addressof(*obj);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===================================================================
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -2413,7 +2413,7 @@
     bool ReturnsPointer = BuiltinID == Builtin::BIaddressof ||
                           BuiltinID == Builtin::BI__addressof;
     if (!(Param->isReferenceType() &&
-          (ReturnsPointer ? Result->isPointerType()
+          (ReturnsPointer ? Result->isAnyPointerType()
                           : Result->isReferenceType()) &&
           Context.hasSameUnqualifiedType(Param->getPointeeType(),
                                          Result->getPointeeType()))) {


Index: clang/test/SemaObjCXX/unsupported-signature-std-addressof-id.mm
===================================================================
--- /dev/null
+++ clang/test/SemaObjCXX/unsupported-signature-std-addressof-id.mm
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -fsyntax-only -fobjc-arc -fobjc-runtime-has-weak -verify %s
+// expected-no-diagnostics
+
+namespace std {
+    template <class T>
+    T* addressof(T&);
+}
+
+void f(id obj) {
+    (void)std::addressof(*obj);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===================================================================
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -2413,7 +2413,7 @@
     bool ReturnsPointer = BuiltinID == Builtin::BIaddressof ||
                           BuiltinID == Builtin::BI__addressof;
     if (!(Param->isReferenceType() &&
-          (ReturnsPointer ? Result->isPointerType()
+          (ReturnsPointer ? Result->isAnyPointerType()
                           : Result->isReferenceType()) &&
           Context.hasSameUnqualifiedType(Param->getPointeeType(),
                                          Result->getPointeeType()))) {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to