@@ -123,6 +123,13 @@ private predicate constructorCallTypeMention(ConstructorCall cc, TypeMention tm)
123123 )
124124}
125125
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+
126133/**
127134 * Gets an element, of kind `kind`, that element `e` uses, if any.
128135 * Attention: This predicate yields multiple definitions for a single location.
@@ -184,11 +191,9 @@ Top definitionOf(Top e, string kind) {
184191 kind = "I" and
185192 result = e .( Include ) .getIncludedFile ( ) and
186193 // 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 )
192197 // (an #include directive must be always on it's own line)
193198 )
194199 ) and
0 commit comments