mirror of
https://github.com/github/codeql.git
synced 2026-04-29 18:55:14 +02:00
Fix code review findings in 'line' directives
This commit is contained in:
@@ -163,7 +163,7 @@ class LineDirective extends PreprocessorDirective, @directive_line {
|
||||
/** Gets the succeeding `#line` directive in the file, if any. */
|
||||
LineDirective getSuccLineDirective() {
|
||||
result =
|
||||
rank[1](LineDirective next |
|
||||
min(LineDirective next |
|
||||
next.getFile() = this.getFile() and
|
||||
next.getLocation().getStartLine() > this.getLocation().getStartLine()
|
||||
|
|
||||
@@ -216,10 +216,10 @@ class NumericLineDirective extends LineDirective {
|
||||
int getLine() { directive_line_values(this, result, _) }
|
||||
|
||||
/** Holds if this directive specifies a file name. */
|
||||
predicate hasFileName() { this.getFileName() != "" }
|
||||
predicate hasFileName() { exists(this.getFileName()) }
|
||||
|
||||
/** Gets the file name of this directive. */
|
||||
string getFileName() { directive_line_values(this, _, result) }
|
||||
/** Gets the file name of this directive, if any. */
|
||||
string getFileName() { directive_line_values(this, _, result) and result != "" }
|
||||
|
||||
override string getAPrimaryQlClass() { result = "NumericLineDirective" }
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ hidden
|
||||
| trivia.cs:25:1:25:38 | #line hidden |
|
||||
lines
|
||||
| trivia.cs:18:1:18:19 | #line ... | 200 | Special |
|
||||
| trivia.cs:27:1:27:9 | #line ... | 300 | |
|
||||
| trivia.cs:27:1:27:9 | #line ... | 300 | no file |
|
||||
succ
|
||||
| trivia.cs:18:1:18:19 | #line ... | trivia.cs:21:1:21:13 | #line default |
|
||||
| trivia.cs:21:1:21:13 | #line default | trivia.cs:25:1:25:38 | #line hidden |
|
||||
|
||||
@@ -5,7 +5,8 @@ query predicate default(DefaultLineDirective line) { any() }
|
||||
query predicate hidden(HiddenLineDirective line) { any() }
|
||||
|
||||
query predicate lines(NumericLineDirective line, int l, string file) {
|
||||
line.getLine() = l and line.getFileName() = file
|
||||
line.getLine() = l and
|
||||
if line.hasFileName() then line.getFileName() = file else file = "no file"
|
||||
}
|
||||
|
||||
query predicate succ(LineDirective d, LineDirective succ) { d.getSuccLineDirective() = succ }
|
||||
|
||||
Reference in New Issue
Block a user