Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c1fcf78

Browse files
committed
C++: Fold predicate sameLocation
1 parent 04ef4d1 commit c1fcf78

1 file changed

Lines changed: 12 additions & 5 deletions

File tree

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

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,17 @@ import TooFewArguments
1717
import TooManyArguments
1818
import semmle.code.cpp.commons.Exclusions
1919

20-
predicate sameLocation(Location loc1, Location loc2) {
21-
loc1.getFile() = loc2.getFile() and
22-
loc1.getStartLine() = loc2.getStartLine() and
23-
loc1.getStartColumn() = loc2.getStartColumn()
20+
predicate locInfo(Locatable e, File file, int line, int col) {
21+
e.getFile() = file and
22+
e.getLocation().getStartLine() = line and
23+
e.getLocation().getStartColumn() = col
24+
}
25+
26+
predicate sameLocation(FunctionDeclarationEntry fde, FunctionCall fc) {
27+
exists(File file, int line, int col |
28+
locInfo(fde, file, line, col) and
29+
locInfo(fc, file, line, col)
30+
)
2431
}
2532

2633
predicate isCompiledAsC(File f) {
@@ -34,7 +41,7 @@ where
3441
isCompiledAsC(fdeIm.getFile()) and
3542
not isFromMacroDefinition(fc) and
3643
fdeIm.isImplicit() and
37-
sameLocation(fdeIm.getLocation(), fc.getLocation()) and
44+
sameLocation(fdeIm, fc) and
3845
not mistypedFunctionArguments(fc, _, _) and
3946
not tooFewArguments(fc, _) and
4047
not tooManyArguments(fc, _)

0 commit comments

Comments
 (0)