File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed
cpp/ql/src/semmle/code/cpp Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -73,14 +73,24 @@ abstract class PreprocessorBranchDirective extends PreprocessorDirective {
7373 * `somePreprocessorBranchDirective`.
7474 */
7575 PreprocessorBranchDirective getNext ( ) {
76- getIf ( ) = result .getIf ( ) and
77- getLocation ( ) .getStartLine ( ) < result .getLocation ( ) .getStartLine ( ) and
78- not exists ( PreprocessorBranchDirective other |
79- getIf ( ) = other .getIf ( ) and
80- getLocation ( ) .getStartLine ( ) < other .getLocation ( ) .getStartLine ( ) and
81- other .getLocation ( ) .getStartLine ( ) < result .getLocation ( ) .getStartLine ( )
76+ exists ( PreprocessorBranch branch |
77+ this .getIndexInBranch ( branch ) + 1 = result .getIndexInBranch ( branch )
8278 )
8379 }
80+
81+ /**
82+ * Gets the index of this branching directive within the matching #if,
83+ * #ifdef or #ifndef.
84+ */
85+ private int getIndexInBranch ( PreprocessorBranch branch ) {
86+ this = rank [ result ] ( PreprocessorBranchDirective other |
87+ other .getIf ( ) = branch
88+ |
89+ other
90+ order by
91+ other .getLocation ( ) .getStartLine ( )
92+ )
93+ }
8494}
8595
8696/**
You can’t perform that action at this time.
0 commit comments