Skip to content

Commit 0124f5e

Browse files
Fix performance issue from join on start column.
1 parent 9969544 commit 0124f5e

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

cpp/common/src/codingstandards/cpp/AlertReporting.qll

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,25 @@ module MacroUnwrapper<ResultType ResultElement> {
1717
result.getAnAffectedElement() = re
1818
}
1919

20+
private MacroInvocation getASubsumedMacroInvocation(ResultElement re) {
21+
result = getAMacroInvocation(re) and
22+
// Only report cases where the element is not located at the macro expansion site
23+
// This means we'll report results in macro arguments in the macro argument
24+
// location, not within the macro itself.
25+
//
26+
// Do not join start column values.
27+
pragma[only_bind_out](result.getLocation().getStartColumn()) =
28+
pragma[only_bind_out](re.getLocation().getStartColumn())
29+
}
30+
2031
/**
2132
* Gets the primary macro invocation that generated the result element.
2233
*
2334
* Does not hold for cases where the result element is located at a macro argument site.
2435
*/
2536
MacroInvocation getPrimaryMacroInvocation(ResultElement re) {
2637
exists(MacroInvocation mi |
27-
mi = getAMacroInvocation(re) and
28-
// Only report cases where the element is not located at the macro expansion site
29-
// This means we'll report results in macro arguments in the macro argument
30-
// location, not within the macro itself
31-
mi.getLocation().getStartColumn() = re.getLocation().getStartColumn() and
38+
mi = getASubsumedMacroInvocation(re) and
3239
// No other more specific macro that expands to element
3340
not exists(MacroInvocation otherMi |
3441
otherMi = getAMacroInvocation(re) and otherMi.getParentInvocation() = mi

0 commit comments

Comments
 (0)