Skip to content

Commit 1cdaaf7

Browse files
committed
C++: Performance fix.
1 parent e319c17 commit 1cdaaf7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

cpp/ql/src/Best Practices/Unused Entities/UnusedStaticFunctions.ql

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@
1313

1414
import cpp
1515

16+
predicate possiblyIncompleteFile(File f) {
17+
exists(Diagnostic d | d.getFile() = f and d.getSeverity() >= 3)
18+
or
19+
exists(ErrorExpr ee | ee.getFile() = f)
20+
}
21+
1622
predicate immediatelyReachableFunction(Function f) {
1723
not f.isStatic()
1824
or
@@ -33,9 +39,7 @@ predicate immediatelyReachableFunction(Function f) {
3339
f.getAnAttribute().hasName("unused")
3440
or
3541
// a compiler error in the same file suggests we may be missing data
36-
exists(Diagnostic d | d.getFile() = f.getFile() and d.getSeverity() >= 3)
37-
or
38-
exists(ErrorExpr ee | ee.getFile() = f.getFile())
42+
possiblyIncompleteFile(f.getFile())
3943
}
4044

4145
predicate immediatelyReachableVariable(Variable v) {

0 commit comments

Comments
 (0)