Skip to content

Commit d22df24

Browse files
authored
Merge pull request #2467 from geoffw0/speedup1
CPP: Speed up isCompiledAsC.
2 parents 198b3b3 + b1c992e commit d22df24

File tree

3 files changed

+15
-15
lines changed

3 files changed

+15
-15
lines changed

cpp/ql/src/Likely Bugs/Underspecified Functions/MistypedFunctionArguments.ql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,18 +84,18 @@ predicate hasZeroParamDecl(Function f) {
8484
}
8585

8686
// True if this file (or header) was compiled as a C file
87-
predicate isCompiledAsC(Function f) {
88-
exists(File file | file.compiledAsC() |
89-
file = f.getFile() or file.getAnIncludedFile+() = f.getFile()
90-
)
87+
predicate isCompiledAsC(File f) {
88+
f.compiledAsC()
89+
or
90+
exists(File src | isCompiledAsC(src) | src.getAnIncludedFile() = f)
9191
}
9292

9393
from FunctionCall fc, Function f, Parameter p
9494
where
9595
f = fc.getTarget() and
9696
p = f.getAParameter() and
9797
hasZeroParamDecl(f) and
98-
isCompiledAsC(f) and
98+
isCompiledAsC(f.getFile()) and
9999
not f.isVarargs() and
100100
not f instanceof BuiltInFunction and
101101
p.getIndex() < fc.getNumberOfArguments() and

cpp/ql/src/Likely Bugs/Underspecified Functions/TooFewArguments.ql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ predicate hasZeroParamDecl(Function f) {
2424
}
2525

2626
// True if this file (or header) was compiled as a C file
27-
predicate isCompiledAsC(Function f) {
28-
exists(File file | file.compiledAsC() |
29-
file = f.getFile() or file.getAnIncludedFile+() = f.getFile()
30-
)
27+
predicate isCompiledAsC(File f) {
28+
f.compiledAsC()
29+
or
30+
exists(File src | isCompiledAsC(src) | src.getAnIncludedFile() = f)
3131
}
3232

3333
from FunctionCall fc, Function f
@@ -36,7 +36,7 @@ where
3636
not f.isVarargs() and
3737
not f instanceof BuiltInFunction and
3838
hasZeroParamDecl(f) and
39-
isCompiledAsC(f) and
39+
isCompiledAsC(f.getFile()) and
4040
// There is an explicit declaration of the function whose parameter count is larger
4141
// than the number of call arguments
4242
exists(FunctionDeclarationEntry fde | fde = f.getADeclarationEntry() |

cpp/ql/src/Likely Bugs/Underspecified Functions/TooManyArguments.ql

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,18 @@ predicate hasZeroParamDecl(Function f) {
2525
}
2626

2727
// True if this file (or header) was compiled as a C file
28-
predicate isCompiledAsC(Function f) {
29-
exists(File file | file.compiledAsC() |
30-
file = f.getFile() or file.getAnIncludedFile+() = f.getFile()
31-
)
28+
predicate isCompiledAsC(File f) {
29+
f.compiledAsC()
30+
or
31+
exists(File src | isCompiledAsC(src) | src.getAnIncludedFile() = f)
3232
}
3333

3434
from FunctionCall fc, Function f
3535
where
3636
f = fc.getTarget() and
3737
not f.isVarargs() and
3838
hasZeroParamDecl(f) and
39-
isCompiledAsC(f) and
39+
isCompiledAsC(f.getFile()) and
4040
exists(f.getBlock()) and
4141
// There must not exist a declaration with the number of parameters
4242
// at least as large as the number of call arguments

0 commit comments

Comments
 (0)