Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1d11a13

Browse files
committed
C++: Don't use dbtypes in SuppressionScope
This avoids using a raw db type. It is possible for `SuppressionComment` and `SuppressionScope` to have different locations because `SuppressionScope` defines `hasLocationInfo` as a new rootdef whereas `SuppressionComment` only responds to `getLocation` that it inherited. In interpretation of query results, a `hasLocationInfo` predicate is preferred over `getLocation` if it exists.
1 parent f005d45 commit 1d11a13

1 file changed

Lines changed: 3 additions & 17 deletions

File tree

cpp/ql/src/AlertSuppression.ql

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,23 +47,14 @@ class SuppressionComment extends CppStyleComment {
4747

4848
/** Gets the scope of this suppression. */
4949
SuppressionScope getScope() {
50-
this = result.getSuppressionComment()
50+
result = this
5151
}
5252
}
5353

5454
/**
5555
* The scope of an alert suppression comment.
5656
*/
57-
class SuppressionScope extends @comment {
58-
SuppressionScope() {
59-
mkElement(this) instanceof SuppressionComment
60-
}
61-
62-
/** Gets a suppression comment with this scope. */
63-
SuppressionComment getSuppressionComment() {
64-
result = mkElement(this)
65-
}
66-
57+
class SuppressionScope extends SuppressionComment {
6758
/**
6859
* Holds if this element is at the specified location.
6960
* The location spans column `startcolumn` of line `startline` to
@@ -72,12 +63,7 @@ class SuppressionScope extends @comment {
7263
* [LGTM locations](https://lgtm.com/help/ql/locations).
7364
*/
7465
predicate hasLocationInfo(string filepath, int startline, int startcolumn, int endline, int endcolumn) {
75-
mkElement(this).(SuppressionComment).covers(filepath, startline, startcolumn, endline, endcolumn)
76-
}
77-
78-
/** Gets a textual representation of this element. */
79-
string toString() {
80-
result = this.getSuppressionComment().toString()
66+
this.covers(filepath, startline, startcolumn, endline, endcolumn)
8167
}
8268
}
8369

0 commit comments

Comments
 (0)