File tree 3 files changed +18
-1
lines changed
3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -134,6 +134,8 @@ static bool areEquivalentExpr(const Expr *Left, const Expr *Right) {
134
134
return cast<UnaryOperator>(Left)->getOpcode () ==
135
135
cast<UnaryOperator>(Right)->getOpcode ();
136
136
case Stmt::BinaryOperatorClass:
137
+ if (cast<BinaryOperator>(Left)->isAssignmentOp ())
138
+ return false ;
137
139
return cast<BinaryOperator>(Left)->getOpcode () ==
138
140
cast<BinaryOperator>(Right)->getOpcode ();
139
141
case Stmt::UnaryExprOrTypeTraitExprClass:
Original file line number Diff line number Diff line change @@ -132,7 +132,7 @@ Changes in existing checks
132
132
the vector is a member of a structure.
133
133
134
134
- Fixed a false positive in :doc: `readability-non-const-parameter
135
- <clang-tidy/checks/readability-non-const-parameter>` when the parameter is referenced by an lvalue
135
+ <clang-tidy/checks/readability-non-const-parameter>` when the parameter is referenced by an lvalue.
136
136
137
137
- Fixed a crash in :doc: `readability-const-return-type
138
138
<clang-tidy/checks/readability-const-return-type>` when a pure virtual function
@@ -150,6 +150,9 @@ Changes in existing checks
150
150
Fixed an issue when there was already an initializer in the constructor and
151
151
the check would try to create another initializer for the same member.
152
152
153
+ - Fixed a false positive in :doc: `misc-redundant-expression <clang-tidy/checks/misc-redundant-expression >`
154
+ involving assignments in conditions. This fixes `Issue 35853 <https://github.com/llvm/llvm-project/issues/35853 >`_.
155
+
153
156
Removed checks
154
157
^^^^^^^^^^^^^^
155
158
Original file line number Diff line number Diff line change @@ -831,3 +831,15 @@ struct Bar2 {
831
831
};
832
832
833
833
} // namespace no_crash
834
+
835
+ int TestAssignSideEffect (int i) {
836
+ int k = i;
837
+
838
+ if ((k = k + 1 ) != 1 || (k = k + 1 ) != 2 )
839
+ return 0 ;
840
+
841
+ if ((k = foo (0 )) != 1 || (k = foo (0 )) != 2 )
842
+ return 1 ;
843
+
844
+ return 2 ;
845
+ }
You can’t perform that action at this time.
0 commit comments