Skip to content

Commit 2dcfffd

Browse files
committed
Add getOrderDisambiguation to signature and use it
1 parent 92524ec commit 2dcfffd

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

shared/controlflow/codeql/controlflow/Cfg.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1320,7 +1320,9 @@ module MakeWithSplitting<
13201320
private module PrintGraphInput implements Pp::InputSig<Location> {
13211321
class Callable = CfgScope;
13221322

1323-
class Node = FinalNode;
1323+
class Node extends FinalNode {
1324+
string getOrderDisambiguation() { result = "" }
1325+
}
13241326

13251327
Node getASuccessor(Node n, string s) {
13261328
exists(SuccessorType t |

shared/controlflow/codeql/controlflow/PrintGraph.qll

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ signature module InputSig<LocationSig Location> {
1818
Location getLocation();
1919

2020
string toString();
21+
22+
/** Gets a string to distinguish nodes that have the same location and toString value. */
23+
string getOrderDisambiguation();
2124
}
2225

2326
Node getASuccessor(Node n, string label);
@@ -53,7 +56,10 @@ module PrintGraph<LocationSig Location, InputSig<Location> Input> {
5356
p.getLocation()
5457
.hasLocationInfo(filePath, startLine, startColumn, endLine, endColumn)
5558
|
56-
p order by filePath, startLine, startColumn, endLine, endColumn, p.toString()
59+
p
60+
order by
61+
filePath, startLine, startColumn, endLine, endColumn, p.toString(),
62+
p.getOrderDisambiguation()
5763
)
5864
).toString()
5965
}
@@ -87,7 +93,8 @@ module PrintGraph<LocationSig Location, InputSig<Location> Input> {
8793
|
8894
edge, "\n"
8995
order by
90-
filePath, startLine, startColumn, endLine, endColumn, pred.toString()
96+
filePath, startLine, startColumn, endLine, endColumn, pred.toString(),
97+
pred.getOrderDisambiguation()
9198
)
9299
}
93100

@@ -165,8 +172,6 @@ module PrintGraph<LocationSig Location, InputSig<Location> Input> {
165172
smallestEnclosingScope(getFileBySourceArchiveName(selectedSourceFile()),
166173
selectedSourceLine(), selectedSourceColumn())
167174
}
168-
169-
string getOrderDisambiguation() { result = "" }
170175
}
171176

172177
private module Output = TestOutput<RelevantNode>;

0 commit comments

Comments
 (0)