mirror of
https://github.com/github/codeql.git
synced 2026-04-22 15:25:18 +02:00
C++: Address false positive results in template instantiations.
This commit is contained in:
@@ -232,6 +232,7 @@ predicate nullCheckInThrowingNew(NewOrNewArrayExpr newExpr, GuardCondition guard
|
||||
from NewOrNewArrayExpr newExpr, Element element, string msg, string elementString
|
||||
where
|
||||
not newExpr.isFromUninstantiatedTemplate(_) and
|
||||
not newExpr.isFromTemplateInstantiation(_) and
|
||||
(
|
||||
noThrowInTryBlock(newExpr, element) and
|
||||
msg = "This allocation cannot throw. $@ is unnecessary." and
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
| test.cpp:93:15:93:41 | new[] | This allocation cannot throw. $@ is unnecessary. | test.cpp:97:36:98:3 | { ... } | This catch block |
|
||||
| test.cpp:96:10:96:36 | new[] | This allocation cannot throw. $@ is unnecessary. | test.cpp:97:36:98:3 | { ... } | This catch block |
|
||||
| test.cpp:160:9:160:24 | new | This allocation cannot throw. $@ is unnecessary. | test.cpp:161:15:161:18 | { ... } | This catch block |
|
||||
| test.cpp:178:12:178:25 | new | This allocation cannot throw. $@ is unnecessary. | test.cpp:179:17:181:3 | { ... } | This catch block |
|
||||
| test.cpp:229:15:229:35 | new | This allocation cannot throw. $@ is unnecessary. | test.cpp:231:16:231:19 | { ... } | This catch block |
|
||||
| test.cpp:242:14:242:34 | new | This allocation cannot throw. $@ is unnecessary. | test.cpp:243:34:243:36 | { ... } | This catch block |
|
||||
| test.cpp:276:17:276:31 | new[] | This allocation cannot return null. $@ is unnecessary. | test.cpp:277:8:277:12 | ! ... | This check |
|
||||
|
||||
@@ -175,7 +175,7 @@ template<typename F> F *test_template_platement_new() {
|
||||
char buffer[1024];
|
||||
|
||||
try {
|
||||
return new (buffer) F; // GOOD: `F` constructor might throw (when `F` is `Foo`) [FALSE POSITIVE]
|
||||
return new (buffer) F; // GOOD: `F` constructor might throw (when `F` is `Bar`)
|
||||
} catch (...) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user