Merge pull request #2467 from geoffw0/speedup1

CPP: Speed up isCompiledAsC.
This commit is contained in:
Jonas Jensen
2019-11-28 17:31:27 +01:00
committed by GitHub
3 changed files with 15 additions and 15 deletions

View File

@@ -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

View File

@@ -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() |

View File

@@ -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