@@ -281,10 +281,13 @@ class IfDirective extends ConditionalDirective, @directive_if {
281281 override predicate conditionMatched ( ) { directive_ifs ( this , _, 1 ) }
282282
283283 /** Gets the closing `#endif` preprocessor directive. */
284- EndifDirective getEndifDirective ( ) { directive_if_endif ( this , result ) }
284+ EndifDirective getEndifDirective ( ) { directive_endifs ( result , this ) }
285285
286286 /** Gets the sibling `#elif` or `#else` preprocessor directive at index `sibling`. */
287- BranchDirective getSiblingDirective ( int sibling ) { directive_if_siblings ( this , result , sibling ) }
287+ BranchDirective getSiblingDirective ( int sibling ) {
288+ directive_elifs ( result , _, _, this , sibling ) or
289+ directive_elses ( result , _, this , sibling )
290+ }
288291
289292 /** Gets a sibling `#elif` or `#else` preprocessor directive. */
290293 BranchDirective getASiblingDirective ( ) { result = getSiblingDirective ( _) }
@@ -298,17 +301,18 @@ class IfDirective extends ConditionalDirective, @directive_if {
298301 * An `#elif` preprocessor directive.
299302 */
300303class ElifDirective extends ConditionalDirective , @directive_elif {
301- override predicate branchTaken ( ) { directive_elifs ( this , 1 , _) }
304+ override predicate branchTaken ( ) { directive_elifs ( this , 1 , _, _ , _ ) }
302305
303- override predicate conditionMatched ( ) { directive_elifs ( this , _, 1 ) }
306+ override predicate conditionMatched ( ) { directive_elifs ( this , _, 1 , _ , _ ) }
304307
305308 /** Gets the opening `#if` preprocessor directive. */
306- IfDirective getIfDirective ( ) { directive_if_siblings ( result , this , _) }
309+ IfDirective getIfDirective ( ) { directive_elifs ( this , _ , _ , result , _) }
307310
308311 /** Gets the successive branching preprocessor directive (`#elif` or `#else`), if any. */
309312 BranchDirective getSuccSiblingDirective ( ) {
310313 exists ( IfDirective i , int index |
311- directive_if_siblings ( i , this , index ) and directive_if_siblings ( i , result , index + 1 )
314+ this = i .getSiblingDirective ( index ) and
315+ result = i .getSiblingDirective ( index + 1 )
312316 )
313317 }
314318
@@ -322,9 +326,9 @@ class ElifDirective extends ConditionalDirective, @directive_elif {
322326 */
323327class ElseDirective extends BranchDirective , @directive_else {
324328 /** Gets the opening `#if` preprocessor directive. */
325- IfDirective getIfDirective ( ) { directive_if_siblings ( result , this , _) }
329+ IfDirective getIfDirective ( ) { directive_elses ( this , _ , result , _) }
326330
327- override predicate branchTaken ( ) { directive_elses ( this , 1 ) }
331+ override predicate branchTaken ( ) { directive_elses ( this , 1 , _ , _ ) }
328332
329333 override string toString ( ) { result = "#else" }
330334
@@ -336,7 +340,7 @@ class ElseDirective extends BranchDirective, @directive_else {
336340 */
337341class EndifDirective extends PreprocessorDirective , @directive_endif {
338342 /** Gets the opening `#if` preprocessor directive. */
339- IfDirective getIfDirective ( ) { directive_if_endif ( result , this ) }
343+ IfDirective getIfDirective ( ) { directive_endifs ( this , result ) }
340344
341345 override string toString ( ) { result = "#endif" }
342346
0 commit comments