@@ -123,6 +123,13 @@ private predicate constructorCallTypeMention(ConstructorCall cc, TypeMention tm)
123
123
)
124
124
}
125
125
126
+ /** Holds if `loc` has the container `container` and is on the line starting at `startLine`. */
127
+ pragma [ nomagic]
128
+ private predicate hasContainerAndStartLine ( Location loc , Container container , int startLine ) {
129
+ loc .getStartLine ( ) = startLine and
130
+ loc .getContainer ( ) = container
131
+ }
132
+
126
133
/**
127
134
* Gets an element, of kind `kind`, that element `e` uses, if any.
128
135
* Attention: This predicate yields multiple definitions for a single location.
@@ -184,11 +191,9 @@ Top definitionOf(Top e, string kind) {
184
191
kind = "I" and
185
192
result = e .( Include ) .getIncludedFile ( ) and
186
193
// exclude `#include` directives containing macros
187
- not exists ( MacroInvocation mi , Location l1 , Location l2 |
188
- l1 = e .( Include ) .getLocation ( ) and
189
- l2 = mi .getLocation ( ) and
190
- l1 .getContainer ( ) = l2 .getContainer ( ) and
191
- l1 .getStartLine ( ) = l2 .getStartLine ( )
194
+ not exists ( MacroInvocation mi , Container container , int startLine |
195
+ hasContainerAndStartLine ( e .( Include ) .getLocation ( ) , container , startLine ) and
196
+ hasContainerAndStartLine ( mi .getLocation ( ) , container , startLine )
192
197
// (an #include directive must be always on it's own line)
193
198
)
194
199
) and
0 commit comments