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.
This commit is contained in:
Jonas Jensen
2018-08-28 10:18:28 +02:00
parent f005d45c63
commit 1d11a13230

View File

@@ -47,23 +47,14 @@ class SuppressionComment extends CppStyleComment {
/** Gets the scope of this suppression. */
SuppressionScope getScope() {
this = result.getSuppressionComment()
result = this
}
}
/**
* The scope of an alert suppression comment.
*/
class SuppressionScope extends @comment {
SuppressionScope() {
mkElement(this) instanceof SuppressionComment
}
/** Gets a suppression comment with this scope. */
SuppressionComment getSuppressionComment() {
result = mkElement(this)
}
class SuppressionScope extends SuppressionComment {
/**
* Holds if this element is at the specified location.
* The location spans column `startcolumn` of line `startline` to
@@ -72,12 +63,7 @@ class SuppressionScope extends @comment {
* [LGTM locations](https://lgtm.com/help/ql/locations).
*/
predicate hasLocationInfo(string filepath, int startline, int startcolumn, int endline, int endcolumn) {
mkElement(this).(SuppressionComment).covers(filepath, startline, startcolumn, endline, endcolumn)
}
/** Gets a textual representation of this element. */
string toString() {
result = this.getSuppressionComment().toString()
this.covers(filepath, startline, startcolumn, endline, endcolumn)
}
}