File tree Expand file tree Collapse file tree 1 file changed +3
-4
lines changed
cpp/ql/src/experimental/Best Practices Expand file tree Collapse file tree 1 file changed +3
-4
lines changed Original file line number Diff line number Diff line change @@ -18,9 +18,7 @@ class FreeCall extends FunctionCall {
18
18
FreeCall ( ) { this .getTarget ( ) .hasGlobalName ( "free" ) }
19
19
}
20
20
21
- predicate isAffectedByMacro ( FreeCall fc , BasicBlock bb ) {
22
- fc .isInMacroExpansion ( )
23
- or
21
+ predicate blockContainsPreprocessorBranches ( BasicBlock bb ) {
24
22
exists ( PreprocessorBranch ppb , Location bbLoc , Location ppbLoc |
25
23
bbLoc = bb .( Stmt ) .getLocation ( ) and ppbLoc = ppb .getLocation ( )
26
24
|
40
38
strictcount ( bb .( BlockStmt ) .getAStmt ( ) ) = 1
41
39
) and
42
40
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
44
43
not ( gc instanceof BinaryOperation and not gc instanceof ComparisonOperation ) and
45
44
not exists ( CommaExpr c | c .getAChild * ( ) = fc )
46
45
select gc , "unnecessary NULL check before call to $@" , fc , "free"
You can’t perform that action at this time.
0 commit comments