C++: Include Assignments in exprMayThrow and accept test changes.

This commit is contained in:
Mathias Vorreiter Pedersen
2021-05-07 11:49:25 +02:00
parent 80d41d9fe5
commit 88e6cbaacd
3 changed files with 5 additions and 2 deletions

View File

@@ -127,6 +127,10 @@ predicate exprMayThrow(Expr e) {
convertedExprMayThrow([binOp.getLeftOperand(), binOp.getRightOperand()])
)
or
exists(Assignment assign | assign = e |
convertedExprMayThrow([assign.getLValue(), assign.getRValue()])
)
or
exists(CommaExpr comma | comma = e |
convertedExprMayThrow([comma.getLeftOperand(), comma.getRightOperand()])
)

View File

@@ -16,4 +16,3 @@
| test.cpp:151:9:151:24 | new | This allocation cannot throw. $@ is unnecessary. | test.cpp:152:15:152:18 | { ... } | This catch block |
| test.cpp:199:15:199:35 | new | This allocation cannot throw. $@ is unnecessary. | test.cpp:201:16:201:19 | { ... } | This catch block |
| test.cpp:212:14:212:34 | new | This allocation cannot throw. $@ is unnecessary. | test.cpp:213:34:213:36 | { ... } | This catch block |
| test.cpp:219:9:219:15 | new | This allocation cannot throw. $@ is unnecessary. | test.cpp:220:34:220:36 | { ... } | This catch block |

View File

@@ -216,6 +216,6 @@ void bad_new_catch_baseclass_of_bad_alloc() {
void good_new_catch_exception_in_assignment() {
int* p;
try {
p = new int; // GOOD [FALSE POSITIVE]
p = new int; // GOOD
} catch(const std::bad_alloc&) { }
}