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

Skip to content

Commit eb0b0d1

Browse files
committed
C++: Fix remaining FP on MAME
This should fix a FP in libretro/mame2003-plus-libretro.
1 parent bd4fa10 commit eb0b0d1

1 file changed

Lines changed: 9 additions & 11 deletions

File tree

cpp/ql/src/semmle/code/cpp/commons/Exclusions.qll

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,17 @@ predicate functionContainsPreprocCode(Function f) {
9595
*/
9696
predicate isFromMacroDefinition(Element e) {
9797
exists(MacroInvocation mi, Location eLocation, Location miLocation |
98-
// e is in mi
9998
mi.getAnExpandedElement() = e and
100-
// and e was apparently not passed in as a macro parameter
10199
eLocation = e.getLocation() and
102100
miLocation = mi.getLocation() and
103-
nonBindingIntEquality(eLocation.getStartLine(), miLocation.getStartLine()) and
104-
nonBindingIntEquality(eLocation.getStartColumn(), miLocation.getStartColumn())
101+
// If the location of `e` coincides with the macro invocation, then `e` did
102+
// not come from a macro argument. The inequalities here could also be
103+
// equalities, but that confuses the join orderer into joining on the source
104+
// locations too early.
105+
// There are cases where the start location of a non-argument element comes
106+
// right after the invocation's open parenthesis, so it appears to be more
107+
// robust to match on the end location instead.
108+
eLocation.getEndLine() >= miLocation.getEndLine() and
109+
eLocation.getEndColumn() >= miLocation.getEndColumn()
105110
)
106111
}
107-
108-
/**
109-
* Holds if `x = y` but gets compiled to a filter instead of a join. This can
110-
* be used to avoid bad join orders where integers are joined too early.
111-
*/
112-
bindingset[x, y]
113-
private predicate nonBindingIntEquality(int x, int y) { x >= y and y >= x }

0 commit comments

Comments
 (0)