mirror of
https://github.com/github/codeql.git
synced 2025-12-22 19:56:32 +01:00
Merge pull request #2467 from geoffw0/speedup1
CPP: Speed up isCompiledAsC.
This commit is contained in:
@@ -84,10 +84,10 @@ predicate hasZeroParamDecl(Function f) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// True if this file (or header) was compiled as a C file
|
// True if this file (or header) was compiled as a C file
|
||||||
predicate isCompiledAsC(Function f) {
|
predicate isCompiledAsC(File f) {
|
||||||
exists(File file | file.compiledAsC() |
|
f.compiledAsC()
|
||||||
file = f.getFile() or file.getAnIncludedFile+() = f.getFile()
|
or
|
||||||
)
|
exists(File src | isCompiledAsC(src) | src.getAnIncludedFile() = f)
|
||||||
}
|
}
|
||||||
|
|
||||||
from FunctionCall fc, Function f, Parameter p
|
from FunctionCall fc, Function f, Parameter p
|
||||||
@@ -95,7 +95,7 @@ where
|
|||||||
f = fc.getTarget() and
|
f = fc.getTarget() and
|
||||||
p = f.getAParameter() and
|
p = f.getAParameter() and
|
||||||
hasZeroParamDecl(f) and
|
hasZeroParamDecl(f) and
|
||||||
isCompiledAsC(f) and
|
isCompiledAsC(f.getFile()) and
|
||||||
not f.isVarargs() and
|
not f.isVarargs() and
|
||||||
not f instanceof BuiltInFunction and
|
not f instanceof BuiltInFunction and
|
||||||
p.getIndex() < fc.getNumberOfArguments() and
|
p.getIndex() < fc.getNumberOfArguments() and
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ predicate hasZeroParamDecl(Function f) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// True if this file (or header) was compiled as a C file
|
// True if this file (or header) was compiled as a C file
|
||||||
predicate isCompiledAsC(Function f) {
|
predicate isCompiledAsC(File f) {
|
||||||
exists(File file | file.compiledAsC() |
|
f.compiledAsC()
|
||||||
file = f.getFile() or file.getAnIncludedFile+() = f.getFile()
|
or
|
||||||
)
|
exists(File src | isCompiledAsC(src) | src.getAnIncludedFile() = f)
|
||||||
}
|
}
|
||||||
|
|
||||||
from FunctionCall fc, Function f
|
from FunctionCall fc, Function f
|
||||||
@@ -36,7 +36,7 @@ where
|
|||||||
not f.isVarargs() and
|
not f.isVarargs() and
|
||||||
not f instanceof BuiltInFunction and
|
not f instanceof BuiltInFunction and
|
||||||
hasZeroParamDecl(f) and
|
hasZeroParamDecl(f) and
|
||||||
isCompiledAsC(f) and
|
isCompiledAsC(f.getFile()) and
|
||||||
// There is an explicit declaration of the function whose parameter count is larger
|
// There is an explicit declaration of the function whose parameter count is larger
|
||||||
// than the number of call arguments
|
// than the number of call arguments
|
||||||
exists(FunctionDeclarationEntry fde | fde = f.getADeclarationEntry() |
|
exists(FunctionDeclarationEntry fde | fde = f.getADeclarationEntry() |
|
||||||
|
|||||||
@@ -25,10 +25,10 @@ predicate hasZeroParamDecl(Function f) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// True if this file (or header) was compiled as a C file
|
// True if this file (or header) was compiled as a C file
|
||||||
predicate isCompiledAsC(Function f) {
|
predicate isCompiledAsC(File f) {
|
||||||
exists(File file | file.compiledAsC() |
|
f.compiledAsC()
|
||||||
file = f.getFile() or file.getAnIncludedFile+() = f.getFile()
|
or
|
||||||
)
|
exists(File src | isCompiledAsC(src) | src.getAnIncludedFile() = f)
|
||||||
}
|
}
|
||||||
|
|
||||||
from FunctionCall fc, Function f
|
from FunctionCall fc, Function f
|
||||||
@@ -36,7 +36,7 @@ where
|
|||||||
f = fc.getTarget() and
|
f = fc.getTarget() and
|
||||||
not f.isVarargs() and
|
not f.isVarargs() and
|
||||||
hasZeroParamDecl(f) and
|
hasZeroParamDecl(f) and
|
||||||
isCompiledAsC(f) and
|
isCompiledAsC(f.getFile()) and
|
||||||
exists(f.getBlock()) and
|
exists(f.getBlock()) and
|
||||||
// There must not exist a declaration with the number of parameters
|
// There must not exist a declaration with the number of parameters
|
||||||
// at least as large as the number of call arguments
|
// at least as large as the number of call arguments
|
||||||
|
|||||||
Reference in New Issue
Block a user