Skip to content

Commit 966c6f1

Browse files
authored
Merge pull request github#8720 from MathiasVP/smaller-join-in-get-root-cause
C++: Remove TC from `Element.getRootCause`
2 parents 3ea6ba5 + 3388196 commit 966c6f1

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

cpp/ql/lib/semmle/code/cpp/Element.qll

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,7 @@ class Element extends ElementBase {
109109
then
110110
exists(MacroInvocation mi |
111111
this = mi.getAGeneratedElement() and
112-
not exists(MacroInvocation closer |
113-
this = closer.getAGeneratedElement() and
114-
mi = closer.getParentInvocation+()
115-
) and
112+
not hasCloserMacroInvocation(this, mi) and
116113
result = mi.getMacro()
117114
)
118115
else result = this
@@ -236,6 +233,14 @@ class Element extends ElementBase {
236233
}
237234
}
238235

236+
pragma[noinline]
237+
private predicate hasCloserMacroInvocation(Element elem, MacroInvocation mi) {
238+
exists(MacroInvocation closer |
239+
elem = closer.getAGeneratedElement() and
240+
mi = closer.getParentInvocation()
241+
)
242+
}
243+
239244
private predicate isFromTemplateInstantiationRec(Element e, Element instantiation) {
240245
instantiation.(Function).isConstructedFrom(_) and
241246
e = instantiation

0 commit comments

Comments
 (0)