Skip to content

Commit 3fe40d3

Browse files
committed
Replace getOrderDisambiguation with a module predicate
1 parent a1489be commit 3fe40d3

File tree

5 files changed

+14
-16
lines changed

5 files changed

+14
-16
lines changed

csharp/ql/test/library-tests/controlflow/graph/Common.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class SourceControlFlowNode extends ControlFlow::Node {
1515
not this.getLocation().getFile() instanceof StubFile and
1616
not this.getLocation().getFile().fromLibrary()
1717
}
18+
19+
string getOrderDisambiguation() { result = "" }
1820
}
1921

2022
class SourceBasicBlock extends ControlFlow::BasicBlock {

java/ql/lib/semmle/code/java/ControlFlowGraph.qll

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1783,11 +1783,7 @@ private module PrintGraphInput implements PrintGraph::InputSig<Location> {
17831783

17841784
class Callable = J::Callable;
17851785

1786-
final private class FinalControlFlowNode = J::ControlFlowNode;
1787-
1788-
class Node extends FinalControlFlowNode {
1789-
string getOrderDisambiguation() { result = "" }
1790-
}
1786+
class Node = J::ControlFlowNode;
17911787

17921788
predicate edge(Node node1, string s, Node node2) {
17931789
exists(SuccessorType t |

shared/controlflow/codeql/controlflow/Cfg.qll

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1315,14 +1315,12 @@ module MakeWithSplitting<
13151315

13161316
private import codeql.util.PrintGraph as Pp
13171317

1318-
final private class FinalNode = Node;
1318+
private class NodeAlias = Node;
13191319

13201320
private module PrintGraphInput implements Pp::InputSig<Location> {
13211321
class Callable = CfgScope;
13221322

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

13271325
predicate edge(Node node1, string label, Node node2) {
13281326
exists(SuccessorType t |

shared/dataflow/codeql/dataflow/PrintDfg.qll

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ module MakePrintDfg<
2121
class Callable = DataFlowLang::DataFlowCallable;
2222

2323
class Node extends FinalNode {
24-
string getOrderDisambiguation() { result = DataFlowLang::nodeGetOrderDisambiguation(this) }
25-
2624
Callable getEnclosingCallable() { result = DataFlowLang::nodeGetEnclosingCallable(this) }
2725
}
2826

@@ -41,6 +39,10 @@ module MakePrintDfg<
4139
or
4240
node1 = node2.(PostUpdateNode).getPreUpdateNode() and label = "post-update"
4341
}
42+
43+
string nodeGetOrderDisambiguation(Node node) {
44+
result = DataFlowLang::nodeGetOrderDisambiguation(node)
45+
}
4446
}
4547

4648
import Pp::PrintGraph<Location, PrintGraphInput>

shared/util/codeql/util/PrintGraph.qll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ 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();
2421
}
2522

2623
predicate edge(Node node1, string label, Node node2);
24+
25+
/** Gets a string to distinguish nodes that have the same location and toString value. */
26+
default string nodeGetOrderDisambiguation(Node node) { result = "" }
2727
}
2828

2929
/** Provides modules for printing flow graphs. */
@@ -59,7 +59,7 @@ module PrintGraph<LocationSig Location, InputSig<Location> Input> {
5959
p
6060
order by
6161
filePath, startLine, startColumn, endLine, endColumn, p.toString(),
62-
p.getOrderDisambiguation()
62+
nodeGetOrderDisambiguation(p)
6363
)
6464
).toString()
6565
}
@@ -94,7 +94,7 @@ module PrintGraph<LocationSig Location, InputSig<Location> Input> {
9494
edge, "\n"
9595
order by
9696
filePath, startLine, startColumn, endLine, endColumn, pred.toString(),
97-
pred.getOrderDisambiguation()
97+
nodeGetOrderDisambiguation(pred)
9898
)
9999
}
100100

0 commit comments

Comments
 (0)