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 {
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 |
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 )
4645select gc , "unnecessary NULL check before call to $@" , fc , "free"
You can’t perform that action at this time.
0 commit comments