C++: Fix false positive

This commit is contained in:
Mathias Vorreiter Pedersen
2020-01-07 13:22:07 +01:00
parent faa9d83567
commit 9a841636dc
3 changed files with 3 additions and 3 deletions

View File

@@ -65,7 +65,8 @@ class BooleanControllingAssignmentInStmt extends BooleanControllingAssignment {
*/
predicate candidateResult(BooleanControllingAssignment ae) {
ae.getRValue().isConstant() and
not ae.isWhitelisted()
not ae.isWhitelisted() and
not ae.getRValue() instanceof StringLiteral
}
/**

View File

@@ -14,4 +14,3 @@
| test.cpp:84:7:84:11 | ... = ... | Use of '=' where '==' may have been intended. |
| test.cpp:92:17:92:22 | ... = ... | Use of '=' where '==' may have been intended. |
| test.cpp:113:6:113:10 | ... = ... | Use of '=' where '==' may have been intended. |
| test.cpp:124:6:124:15 | ... = ... | Use of '=' where '==' may have been intended. |

View File

@@ -121,6 +121,6 @@ void f() {
void f2() {
const char* sz = "abc";
if(sz = "def") { // GOOD [FALSE POSITIVE]: a == comparison with a string literal is probably not the intent here
if(sz = "def") { // GOOD: a == comparison with a string literal is probably not the intent here
}
}