Skip to content

Commit 2068591

Browse files
committed
C++: Silence ql-for-ql warning
1 parent b581723 commit 2068591

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

cpp/ql/src/experimental/Best Practices/GuardedFree.ql

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@ class FreeCall extends FunctionCall {
1818
FreeCall() { this.getTarget().hasGlobalName("free") }
1919
}
2020

21-
predicate isAffectedByMacro(FreeCall fc, BasicBlock bb) {
22-
fc.isInMacroExpansion()
23-
or
21+
predicate blockContainsPreprocessorBranches(BasicBlock bb) {
2422
exists(PreprocessorBranch ppb, Location bbLoc, Location ppbLoc |
2523
bbLoc = bb.(Stmt).getLocation() and ppbLoc = ppb.getLocation()
2624
|
@@ -40,7 +38,8 @@ where
4038
strictcount(bb.(BlockStmt).getAStmt()) = 1
4139
) and
4240
strictcount(BasicBlock bb2 | gc.ensuresEq(_, 0, bb2, _) | bb2) = 1 and
43-
not isAffectedByMacro(fc, bb) and
41+
not fc.isInMacroExpansion() and
42+
not blockContainsPreprocessorBranches(bb) and
4443
not (gc instanceof BinaryOperation and not gc instanceof ComparisonOperation) and
4544
not exists(CommaExpr c | c.getAChild*() = fc)
4645
select gc, "unnecessary NULL check before call to $@", fc, "free"

0 commit comments

Comments
 (0)