https://github.com/fmayer created https://github.com/llvm/llvm-project/pull/125958
one would assume that `getCanonicalTypeUnqualified` returns an unqualified type, but sadly one would be wrong. the current logic fails for std::optional as implemented in libcxx, because Star and Arrow types mismatch in their const qualification. there are other places in clang that use getCanonicalTypeUnqualified().getUnqualifiedType(). >From 2ae5e2d1bcffae1ba41ee310f68752c7d0d920c7 Mon Sep 17 00:00:00 2001 From: Florian Mayer <fma...@google.com> Date: Wed, 5 Feb 2025 15:25:39 -0800 Subject: [PATCH] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20initia?= =?UTF-8?q?l=20version?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Created using spr 1.3.4 --- .../FlowSensitive/SmartPointerAccessorCaching.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/clang/lib/Analysis/FlowSensitive/SmartPointerAccessorCaching.cpp b/clang/lib/Analysis/FlowSensitive/SmartPointerAccessorCaching.cpp index c58bd309545dbf8..576a0ca15941540 100644 --- a/clang/lib/Analysis/FlowSensitive/SmartPointerAccessorCaching.cpp +++ b/clang/lib/Analysis/FlowSensitive/SmartPointerAccessorCaching.cpp @@ -41,7 +41,8 @@ bool hasSmartPointerClassShape(const CXXRecordDecl &RD, bool &HasGet, HasStar = true; StarReturnType = MD->getReturnType() .getNonReferenceType() - ->getCanonicalTypeUnqualified(); + ->getCanonicalTypeUnqualified() + .getUnqualifiedType(); } break; case OO_Arrow: @@ -49,7 +50,8 @@ bool hasSmartPointerClassShape(const CXXRecordDecl &RD, bool &HasGet, HasArrow = true; ArrowReturnType = MD->getReturnType() ->getPointeeType() - ->getCanonicalTypeUnqualified(); + ->getCanonicalTypeUnqualified() + .getUnqualifiedType(); } break; case OO_None: { @@ -61,14 +63,16 @@ bool hasSmartPointerClassShape(const CXXRecordDecl &RD, bool &HasGet, HasGet = true; GetReturnType = MD->getReturnType() ->getPointeeType() - ->getCanonicalTypeUnqualified(); + ->getCanonicalTypeUnqualified() + .getUnqualifiedType(); } } else if (II->isStr("value")) { if (MD->getReturnType()->isReferenceType()) { HasValue = true; ValueReturnType = MD->getReturnType() .getNonReferenceType() - ->getCanonicalTypeUnqualified(); + ->getCanonicalTypeUnqualified() + .getUnqualifiedType(); } } } break; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits