зеркало из https://github.com/github/codeql.git
C++: Fix wobble in PrintAST test
PrintAST.ql orders the functions by location, then in lexicographical order of the function signature. This is supposed to ensure a stable ordering, but functions without a location were not getting assigned an order at all.
This commit is contained in:
Родитель
7cae9be4bf
Коммит
c4d6e1b01c
|
@ -39,6 +39,26 @@ private Location getRepresentativeLocation(Locatable ast) {
|
|||
result = rank[1](Location loc | loc = ast.getLocation() | loc order by loc.toString())
|
||||
}
|
||||
|
||||
/**
|
||||
* Computes the sort keys to sort the given AST node by location. An AST without
|
||||
* a location gets an empty file name and a zero line and column number.
|
||||
*/
|
||||
private predicate locationSortKeys(Locatable ast, string file, int line,
|
||||
int column) {
|
||||
if exists(getRepresentativeLocation(ast)) then (
|
||||
exists(Location loc |
|
||||
loc = getRepresentativeLocation(ast) and
|
||||
file = loc.getFile().toString() and
|
||||
line = loc.getStartLine() and
|
||||
column = loc.getStartColumn()
|
||||
)
|
||||
) else (
|
||||
file = "" and
|
||||
line = 0 and
|
||||
column = 0
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Most nodes are just a wrapper around `Locatable`, but we do synthesize new
|
||||
* nodes for things like parameter lists and constructor init lists.
|
||||
|
@ -482,12 +502,14 @@ class FunctionNode extends ASTNode {
|
|||
}
|
||||
|
||||
private int getOrder() {
|
||||
this = rank[result](FunctionNode node, Function function, Location loc |
|
||||
node.getAST() = function and loc = getRepresentativeLocation(function) |
|
||||
this = rank[result](FunctionNode node, Function function, string file,
|
||||
int line, int column |
|
||||
node.getAST() = function and
|
||||
locationSortKeys(function, file, line, column) |
|
||||
node order by
|
||||
loc.getFile().toString(),
|
||||
loc.getStartLine(),
|
||||
loc.getStartColumn(),
|
||||
file,
|
||||
line,
|
||||
column,
|
||||
function.getFullSignature()
|
||||
)
|
||||
}
|
||||
|
|
|
@ -2,16 +2,22 @@
|
|||
#-----| params:
|
||||
#-----| __va_list_tag::operator=() -> __va_list_tag &
|
||||
#-----| params:
|
||||
#-----| operator new(unsigned long) -> void *
|
||||
#-----| params:
|
||||
#-----| 0: p#0
|
||||
#-----| Type = unsigned long
|
||||
#-----| operator delete(void *, unsigned long) -> void
|
||||
#-----| params:
|
||||
#-----| 0: p#0
|
||||
#-----| Type = void *
|
||||
#-----| 1: p#1
|
||||
#-----| Type = unsigned long
|
||||
#-----| operator delete[](void *, unsigned long) -> void
|
||||
#-----| params:
|
||||
#-----| 0: p#0
|
||||
#-----| Type = void *
|
||||
#-----| 1: p#1
|
||||
#-----| Type = unsigned long
|
||||
#-----| operator new(unsigned long) -> void *
|
||||
#-----| params:
|
||||
#-----| 0: p#0
|
||||
#-----| Type = unsigned long
|
||||
#-----| operator new(unsigned long, align_val_t) -> void *
|
||||
#-----| params:
|
||||
#-----| 0: p#0
|
||||
|
@ -22,12 +28,6 @@
|
|||
#-----| params:
|
||||
#-----| 0: p#0
|
||||
#-----| Type = unsigned long
|
||||
#-----| operator delete[](void *, unsigned long) -> void
|
||||
#-----| params:
|
||||
#-----| 0: p#0
|
||||
#-----| Type = void *
|
||||
#-----| 1: p#1
|
||||
#-----| Type = unsigned long
|
||||
#-----| operator new[](unsigned long, align_val_t) -> void *
|
||||
#-----| params:
|
||||
#-----| 0: p#0
|
||||
|
|
Загрузка…
Ссылка в новой задаче