[clang] [clang-tools-extra] [clang][Analysis] Handle const-qualified pointer refs in `ExprMutationAnalyzer` (PR #190421)

Baranov Victor via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 14 07:21:35 PDT 2026


================
@@ -145,9 +145,20 @@ class ExprPointeeResolve {
       // explicit cast will be checked in `findPointeeToNonConst`
       const CastKind kind = ICE->getCastKind();
       if (kind == CK_LValueToRValue || kind == CK_DerivedToBase ||
-          kind == CK_UncheckedDerivedToBase ||
-          (kind == CK_NoOp && (ICE->getType() == ICE->getSubExpr()->getType())))
+          kind == CK_UncheckedDerivedToBase)
         return resolveExpr(ICE->getSubExpr());
+      if (kind == CK_NoOp) {
+        // Binding `T *` to `T *const &` only adds top-level qualifiers to the
+        // pointer object, so this `CK_NoOp` still refers to the same pointer.
+        const QualType CastType =
+            ICE->getType().getLocalUnqualifiedType().getCanonicalType();
----------------
vbvictor wrote:

ditto below

https://github.com/llvm/llvm-project/pull/190421


More information about the cfe-commits mailing list