mirror of
https://github.com/github/codeql.git
synced 2026-04-27 09:45:15 +02:00
Merge pull request #5431 from MathiasVP/av-rule-79-use-gvn
C++: Use GVN in AV Rule 79
This commit is contained in:
2
cpp/change-notes/2021-03-17-av-rule-79.md
Normal file
2
cpp/change-notes/2021-03-17-av-rule-79.md
Normal file
@@ -0,0 +1,2 @@
|
||||
lgtm,codescanning
|
||||
* The 'Resource not released in destructor' (cpp/resource-not-released-in-destructor) query has been improved to recognize more releases of resources.
|
||||
@@ -13,6 +13,7 @@
|
||||
|
||||
import cpp
|
||||
import Critical.NewDelete
|
||||
import semmle.code.cpp.valuenumbering.GlobalValueNumbering
|
||||
|
||||
/**
|
||||
* An expression that acquires a resource, and the kind of resource that is acquired. The
|
||||
@@ -98,7 +99,8 @@ private predicate exprReleases(Expr e, Expr released, string kind) {
|
||||
e.(FunctionCall).getTarget().(MemberFunction).getAnOverridingFunction+() = f
|
||||
) and
|
||||
e.(FunctionCall).getArgument(arg) = released and
|
||||
exprReleases(_, exprOrDereference(f.getParameter(arg).getAnAccess()), kind)
|
||||
exprReleases(_,
|
||||
exprOrDereference(globalValueNumber(f.getParameter(arg).getAnAccess()).getAnExpr()), kind)
|
||||
)
|
||||
or
|
||||
exists(Function f, ThisExpr innerThis |
|
||||
@@ -110,7 +112,7 @@ private predicate exprReleases(Expr e, Expr released, string kind) {
|
||||
) and
|
||||
e.(FunctionCall).getQualifier() = exprOrDereference(released) and
|
||||
innerThis.getEnclosingFunction() = f and
|
||||
exprReleases(_, innerThis, kind)
|
||||
exprReleases(_, globalValueNumber(innerThis).getAnExpr(), kind)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user