@@ -140,3 +140,72 @@ class NullableDirective extends PreprocessorDirective, @directive_nullable {
140140
141141 override string getAPrimaryQlClass ( ) { result = "NullableDirective" }
142142}
143+
144+ /**
145+ * A `#line` directive, such as `#line default`, `#line hidden`, or `#line`
146+ * directive with line number.
147+ */
148+ class LineDirective extends PreprocessorDirective , @directive_line {
149+ /** Gets the succeeding `#line` directive in the file, if any. */
150+ LineDirective getSuccLineDirective ( ) {
151+ result =
152+ rank [ 1 ] ( LineDirective next |
153+ next .getFile ( ) = this .getFile ( ) and
154+ next .getLocation ( ) .getStartLine ( ) > this .getLocation ( ) .getStartLine ( )
155+ |
156+ next order by next .getLocation ( ) .getStartLine ( )
157+ )
158+ }
159+
160+ /** Holds if there is a succeeding `#line` directive in the file. */
161+ predicate hasSuccLineDirective ( ) {
162+ exists ( LineDirective other |
163+ other .getFile ( ) = this .getFile ( ) and
164+ other .getLocation ( ) .getStartLine ( ) > this .getLocation ( ) .getStartLine ( )
165+ )
166+ }
167+
168+ override string toString ( ) { result = "#line ..." }
169+
170+ override string getAPrimaryQlClass ( ) { result = "LineDirective" }
171+ }
172+
173+ /**
174+ * A `#line default` directive.
175+ */
176+ class DefaultLineDirective extends LineDirective {
177+ DefaultLineDirective ( ) { directive_lines ( this , 0 ) }
178+
179+ override string toString ( ) { result = "#line default" }
180+
181+ override string getAPrimaryQlClass ( ) { result = "DefaultLineDirective" }
182+ }
183+
184+ /**
185+ * A `#line hidden` directive.
186+ */
187+ class HiddenLineDirective extends LineDirective {
188+ HiddenLineDirective ( ) { directive_lines ( this , 1 ) }
189+
190+ override string toString ( ) { result = "#line hidden" }
191+
192+ override string getAPrimaryQlClass ( ) { result = "HiddenLineDirective" }
193+ }
194+
195+ /**
196+ * A numeric `#line` directive, such as `#line 200 file`
197+ */
198+ class NumericLineDirective extends LineDirective {
199+ NumericLineDirective ( ) { directive_lines ( this , 2 ) }
200+
201+ /** Gets the line number of this directive. */
202+ int getLine ( ) { directive_line_values ( this , result , _) }
203+
204+ /** Holds if this directive specifies a file name. */
205+ predicate hasFileName ( ) { this .getFileName ( ) != "" }
206+
207+ /** Gets the file name of this directive. */
208+ string getFileName ( ) { directive_line_values ( this , _, result ) }
209+
210+ override string getAPrimaryQlClass ( ) { result = "NumericLineDirective" }
211+ }
0 commit comments