mirror of
https://github.com/github/codeql.git
synced 2025-12-16 16:53:25 +01:00
Merge pull request #17581 from jketema/loc-table-merge
C++: Merge the location tables
This commit is contained in:
@@ -0,0 +1,161 @@
|
||||
class Accessible extends @accessible {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
class Container extends @container {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
class Expr extends @expr {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
class Initialiser extends @initialiser {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
class Location extends @location_default {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
class Stmt extends @stmt {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
predicate isLocationDefault(Location l) {
|
||||
diagnostics(_, _, _, _, _, l)
|
||||
or
|
||||
macroinvocations(_, _, l, _)
|
||||
or
|
||||
fun_decls(_, _, _, _, l)
|
||||
or
|
||||
var_decls(_, _, _, _, l)
|
||||
or
|
||||
type_decls(_, _, l)
|
||||
or
|
||||
namespace_decls(_, _, l, _)
|
||||
or
|
||||
namespace_decls(_, _, _, l)
|
||||
or
|
||||
usings(_, _, l, _)
|
||||
or
|
||||
static_asserts(_, _, _, l, _)
|
||||
or
|
||||
enumconstants(_, _, _, _, _, l)
|
||||
or
|
||||
concept_templates(_, _, l)
|
||||
or
|
||||
attributes(_, _, _, _, l)
|
||||
or
|
||||
attribute_args(_, _, _, _, l)
|
||||
or
|
||||
derivations(_, _, _, _, l)
|
||||
or
|
||||
frienddecls(_, _, _, l)
|
||||
or
|
||||
comments(_, _, l)
|
||||
or
|
||||
namequalifiers(_, _, _, l)
|
||||
or
|
||||
lambda_capture(_, _, _, _, _, _, l)
|
||||
or
|
||||
preprocdirects(_, _, l)
|
||||
or
|
||||
xmllocations(_, l)
|
||||
or
|
||||
locations_default(l, _, 0, 0, 0, 0) // For containers.
|
||||
}
|
||||
|
||||
predicate isLocationExpr(Location l) {
|
||||
initialisers(_, _, _, l)
|
||||
or
|
||||
exprs(_, _, l)
|
||||
}
|
||||
|
||||
predicate isLocationStmt(Location l) { stmts(_, _, l) }
|
||||
|
||||
newtype TExprOrStmtLocation =
|
||||
TExprLocation(Location l, Container c, int startLine, int startColumn, int endLine, int endColumn) {
|
||||
isLocationExpr(l) and
|
||||
(isLocationDefault(l) or isLocationStmt(l)) and
|
||||
locations_default(l, c, startLine, startColumn, endLine, endColumn)
|
||||
} or
|
||||
TStmtLocation(Location l, Container c, int startLine, int startColumn, int endLine, int endColumn) {
|
||||
isLocationStmt(l) and
|
||||
(isLocationDefault(l) or isLocationExpr(l)) and
|
||||
locations_default(l, c, startLine, startColumn, endLine, endColumn)
|
||||
}
|
||||
|
||||
module Fresh = QlBuiltins::NewEntity<TExprOrStmtLocation>;
|
||||
|
||||
class NewLocationBase = @location_default or Fresh::EntityId;
|
||||
|
||||
class NewLocation extends NewLocationBase {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
query predicate new_locations_default(
|
||||
NewLocation l, Container c, int startLine, int startColumn, int endLine, int endColumn
|
||||
) {
|
||||
isLocationDefault(l) and
|
||||
locations_default(l, c, startLine, startColumn, endLine, endColumn)
|
||||
}
|
||||
|
||||
query predicate new_locations_expr(
|
||||
NewLocation l, Container c, int startLine, int startColumn, int endLine, int endColumn
|
||||
) {
|
||||
exists(Location l_old |
|
||||
isLocationExpr(l_old) and
|
||||
locations_default(l_old, c, startLine, startColumn, endLine, endColumn)
|
||||
|
|
||||
if not isLocationDefault(l_old) and not isLocationStmt(l)
|
||||
then l = l_old
|
||||
else l = Fresh::map(TExprLocation(l_old, c, startLine, startColumn, endLine, endColumn))
|
||||
)
|
||||
}
|
||||
|
||||
query predicate new_locations_stmt(
|
||||
NewLocation l, Container c, int startLine, int startColumn, int endLine, int endColumn
|
||||
) {
|
||||
exists(Location l_old |
|
||||
isLocationStmt(l_old) and
|
||||
locations_default(l_old, c, startLine, startColumn, endLine, endColumn)
|
||||
|
|
||||
if not isLocationDefault(l_old) and not isLocationExpr(l)
|
||||
then l = l_old
|
||||
else l = Fresh::map(TStmtLocation(l_old, c, startLine, startColumn, endLine, endColumn))
|
||||
)
|
||||
}
|
||||
|
||||
query predicate new_exprs(Expr e, int kind, NewLocation l) {
|
||||
exists(Location l_old, Container c, int startLine, int startColumn, int endLine, int endColumn |
|
||||
exprs(e, kind, l_old) and
|
||||
locations_default(l_old, c, startLine, startColumn, endLine, endColumn)
|
||||
|
|
||||
if not isLocationDefault(l_old) and not isLocationStmt(l)
|
||||
then l = l_old
|
||||
else l = Fresh::map(TExprLocation(l_old, c, startLine, startColumn, endLine, endColumn))
|
||||
)
|
||||
}
|
||||
|
||||
query predicate new_initialisers(Initialiser i, Accessible v, Expr e, NewLocation l) {
|
||||
exists(Location l_old, Container c, int startLine, int startColumn, int endLine, int endColumn |
|
||||
initialisers(i, v, e, l_old) and
|
||||
locations_default(l_old, c, startLine, startColumn, endLine, endColumn)
|
||||
|
|
||||
if not isLocationDefault(l_old) and not isLocationStmt(l)
|
||||
then l = l_old
|
||||
else l = Fresh::map(TExprLocation(l_old, c, startLine, startColumn, endLine, endColumn))
|
||||
)
|
||||
}
|
||||
|
||||
query predicate new_stmts(Stmt s, int kind, NewLocation l) {
|
||||
exists(Location l_old, Container c, int startLine, int startColumn, int endLine, int endColumn |
|
||||
stmts(s, kind, l_old) and
|
||||
locations_default(l_old, c, startLine, startColumn, endLine, endColumn)
|
||||
|
|
||||
if not isLocationDefault(l_old) and not isLocationExpr(l)
|
||||
then l = l_old
|
||||
else l = Fresh::map(TStmtLocation(l_old, c, startLine, startColumn, endLine, endColumn))
|
||||
)
|
||||
}
|
||||
2475
cpp/downgrades/e70d0b653187b93d9688f21c9db46bb1cd46ab78/old.dbscheme
Normal file
2475
cpp/downgrades/e70d0b653187b93d9688f21c9db46bb1cd46ab78/old.dbscheme
Normal file
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,8 @@
|
||||
description: Merge location tables
|
||||
compatibility: partial
|
||||
locations_default.rel: run downgrades.ql new_locations_default
|
||||
locations_expr.rel: run downgrades.ql new_locations_expr
|
||||
locations_stmt.rel: run downgrades.ql new_locations_stmt
|
||||
exprs.rel: run downgrades.ql new_exprs
|
||||
initialisers.rel: run downgrades.ql new_initialisers
|
||||
stmts.rel: run downgrades.ql new_stmts
|
||||
4
cpp/ql/lib/change-notes/2025-06-27-locations.md
Normal file
4
cpp/ql/lib/change-notes/2025-06-27-locations.md
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
category: deprecated
|
||||
---
|
||||
* The `UnknownDefaultLocation`, `UnknownExprLocation`, and `UnknownStmtLocation` classes have been deprecated. Use `UnknownLocation` instead.
|
||||
@@ -8,7 +8,7 @@ module CryptoInput implements InputSig<Language::Location> {
|
||||
|
||||
class LocatableElement = Language::Locatable;
|
||||
|
||||
class UnknownLocation = Language::UnknownDefaultLocation;
|
||||
class UnknownLocation = Language::UnknownLocation;
|
||||
|
||||
LocatableElement dfn_to_element(DataFlow::Node node) {
|
||||
result = node.asExpr() or
|
||||
|
||||
@@ -901,7 +901,7 @@ class BuiltInFunction extends Function {
|
||||
/** Gets a dummy location for the built-in function. */
|
||||
override Location getLocation() {
|
||||
suppressUnusedThis(this) and
|
||||
result instanceof UnknownDefaultLocation
|
||||
result instanceof UnknownLocation
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,9 +53,7 @@ class Location extends @location {
|
||||
predicate fullLocationInfo(
|
||||
Container container, int startline, int startcolumn, int endline, int endcolumn
|
||||
) {
|
||||
locations_default(this, unresolveElement(container), startline, startcolumn, endline, endcolumn) or
|
||||
locations_expr(this, unresolveElement(container), startline, startcolumn, endline, endcolumn) or
|
||||
locations_stmt(this, unresolveElement(container), startline, startcolumn, endline, endcolumn)
|
||||
locations_default(this, unresolveElement(container), startline, startcolumn, endline, endcolumn)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -146,30 +144,32 @@ class Locatable extends Element { }
|
||||
* expressions, one for statements and one for other program elements.
|
||||
*/
|
||||
class UnknownLocation extends Location {
|
||||
UnknownLocation() { this.getFile().getAbsolutePath() = "" }
|
||||
UnknownLocation() {
|
||||
this.getFile().getAbsolutePath() = "" and locations_default(this, _, 0, 0, 0, 0)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A dummy location which is used when something doesn't have a location in
|
||||
* the source code but needs to have a `Location` associated with it.
|
||||
*
|
||||
* DEPRECATED: use `UnknownLocation`
|
||||
*/
|
||||
class UnknownDefaultLocation extends UnknownLocation {
|
||||
UnknownDefaultLocation() { locations_default(this, _, 0, 0, 0, 0) }
|
||||
}
|
||||
deprecated class UnknownDefaultLocation extends UnknownLocation { }
|
||||
|
||||
/**
|
||||
* A dummy location which is used when an expression doesn't have a
|
||||
* location in the source code but needs to have a `Location` associated
|
||||
* with it.
|
||||
*
|
||||
* DEPRECATED: use `UnknownLocation`
|
||||
*/
|
||||
class UnknownExprLocation extends UnknownLocation {
|
||||
UnknownExprLocation() { locations_expr(this, _, 0, 0, 0, 0) }
|
||||
}
|
||||
deprecated class UnknownExprLocation extends UnknownLocation { }
|
||||
|
||||
/**
|
||||
* A dummy location which is used when a statement doesn't have a location
|
||||
* in the source code but needs to have a `Location` associated with it.
|
||||
*
|
||||
* DEPRECATED: use `UnknownLocation`
|
||||
*/
|
||||
class UnknownStmtLocation extends UnknownLocation {
|
||||
UnknownStmtLocation() { locations_stmt(this, _, 0, 0, 0, 0) }
|
||||
}
|
||||
deprecated class UnknownStmtLocation extends UnknownLocation { }
|
||||
|
||||
@@ -154,8 +154,9 @@ class MacroInvocation extends MacroAccess {
|
||||
* well.
|
||||
*/
|
||||
Locatable getAnAffectedElement() {
|
||||
inmacroexpansion(unresolveElement(result), underlyingElement(this)) or
|
||||
macrolocationbind(underlyingElement(this), result.getLocation())
|
||||
inmacroexpansion(unresolveElement(result), underlyingElement(this))
|
||||
or
|
||||
macrolocationbind(underlyingElement(this), result.getLocation()) and this != result
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -259,7 +260,8 @@ predicate inMacroExpansion(Locatable element) {
|
||||
inmacroexpansion(unresolveElement(element), _)
|
||||
or
|
||||
macroLocation(element.getLocation()) and
|
||||
not topLevelMacroAccess(element)
|
||||
not topLevelMacroAccess(element) and
|
||||
not element.getLocation() instanceof UnknownLocation
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,7 +40,7 @@ class Namespace extends NameQualifyingElement, @namespace {
|
||||
override Location getLocation() {
|
||||
if strictcount(this.getADeclarationEntry()) = 1
|
||||
then result = this.getADeclarationEntry().getLocation()
|
||||
else result instanceof UnknownDefaultLocation
|
||||
else result instanceof UnknownLocation
|
||||
}
|
||||
|
||||
/** Gets the simple name of this namespace. */
|
||||
|
||||
@@ -13,7 +13,7 @@ class Specifier extends Element, @specifier {
|
||||
/** Gets a dummy location for the specifier. */
|
||||
override Location getLocation() {
|
||||
exists(this) and
|
||||
result instanceof UnknownDefaultLocation
|
||||
result instanceof UnknownLocation
|
||||
}
|
||||
|
||||
override string getAPrimaryQlClass() { result = "Specifier" }
|
||||
|
||||
@@ -105,7 +105,7 @@ class AutoType extends TypeTemplateParameter {
|
||||
|
||||
override string getAPrimaryQlClass() { result = "AutoType" }
|
||||
|
||||
override Location getLocation() { result instanceof UnknownDefaultLocation }
|
||||
override Location getLocation() { result instanceof UnknownLocation }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -290,7 +290,7 @@ class Type extends Locatable, @type {
|
||||
*/
|
||||
Type stripType() { result = this }
|
||||
|
||||
override Location getLocation() { result instanceof UnknownDefaultLocation }
|
||||
override Location getLocation() { result instanceof UnknownLocation }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -91,13 +91,13 @@ class Expr extends StmtParent, @expr {
|
||||
*/
|
||||
private Location getExprLocationOverride() {
|
||||
// Base case: the parent has a better location than `this`.
|
||||
this.getDbLocation() instanceof UnknownExprLocation and
|
||||
this.getDbLocation() instanceof UnknownLocation and
|
||||
result = this.getParent().(Expr).getDbLocation() and
|
||||
not result instanceof UnknownLocation
|
||||
or
|
||||
// Recursive case: the parent has a location override that's better than
|
||||
// what `this` has.
|
||||
this.getDbLocation() instanceof UnknownExprLocation and
|
||||
this.getDbLocation() instanceof UnknownLocation and
|
||||
result = this.getParent().(Expr).getExprLocationOverride() and
|
||||
not result instanceof UnknownLocation
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ abstract class InstructionNode0 extends Node0Impl {
|
||||
override Location getLocationImpl() {
|
||||
if exists(instr.getAst().getLocation())
|
||||
then result = instr.getAst().getLocation()
|
||||
else result instanceof UnknownDefaultLocation
|
||||
else result instanceof UnknownLocation
|
||||
}
|
||||
|
||||
final override predicate isGLValue() { exists(getInstructionType(instr, true)) }
|
||||
@@ -227,7 +227,7 @@ abstract class OperandNode0 extends Node0Impl {
|
||||
override Location getLocationImpl() {
|
||||
if exists(op.getDef().getAst().getLocation())
|
||||
then result = op.getDef().getAst().getLocation()
|
||||
else result instanceof UnknownDefaultLocation
|
||||
else result instanceof UnknownLocation
|
||||
}
|
||||
|
||||
final override predicate isGLValue() { exists(getOperandType(op, true)) }
|
||||
|
||||
@@ -847,7 +847,7 @@ class BodyLessParameterNodeImpl extends Node, TBodyLessParameterNodeImpl {
|
||||
result = unique( | | p.getLocation())
|
||||
or
|
||||
count(p.getLocation()) != 1 and
|
||||
result instanceof UnknownDefaultLocation
|
||||
result instanceof UnknownLocation
|
||||
}
|
||||
|
||||
final override string toStringImpl() {
|
||||
@@ -1115,7 +1115,7 @@ private module RawIndirectNodes {
|
||||
final override Location getLocationImpl() {
|
||||
if exists(this.getOperand().getLocation())
|
||||
then result = this.getOperand().getLocation()
|
||||
else result instanceof UnknownDefaultLocation
|
||||
else result instanceof UnknownLocation
|
||||
}
|
||||
|
||||
override string toStringImpl() {
|
||||
@@ -1161,7 +1161,7 @@ private module RawIndirectNodes {
|
||||
final override Location getLocationImpl() {
|
||||
if exists(this.getInstruction().getLocation())
|
||||
then result = this.getInstruction().getLocation()
|
||||
else result instanceof UnknownDefaultLocation
|
||||
else result instanceof UnknownLocation
|
||||
}
|
||||
|
||||
override string toStringImpl() {
|
||||
@@ -1257,7 +1257,7 @@ class FinalParameterNode extends Node, TFinalParameterNode {
|
||||
result = unique( | | p.getLocation())
|
||||
or
|
||||
not exists(unique( | | p.getLocation())) and
|
||||
result instanceof UnknownDefaultLocation
|
||||
result instanceof UnknownLocation
|
||||
}
|
||||
|
||||
override string toStringImpl() { result = stars(this) + p.toString() }
|
||||
@@ -1629,7 +1629,7 @@ class VariableNode extends Node, TGlobalLikeVariableNode {
|
||||
result = unique( | | v.getLocation())
|
||||
or
|
||||
not exists(unique( | | v.getLocation())) and
|
||||
result instanceof UnknownDefaultLocation
|
||||
result instanceof UnknownLocation
|
||||
}
|
||||
|
||||
override string toStringImpl() { result = stars(this) + v.toString() }
|
||||
|
||||
@@ -516,7 +516,7 @@ class FinalParameterUse extends UseImpl, TFinalParameterUse {
|
||||
result = unique( | | p.getLocation())
|
||||
or
|
||||
not exists(unique( | | p.getLocation())) and
|
||||
result instanceof UnknownDefaultLocation
|
||||
result instanceof UnknownLocation
|
||||
}
|
||||
|
||||
override BaseIRVariable getBaseSourceVariable() { result.getIRVariable().getAst() = p }
|
||||
|
||||
@@ -45,7 +45,7 @@ module InstructionConsistency {
|
||||
private class MissingIRFunction extends OptionalIRFunction, TMissingIRFunction {
|
||||
override string toString() { result = "<Missing IRFunction>" }
|
||||
|
||||
override Language::Location getLocation() { result instanceof Language::UnknownDefaultLocation }
|
||||
override Language::Location getLocation() { result instanceof Language::UnknownLocation }
|
||||
}
|
||||
|
||||
private OptionalIRFunction getInstructionIRFunction(Instruction instr) {
|
||||
|
||||
@@ -26,7 +26,7 @@ class ValueNumber extends TValueNumber {
|
||||
l.getFile().getAbsolutePath(), l.getStartLine(), l.getStartColumn(), l.getEndLine(),
|
||||
l.getEndColumn()
|
||||
)
|
||||
else result instanceof Language::UnknownDefaultLocation
|
||||
else result instanceof Language::UnknownLocation
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,7 +45,7 @@ module InstructionConsistency {
|
||||
private class MissingIRFunction extends OptionalIRFunction, TMissingIRFunction {
|
||||
override string toString() { result = "<Missing IRFunction>" }
|
||||
|
||||
override Language::Location getLocation() { result instanceof Language::UnknownDefaultLocation }
|
||||
override Language::Location getLocation() { result instanceof Language::UnknownLocation }
|
||||
}
|
||||
|
||||
private OptionalIRFunction getInstructionIRFunction(Instruction instr) {
|
||||
|
||||
@@ -26,7 +26,7 @@ class ValueNumber extends TValueNumber {
|
||||
l.getFile().getAbsolutePath(), l.getStartLine(), l.getStartColumn(), l.getEndLine(),
|
||||
l.getEndColumn()
|
||||
)
|
||||
else result instanceof Language::UnknownDefaultLocation
|
||||
else result instanceof Language::UnknownLocation
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -45,7 +45,7 @@ module InstructionConsistency {
|
||||
private class MissingIRFunction extends OptionalIRFunction, TMissingIRFunction {
|
||||
override string toString() { result = "<Missing IRFunction>" }
|
||||
|
||||
override Language::Location getLocation() { result instanceof Language::UnknownDefaultLocation }
|
||||
override Language::Location getLocation() { result instanceof Language::UnknownLocation }
|
||||
}
|
||||
|
||||
private OptionalIRFunction getInstructionIRFunction(Instruction instr) {
|
||||
|
||||
@@ -26,7 +26,7 @@ class ValueNumber extends TValueNumber {
|
||||
l.getFile().getAbsolutePath(), l.getStartLine(), l.getStartColumn(), l.getEndLine(),
|
||||
l.getEndColumn()
|
||||
)
|
||||
else result instanceof Language::UnknownDefaultLocation
|
||||
else result instanceof Language::UnknownLocation
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -76,7 +76,7 @@ class GVN extends TValueNumber {
|
||||
l.getFile().getAbsolutePath(), l.getStartLine(), l.getStartColumn(), l.getEndLine(),
|
||||
l.getEndColumn()
|
||||
)
|
||||
else result instanceof UnknownDefaultLocation
|
||||
else result instanceof UnknownLocation
|
||||
}
|
||||
|
||||
final string getKind() {
|
||||
|
||||
@@ -22,8 +22,6 @@ class Location = Cpp::Location;
|
||||
|
||||
class UnknownLocation = Cpp::UnknownLocation;
|
||||
|
||||
class UnknownDefaultLocation = Cpp::UnknownDefaultLocation;
|
||||
|
||||
class File = Cpp::File;
|
||||
|
||||
class AST = Cpp::Locatable;
|
||||
|
||||
@@ -89,7 +89,7 @@ class ZeroBound extends Bound instanceof IRBound::ZeroBound {
|
||||
result = super.getInstruction(delta).getUnconvertedResultExpression()
|
||||
}
|
||||
|
||||
override Location getLocation() { result instanceof UnknownDefaultLocation }
|
||||
override Location getLocation() { result instanceof UnknownLocation }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -61,7 +61,7 @@ class ZeroBound extends Bound, TBoundZero {
|
||||
result.(ConstantValueInstruction).getValue().toInt() = delta
|
||||
}
|
||||
|
||||
override Location getLocation() { result instanceof UnknownDefaultLocation }
|
||||
override Location getLocation() { result instanceof UnknownLocation }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -218,10 +218,10 @@ extractor_version(
|
||||
string frontend_version: string ref
|
||||
)
|
||||
|
||||
@location = @location_stmt | @location_expr | @location_default ;
|
||||
@location = @location_default ;
|
||||
|
||||
/**
|
||||
* The location of an element that is not an expression or a statement.
|
||||
* The location of an element.
|
||||
* The location spans column `startcolumn` of line `startline` to
|
||||
* column `endcolumn` of line `endline` in file `file`.
|
||||
* For more information, see
|
||||
@@ -237,40 +237,6 @@ locations_default(
|
||||
int endColumn: int ref
|
||||
);
|
||||
|
||||
/**
|
||||
* The location of a statement.
|
||||
* The location spans column `startcolumn` of line `startline` to
|
||||
* column `endcolumn` of line `endline` in file `file`.
|
||||
* For more information, see
|
||||
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
|
||||
*/
|
||||
locations_stmt(
|
||||
/** The location of a statement. */
|
||||
unique int id: @location_stmt,
|
||||
int container: @container ref,
|
||||
int startLine: int ref,
|
||||
int startColumn: int ref,
|
||||
int endLine: int ref,
|
||||
int endColumn: int ref
|
||||
);
|
||||
|
||||
/**
|
||||
* The location of an expression.
|
||||
* The location spans column `startcolumn` of line `startline` to
|
||||
* column `endcolumn` of line `endline` in file `file`.
|
||||
* For more information, see
|
||||
* [Locations](https://codeql.github.com/docs/writing-codeql-queries/providing-locations-in-codeql-queries/).
|
||||
*/
|
||||
locations_expr(
|
||||
/** The location of an expression. */
|
||||
unique int id: @location_expr,
|
||||
int container: @container ref,
|
||||
int startLine: int ref,
|
||||
int startColumn: int ref,
|
||||
int endLine: int ref,
|
||||
int endColumn: int ref
|
||||
);
|
||||
|
||||
/** An element for which line-count information is available. */
|
||||
@sourceline = @file | @function | @variable | @enumconstant | @xmllocatable;
|
||||
|
||||
@@ -287,7 +253,7 @@ diagnostics(
|
||||
string error_tag: string ref,
|
||||
string error_message: string ref,
|
||||
string full_error_message: string ref,
|
||||
int location: @location_default ref
|
||||
int location: @location ref
|
||||
);
|
||||
|
||||
files(
|
||||
@@ -332,7 +298,7 @@ case @macroinvocation.kind of
|
||||
macroinvocations(
|
||||
unique int id: @macroinvocation,
|
||||
int macro_id: @ppd_define ref,
|
||||
int location: @location_default ref,
|
||||
int location: @location ref,
|
||||
int kind: int ref
|
||||
);
|
||||
|
||||
@@ -453,7 +419,7 @@ fun_decls(
|
||||
int function: @function ref,
|
||||
int type_id: @type ref,
|
||||
string name: string ref,
|
||||
int location: @location_default ref
|
||||
int location: @location ref
|
||||
);
|
||||
fun_def(unique int id: @fun_decl ref);
|
||||
fun_specialized(unique int id: @fun_decl ref);
|
||||
@@ -505,7 +471,7 @@ var_decls(
|
||||
int variable: @variable ref,
|
||||
int type_id: @type ref,
|
||||
string name: string ref,
|
||||
int location: @location_default ref
|
||||
int location: @location ref
|
||||
);
|
||||
var_def(unique int id: @var_decl ref);
|
||||
var_specialized(int id: @var_decl ref);
|
||||
@@ -522,7 +488,7 @@ var_requires(
|
||||
type_decls(
|
||||
unique int id: @type_decl,
|
||||
int type_id: @type ref,
|
||||
int location: @location_default ref
|
||||
int location: @location ref
|
||||
);
|
||||
type_def(unique int id: @type_decl ref);
|
||||
type_decl_top(
|
||||
@@ -536,8 +502,8 @@ type_requires(
|
||||
namespace_decls(
|
||||
unique int id: @namespace_decl,
|
||||
int namespace_id: @namespace ref,
|
||||
int location: @location_default ref,
|
||||
int bodylocation: @location_default ref
|
||||
int location: @location ref,
|
||||
int bodylocation: @location ref
|
||||
);
|
||||
|
||||
case @using.kind of
|
||||
@@ -549,7 +515,7 @@ case @using.kind of
|
||||
usings(
|
||||
unique int id: @using,
|
||||
int element_id: @element ref,
|
||||
int location: @location_default ref,
|
||||
int location: @location ref,
|
||||
int kind: int ref
|
||||
);
|
||||
|
||||
@@ -563,7 +529,7 @@ static_asserts(
|
||||
unique int id: @static_assert,
|
||||
int condition : @expr ref,
|
||||
string message : string ref,
|
||||
int location: @location_default ref,
|
||||
int location: @location ref,
|
||||
int enclosing : @element ref
|
||||
);
|
||||
|
||||
@@ -619,7 +585,7 @@ enumconstants(
|
||||
int index: int ref,
|
||||
int type_id: @type ref,
|
||||
string name: string ref,
|
||||
int location: @location_default ref
|
||||
int location: @location ref
|
||||
);
|
||||
|
||||
@variable = @localscopevariable | @globalvariable | @membervariable;
|
||||
@@ -980,7 +946,7 @@ template_template_argument_value(
|
||||
concept_templates(
|
||||
unique int concept_id: @concept_template,
|
||||
string name: string ref,
|
||||
int location: @location_default ref
|
||||
int location: @location ref
|
||||
);
|
||||
concept_instantiation(
|
||||
unique int to: @concept_id ref,
|
||||
@@ -1084,7 +1050,7 @@ attributes(
|
||||
int kind: int ref,
|
||||
string name: string ref,
|
||||
string name_space: string ref,
|
||||
int location: @location_default ref
|
||||
int location: @location ref
|
||||
);
|
||||
|
||||
case @attribute.kind of
|
||||
@@ -1101,7 +1067,7 @@ attribute_args(
|
||||
int kind: int ref,
|
||||
int attribute: @attribute ref,
|
||||
int index: int ref,
|
||||
int location: @location_default ref
|
||||
int location: @location ref
|
||||
);
|
||||
|
||||
case @attribute_arg.kind of
|
||||
@@ -1190,7 +1156,7 @@ derivations(
|
||||
int sub: @type ref,
|
||||
int index: int ref,
|
||||
int super: @type ref,
|
||||
int location: @location_default ref
|
||||
int location: @location ref
|
||||
);
|
||||
|
||||
derspecifiers(
|
||||
@@ -1224,7 +1190,7 @@ frienddecls(
|
||||
unique int id: @frienddecl,
|
||||
int type_id: @type ref,
|
||||
int decl_id: @declaration ref,
|
||||
int location: @location_default ref
|
||||
int location: @location ref
|
||||
);
|
||||
|
||||
@declaredtype = @usertype ;
|
||||
@@ -1281,7 +1247,7 @@ frienddecls(
|
||||
comments(
|
||||
unique int id: @comment,
|
||||
string contents: string ref,
|
||||
int location: @location_default ref
|
||||
int location: @location ref
|
||||
);
|
||||
|
||||
commentbinding(
|
||||
@@ -1403,7 +1369,7 @@ namequalifiers(
|
||||
unique int id: @namequalifier,
|
||||
unique int qualifiableelement: @namequalifiableelement ref,
|
||||
int qualifyingelement: @namequalifyingelement ref,
|
||||
int location: @location_default ref
|
||||
int location: @location ref
|
||||
);
|
||||
|
||||
varbind(
|
||||
@@ -1672,7 +1638,7 @@ initialisers(
|
||||
unique int init: @initialiser,
|
||||
int var: @accessible ref,
|
||||
unique int expr: @expr ref,
|
||||
int location: @location_expr ref
|
||||
int location: @location ref
|
||||
);
|
||||
|
||||
braced_initialisers(
|
||||
@@ -1691,7 +1657,7 @@ expr_ancestor(
|
||||
exprs(
|
||||
unique int id: @expr,
|
||||
int kind: int ref,
|
||||
int location: @location_expr ref
|
||||
int location: @location ref
|
||||
);
|
||||
|
||||
expr_reuse(
|
||||
@@ -2165,7 +2131,7 @@ lambda_capture(
|
||||
int field: @membervariable ref,
|
||||
boolean captured_by_reference: boolean ref,
|
||||
boolean is_implicit: boolean ref,
|
||||
int location: @location_default ref
|
||||
int location: @location ref
|
||||
);
|
||||
|
||||
@funbindexpr = @routineexpr
|
||||
@@ -2193,7 +2159,7 @@ fold(
|
||||
stmts(
|
||||
unique int id: @stmt,
|
||||
int kind: int ref,
|
||||
int location: @location_stmt ref
|
||||
int location: @location ref
|
||||
);
|
||||
|
||||
case @stmt.kind of
|
||||
@@ -2378,7 +2344,7 @@ jumpinfo(
|
||||
preprocdirects(
|
||||
unique int id: @preprocdirect,
|
||||
int kind: int ref,
|
||||
int location: @location_default ref
|
||||
int location: @location ref
|
||||
);
|
||||
case @preprocdirect.kind of
|
||||
0 = @ppd_if
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,18 @@
|
||||
class LocationBase = @location_default or @location_stmt or @location_expr;
|
||||
|
||||
class Location extends LocationBase {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
class Container extends @container {
|
||||
string toString() { none() }
|
||||
}
|
||||
|
||||
from Location l, Container c, int startLine, int startColumn, int endLine, int endColumn
|
||||
where
|
||||
locations_default(l, c, startLine, startColumn, endLine, endColumn)
|
||||
or
|
||||
locations_stmt(l, c, startLine, startColumn, endLine, endColumn)
|
||||
or
|
||||
locations_expr(l, c, startLine, startColumn, endLine, endColumn)
|
||||
select l, c, startLine, startColumn, endLine, endColumn
|
||||
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,5 @@
|
||||
description: Merge location tables
|
||||
compatibility: full
|
||||
locations_default.rel: run locations_default.qlo
|
||||
locations_expr.rel: delete
|
||||
locations_stmt.rel: delete
|
||||
@@ -37,7 +37,7 @@ abstract class MaybePreprocessorDirective extends TMaybePreprocessorDirective {
|
||||
class NoPreprocessorDirective extends TNoPreprocessorDirective, MaybePreprocessorDirective {
|
||||
override string toString() { result = "" }
|
||||
|
||||
override Location getLocation() { result instanceof UnknownDefaultLocation }
|
||||
override Location getLocation() { result instanceof UnknownLocation }
|
||||
}
|
||||
|
||||
class SomePreprocessorDirective extends TSomePreprocessorDirective, MaybePreprocessorDirective {
|
||||
|
||||
@@ -15,5 +15,5 @@ query predicate instructionBounds(
|
||||
not valueNumber(b.getInstruction()) = valueNumber(i) and
|
||||
if reason instanceof CondReason
|
||||
then reasonLoc = reason.(CondReason).getCond().getLocation()
|
||||
else reasonLoc instanceof UnknownDefaultLocation
|
||||
else reasonLoc instanceof UnknownLocation
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
| bar.h:0:0:0:0 | bar.h:0:0:0:0 |
|
||||
| file://:0:0:0:0 | file://:0:0:0:0 |
|
||||
| file://:0:0:0:0 | file://:0:0:0:0 |
|
||||
| file://:0:0:0:0 | file://:0:0:0:0 |
|
||||
| includes.c:0:0:0:0 | includes.c:0:0:0:0 |
|
||||
| includes.c:2:1:2:15 | includes.c:2:1:2:15 |
|
||||
| includes.c:4:1:4:16 | includes.c:4:1:4:16 |
|
||||
|
||||
@@ -14,14 +14,14 @@
|
||||
| test.cpp:4:1:4:1 | operator= | false |
|
||||
| test.cpp:4:1:4:1 | operator= | false |
|
||||
| test.cpp:4:1:4:10 | CLASS_DECL | false |
|
||||
| test.cpp:4:1:4:10 | S | false |
|
||||
| test.cpp:4:1:4:10 | S | true |
|
||||
| test.cpp:4:1:4:10 | declaration | true |
|
||||
| test.cpp:4:1:4:10 | definition of S | true |
|
||||
| test.cpp:4:1:4:10 | definition of f | true |
|
||||
| test.cpp:4:1:4:10 | definition of i | true |
|
||||
| test.cpp:4:1:4:10 | definition of j | true |
|
||||
| test.cpp:4:1:4:10 | f | false |
|
||||
| test.cpp:4:1:4:10 | i | false |
|
||||
| test.cpp:4:1:4:10 | f | true |
|
||||
| test.cpp:4:1:4:10 | i | true |
|
||||
| test.cpp:4:1:4:10 | j | true |
|
||||
| test.cpp:4:1:4:10 | return ... | true |
|
||||
| test.cpp:4:1:4:10 | { ... } | true |
|
||||
@@ -30,7 +30,7 @@
|
||||
| test.cpp:8:1:8:13 | declaration | true |
|
||||
| test.cpp:8:1:8:13 | definition of f1 | true |
|
||||
| test.cpp:8:1:8:13 | definition of k | true |
|
||||
| test.cpp:8:1:8:13 | f1 | false |
|
||||
| test.cpp:8:1:8:13 | f1 | true |
|
||||
| test.cpp:8:1:8:13 | k | true |
|
||||
| test.cpp:8:1:8:13 | return ... | true |
|
||||
| test.cpp:8:1:8:13 | { ... } | true |
|
||||
@@ -68,18 +68,18 @@
|
||||
| test.cpp:38:1:38:13 | 1 | true |
|
||||
| test.cpp:38:1:38:13 | ... == ... | true |
|
||||
| test.cpp:38:1:38:13 | STATIC_ASSERT | false |
|
||||
| test.cpp:38:1:38:13 | static_assert(..., "") | false |
|
||||
| test.cpp:38:1:38:13 | static_assert(..., "") | true |
|
||||
| test.cpp:40:1:40:42 | #define ATTRIBUTE [[nodiscard("reason1")]] | false |
|
||||
| test.cpp:42:1:42:9 | ATTRIBUTE | false |
|
||||
| test.cpp:42:1:42:9 | nodiscard | false |
|
||||
| test.cpp:42:1:42:9 | reason1 | false |
|
||||
| test.cpp:42:1:42:9 | nodiscard | true |
|
||||
| test.cpp:42:1:42:9 | reason1 | true |
|
||||
| test.cpp:42:1:42:9 | reason1 | true |
|
||||
| test.cpp:43:5:43:6 | declaration of f2 | false |
|
||||
| test.cpp:43:5:43:6 | f2 | false |
|
||||
| test.cpp:45:1:45:31 | #define ATTRIBUTE_ARG "reason2" | false |
|
||||
| test.cpp:47:3:47:11 | nodiscard | false |
|
||||
| test.cpp:47:13:47:25 | ATTRIBUTE_ARG | false |
|
||||
| test.cpp:47:13:47:25 | reason2 | false |
|
||||
| test.cpp:47:13:47:25 | reason2 | true |
|
||||
| test.cpp:47:13:47:25 | reason2 | true |
|
||||
| test.cpp:48:5:48:6 | declaration of f3 | false |
|
||||
| test.cpp:48:5:48:6 | f3 | false |
|
||||
|
||||
Reference in New Issue
Block a user