mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
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:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user