File tree Expand file tree Collapse file tree
cpp/ql/src/semmle/code/cpp/commons Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -94,11 +94,22 @@ predicate functionContainsPreprocCode(Function f) {
9494 * ```
9595 */
9696predicate isFromMacroDefinition ( Element e ) {
97- exists ( MacroInvocation mi |
97+ exists ( MacroInvocation mi , Location eLocation , Location miLocation |
9898 // e is in mi
9999 mi .getAnExpandedElement ( ) = e and
100100 // and e was apparently not passed in as a macro parameter
101- e .getLocation ( ) .getStartLine ( ) = mi .getLocation ( ) .getStartLine ( ) and
102- e .getLocation ( ) .getStartColumn ( ) = mi .getLocation ( ) .getStartColumn ( )
101+ eLocation = e .getLocation ( ) and
102+ miLocation = mi .getLocation ( ) and
103+ nonBindingIntEquality ( eLocation .getStartLine ( ) , miLocation .getStartLine ( ) ) and
104+ nonBindingIntEquality ( eLocation .getStartColumn ( ) , miLocation .getStartColumn ( ) )
103105 )
104106}
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 ) {
114+ x >= y and y >= x
115+ }
You can’t perform that action at this time.
0 commit comments