[clang-tools-extra] [clang-tidy] `doesNotMutateObject`: Handle calls to member functions … (PR #94362)

via cfe-commits cfe-commits at lists.llvm.org
Wed Jun 5 07:18:23 PDT 2024


================
@@ -159,11 +263,56 @@ AST_MATCHER_P(DeclRefExpr, doesNotMutateObject, int, Indirections) {
             // The method call cannot mutate our variable.
             continue;
           }
+          if (isLikelyShallowConst(*Method)) {
+            // We still have to check that the object is not modified through
+            // the method's return value (C).
+            const auto MemberParents = Ctx.getParents(*Member);
+            assert(MemberParents.size() == 1);
+            const CallExpr *Call = MemberParents[0].get<CallExpr>();
----------------
EugeneZelenko wrote:

```suggestion
            const auto *Call = MemberParents[0].get<CallExpr>();
```

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


More information about the cfe-commits mailing list