Merge pull request #10510 from geoffw0/staticfn

C++: Fix FPs for cpp/unused-static-function in files that were not extracted completely
This commit is contained in:
Geoffrey White
2022-10-18 14:53:49 +01:00
committed by GitHub
4 changed files with 56 additions and 8 deletions

View File

@@ -13,16 +13,32 @@
import cpp
pragma[noinline]
predicate possiblyIncompleteFile(File f) {
exists(Diagnostic d | d.getFile() = f and d.getSeverity() >= 3)
}
predicate immediatelyReachableFunction(Function f) {
not f.isStatic() or
exists(BlockExpr be | be.getFunction() = f) or
f instanceof MemberFunction or
f instanceof TemplateFunction or
f.getFile() instanceof HeaderFile or
f.getAnAttribute().hasName("constructor") or
f.getAnAttribute().hasName("destructor") or
f.getAnAttribute().hasName("used") or
not f.isStatic()
or
exists(BlockExpr be | be.getFunction() = f)
or
f instanceof MemberFunction
or
f instanceof TemplateFunction
or
f.getFile() instanceof HeaderFile
or
f.getAnAttribute().hasName("constructor")
or
f.getAnAttribute().hasName("destructor")
or
f.getAnAttribute().hasName("used")
or
f.getAnAttribute().hasName("unused")
or
// a compiler error in the same file suggests we may be missing data
possiblyIncompleteFile(f.getFile())
}
predicate immediatelyReachableVariable(Variable v) {

View File

@@ -0,0 +1,4 @@
---
category: minorAnalysis
---
* Fixed false positives from the "Unused static function" (`cpp/unused-static-function`) query in files that had errors during compilation.