[PATCH] D129384: [objcxx] Fix `std::addressof` for `id`.

Zoe Carver via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 8 10:48:08 PDT 2022


zoecarver created this revision.
Herald added a project: All.
zoecarver requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

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()))) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D129384.443289.patch
Type: text/x-patch
Size: 1146 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220708/acfc0bb5/attachment.bin>


More information about the cfe-commits mailing list