[clang-tools-extra] [clang-tidy] bugprone-assert-side-effect non-const operator methods (PR #71974)

via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 10 12:49:44 PST 2023


================
@@ -41,6 +41,10 @@ AST_MATCHER_P2(Expr, hasSideEffect, bool, CheckFunctionCalls,
   }
 
   if (const auto *OpCallExpr = dyn_cast<CXXOperatorCallExpr>(E)) {
+    if (const auto *FuncDecl = OpCallExpr->getDirectCallee())
+      if (const auto *MethodDecl = dyn_cast<CXXMethodDecl>(FuncDecl))
+        return !MethodDecl->isConst();
----------------
schenker wrote:

this makes we wonder if we need the comparisons agains the different operator kinds at all, or if we should treat all operators the same, based on their constness.

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


More information about the cfe-commits mailing list