mirror of
https://github.com/github/codeql.git
synced 2025-12-16 08:43:11 +01:00
Ruby/QL: unconditionally generate discard predicates
This commit is contained in:
@@ -36,5 +36,5 @@ pub fn run(options: Options) -> std::io::Result<()> {
|
||||
},
|
||||
];
|
||||
|
||||
generate(languages, options.dbscheme, options.library, false)
|
||||
generate(languages, options.dbscheme, options.library)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,10 @@
|
||||
|
||||
import codeql.Locations as L
|
||||
|
||||
/** Holds if the database is an overlay. */
|
||||
overlay[local]
|
||||
private predicate isOverlay() { databaseMetadata("isOverlay", "true") }
|
||||
|
||||
module QL {
|
||||
/** The base class for all AST nodes */
|
||||
class AstNode extends @ql_ast_node {
|
||||
@@ -48,6 +52,30 @@ module QL {
|
||||
final override string getAPrimaryQlClass() { result = "ReservedWord" }
|
||||
}
|
||||
|
||||
/** Gets the file containing the given `node`. */
|
||||
overlay[local]
|
||||
private @file getNodeFile(@ql_ast_node node) {
|
||||
exists(@location_default loc | ql_ast_node_location(node, loc) |
|
||||
locations_default(loc, result, _, _, _, _)
|
||||
)
|
||||
}
|
||||
|
||||
/** Holds if `file` was extracted as part of the overlay database. */
|
||||
overlay[local]
|
||||
private predicate discardFile(@file file) { isOverlay() and file = getNodeFile(_) }
|
||||
|
||||
/** Holds if `node` is in the `file` and is part of the overlay base database. */
|
||||
overlay[local]
|
||||
private predicate discardableAstNode(@file file, @ql_ast_node node) {
|
||||
not isOverlay() and file = getNodeFile(node)
|
||||
}
|
||||
|
||||
/** Holds if `node` should be discarded, because it is part of the overlay base and is in a file that was also extracted as part of the overlay database. */
|
||||
overlay[discard_entity]
|
||||
private predicate discardAstNode(@ql_ast_node node) {
|
||||
exists(@file file | discardableAstNode(file, node) and discardFile(file))
|
||||
}
|
||||
|
||||
/** A class representing `add_expr` nodes. */
|
||||
class AddExpr extends @ql_add_expr, AstNode {
|
||||
/** Gets the name of the primary QL class for this element. */
|
||||
@@ -1318,6 +1346,30 @@ module Dbscheme {
|
||||
final override string getAPrimaryQlClass() { result = "ReservedWord" }
|
||||
}
|
||||
|
||||
/** Gets the file containing the given `node`. */
|
||||
overlay[local]
|
||||
private @file getNodeFile(@dbscheme_ast_node node) {
|
||||
exists(@location_default loc | dbscheme_ast_node_location(node, loc) |
|
||||
locations_default(loc, result, _, _, _, _)
|
||||
)
|
||||
}
|
||||
|
||||
/** Holds if `file` was extracted as part of the overlay database. */
|
||||
overlay[local]
|
||||
private predicate discardFile(@file file) { isOverlay() and file = getNodeFile(_) }
|
||||
|
||||
/** Holds if `node` is in the `file` and is part of the overlay base database. */
|
||||
overlay[local]
|
||||
private predicate discardableAstNode(@file file, @dbscheme_ast_node node) {
|
||||
not isOverlay() and file = getNodeFile(node)
|
||||
}
|
||||
|
||||
/** Holds if `node` should be discarded, because it is part of the overlay base and is in a file that was also extracted as part of the overlay database. */
|
||||
overlay[discard_entity]
|
||||
private predicate discardAstNode(@dbscheme_ast_node node) {
|
||||
exists(@file file | discardableAstNode(file, node) and discardFile(file))
|
||||
}
|
||||
|
||||
/** A class representing `annotName` tokens. */
|
||||
class AnnotName extends @dbscheme_token_annot_name, Token {
|
||||
/** Gets the name of the primary QL class for this element. */
|
||||
@@ -1654,6 +1706,30 @@ module Blame {
|
||||
final override string getAPrimaryQlClass() { result = "ReservedWord" }
|
||||
}
|
||||
|
||||
/** Gets the file containing the given `node`. */
|
||||
overlay[local]
|
||||
private @file getNodeFile(@blame_ast_node node) {
|
||||
exists(@location_default loc | blame_ast_node_location(node, loc) |
|
||||
locations_default(loc, result, _, _, _, _)
|
||||
)
|
||||
}
|
||||
|
||||
/** Holds if `file` was extracted as part of the overlay database. */
|
||||
overlay[local]
|
||||
private predicate discardFile(@file file) { isOverlay() and file = getNodeFile(_) }
|
||||
|
||||
/** Holds if `node` is in the `file` and is part of the overlay base database. */
|
||||
overlay[local]
|
||||
private predicate discardableAstNode(@file file, @blame_ast_node node) {
|
||||
not isOverlay() and file = getNodeFile(node)
|
||||
}
|
||||
|
||||
/** Holds if `node` should be discarded, because it is part of the overlay base and is in a file that was also extracted as part of the overlay database. */
|
||||
overlay[discard_entity]
|
||||
private predicate discardAstNode(@blame_ast_node node) {
|
||||
exists(@file file | discardableAstNode(file, node) and discardFile(file))
|
||||
}
|
||||
|
||||
/** A class representing `blame_entry` nodes. */
|
||||
class BlameEntry extends @blame_blame_entry, AstNode {
|
||||
/** Gets the name of the primary QL class for this element. */
|
||||
@@ -1767,6 +1843,30 @@ module JSON {
|
||||
final override string getAPrimaryQlClass() { result = "ReservedWord" }
|
||||
}
|
||||
|
||||
/** Gets the file containing the given `node`. */
|
||||
overlay[local]
|
||||
private @file getNodeFile(@json_ast_node node) {
|
||||
exists(@location_default loc | json_ast_node_location(node, loc) |
|
||||
locations_default(loc, result, _, _, _, _)
|
||||
)
|
||||
}
|
||||
|
||||
/** Holds if `file` was extracted as part of the overlay database. */
|
||||
overlay[local]
|
||||
private predicate discardFile(@file file) { isOverlay() and file = getNodeFile(_) }
|
||||
|
||||
/** Holds if `node` is in the `file` and is part of the overlay base database. */
|
||||
overlay[local]
|
||||
private predicate discardableAstNode(@file file, @json_ast_node node) {
|
||||
not isOverlay() and file = getNodeFile(node)
|
||||
}
|
||||
|
||||
/** Holds if `node` should be discarded, because it is part of the overlay base and is in a file that was also extracted as part of the overlay database. */
|
||||
overlay[discard_entity]
|
||||
private predicate discardAstNode(@json_ast_node node) {
|
||||
exists(@file file | discardableAstNode(file, node) and discardFile(file))
|
||||
}
|
||||
|
||||
class UnderscoreValue extends @json_underscore_value, AstNode { }
|
||||
|
||||
/** A class representing `array` nodes. */
|
||||
|
||||
Reference in New Issue
Block a user