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

Differential Revision: https://reviews.llvm.org/D129384
This commit is contained in:
zoecarver 2022-07-08 10:42:29 -07:00
parent 23c7328bad
commit 22c7a6dddd
2 changed files with 12 additions and 1 deletions

View File

@ -2413,7 +2413,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID,
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()))) {

View File

@ -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);
}