[clang-tools-extra] [clang-tidy]bugprone-unused-return-value ignore `++` and `--` operator overloading (PR #84922)
Piotr Zegar via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 13 10:26:40 PDT 2024
================
@@ -31,9 +31,20 @@ AST_MATCHER_P(FunctionDecl, isInstantiatedFrom, Matcher<FunctionDecl>,
Finder, Builder);
}
-AST_MATCHER_P(CXXMethodDecl, isOperatorOverloading,
- llvm::SmallVector<OverloadedOperatorKind>, Kinds) {
- return llvm::is_contained(Kinds, Node.getOverloadedOperator());
+constexpr std::initializer_list<OverloadedOperatorKind>
+ AssignmentOverloadedOperatorKinds = {
+ OO_Equal, OO_PlusEqual, OO_MinusEqual, OO_StarEqual,
+ OO_SlashEqual, OO_PercentEqual, OO_CaretEqual, OO_AmpEqual,
+ OO_PipeEqual, OO_LessLessEqual, OO_GreaterGreaterEqual, OO_PlusPlus,
+ OO_MinusMinus};
+
+AST_MATCHER(CXXOperatorCallExpr, isAssignmentOverloadedOperatorCall) {
+ return llvm::is_contained(AssignmentOverloadedOperatorKinds,
+ Node.getOperator());
+}
+AST_MATCHER(CXXMethodDecl, isAssignmentOverloadedOperatorMethod) {
+ return llvm::is_contained(AssignmentOverloadedOperatorKinds,
----------------
PiotrZSL wrote:
getOverloadedOperator belongs to FunctionDecl, change this from Method to Function, and same in calee, in such case you will also cover calls to free standing operators called directly.
https://github.com/llvm/llvm-project/pull/84922
More information about the cfe-commits
mailing list