[clang-tools-extra] [clang-tidy] bugprone-assert-side-effect non-const operator methods (PR #71974)
Piotr Zegar via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 10 13:55:33 PST 2023
================
@@ -41,6 +41,10 @@ AST_MATCHER_P2(Expr, hasSideEffect, bool, CheckFunctionCalls,
}
if (const auto *OpCallExpr = dyn_cast<CXXOperatorCallExpr>(E)) {
+ if (const auto *MethodDecl =
+ dyn_cast_or_null<CXXMethodDecl>(OpCallExpr->getDirectCallee()))
+ return !MethodDecl->isConst();
----------------
PiotrZSL wrote:
On std::shared_ptr yes, but not on std::optional
https://github.com/llvm/llvm-project/pull/71974
More information about the cfe-commits
mailing list