C++: Fix false negative.

This commit is contained in:
Mathias Vorreiter Pedersen
2021-05-06 16:57:09 +02:00
parent 7b8a51f995
commit c12837cff0
2 changed files with 3 additions and 2 deletions

View File

@@ -168,13 +168,13 @@ class BadAllocType extends Class {
}
/**
* A catch block that catches a `std::bad_alloc` (or any of its subclasses), or a catch
* A catch block that catches a `std::bad_alloc` (or any of its superclasses), or a catch
* block that catches every exception (i.e., `catch(...)`).
*/
class BadAllocCatchBlock extends CatchBlock {
BadAllocCatchBlock() {
this.getParameter().getUnspecifiedType().stripType() =
any(BadAllocType badAlloc).getADerivedClass*()
any(BadAllocType badAlloc).getABaseClass*()
or
not exists(this.getParameter())
}

View File

@@ -15,3 +15,4 @@
| test.cpp:96:10:96:36 | new[] | This allocation cannot throw. $@ is unnecessary. | test.cpp:97:36:98:3 | { ... } | This catch block |
| 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 |