C++: Fold predicate sameLocation

This commit is contained in:
Mathias Vorreiter Pedersen
2020-01-16 16:14:55 +01:00
parent 04ef4d102d
commit c1fcf78f16

View File

@@ -17,10 +17,17 @@ import TooFewArguments
import TooManyArguments import TooManyArguments
import semmle.code.cpp.commons.Exclusions import semmle.code.cpp.commons.Exclusions
predicate sameLocation(Location loc1, Location loc2) { predicate locInfo(Locatable e, File file, int line, int col) {
loc1.getFile() = loc2.getFile() and e.getFile() = file and
loc1.getStartLine() = loc2.getStartLine() and e.getLocation().getStartLine() = line and
loc1.getStartColumn() = loc2.getStartColumn() e.getLocation().getStartColumn() = col
}
predicate sameLocation(FunctionDeclarationEntry fde, FunctionCall fc) {
exists(File file, int line, int col |
locInfo(fde, file, line, col) and
locInfo(fc, file, line, col)
)
} }
predicate isCompiledAsC(File f) { predicate isCompiledAsC(File f) {
@@ -34,7 +41,7 @@ where
isCompiledAsC(fdeIm.getFile()) and isCompiledAsC(fdeIm.getFile()) and
not isFromMacroDefinition(fc) and not isFromMacroDefinition(fc) and
fdeIm.isImplicit() and fdeIm.isImplicit() and
sameLocation(fdeIm.getLocation(), fc.getLocation()) and sameLocation(fdeIm, fc) and
not mistypedFunctionArguments(fc, _, _) and not mistypedFunctionArguments(fc, _, _) and
not tooFewArguments(fc, _) and not tooFewArguments(fc, _) and
not tooManyArguments(fc, _) not tooManyArguments(fc, _)