C++: Move private stuff from 'DataFlowUtil' to public stuff 'DataFlowPrivate'. Also make 'PostUpdateNodeImpl' public in 'DataFlowUtil'. Sadly, this means that it's visible at the query level (as DataFlow::PostUpdateNodeImpl), but I've added a big INTERNAL QLDoc on it to make sure people don't use it.

This commit is contained in:
Mathias Vorreiter Pedersen
2023-12-19 10:41:35 +01:00
parent f50817e92a
commit 501645920f
2 changed files with 39 additions and 42 deletions

View File

@@ -59,6 +59,41 @@ private module Cached {
import Cached
private import Nodes0
/**
* A module for calculating the number of stars (i.e., `*`s) needed for various
* dataflow node `toString` predicates.
*/
module NodeStars {
private int getNumberOfIndirections(Node n) {
result = n.(RawIndirectOperand).getIndirectionIndex()
or
result = n.(RawIndirectInstruction).getIndirectionIndex()
or
result = n.(VariableNode).getIndirectionIndex()
or
result = n.(PostUpdateNodeImpl).getIndirectionIndex()
or
result = n.(FinalParameterNode).getIndirectionIndex()
}
private int maxNumberOfIndirections() { result = max(getNumberOfIndirections(_)) }
private string repeatStars(int n) {
n = 0 and result = ""
or
n = [1 .. maxNumberOfIndirections()] and
result = "*" + repeatStars(n - 1)
}
/**
* Gets the number of stars (i.e., `*`s) needed to produce the `toString`
* output for `n`.
*/
string stars(Node n) { result = repeatStars(getNumberOfIndirections(n)) }
}
import NodeStars
class Node0Impl extends TIRDataFlowNode0 {
/**
* INTERNAL: Do not use.

View File

@@ -486,47 +486,6 @@ class Node extends TIRDataFlowNode {
}
}
private string toExprString(Node n) {
not isDebugMode() and
(
result = n.asExpr(0).toString()
or
not exists(n.asExpr()) and
result = stars(n) + n.asIndirectExpr(0, 1).toString()
)
}
private module NodeStars {
private int getNumberOfIndirections(Node n) {
result = n.(RawIndirectOperand).getIndirectionIndex()
or
result = n.(RawIndirectInstruction).getIndirectionIndex()
or
result = n.(VariableNode).getIndirectionIndex()
or
result = n.(PostUpdateNodeImpl).getIndirectionIndex()
or
result = n.(FinalParameterNode).getIndirectionIndex()
}
private int maxNumberOfIndirections() { result = max(getNumberOfIndirections(_)) }
private string repeatStars(int n) {
n = 0 and result = ""
or
n = [1 .. maxNumberOfIndirections()] and
result = "*" + repeatStars(n - 1)
}
/**
* Gets the number of stars (i.e., `*`s) needed to produce the `toString`
* output for `n`.
*/
string stars(Node n) { result = repeatStars(getNumberOfIndirections(n)) }
}
private import NodeStars
/**
* A class that lifts pre-SSA dataflow nodes to regular dataflow nodes.
*/
@@ -589,7 +548,10 @@ Type stripPointer(Type t) {
result = t.(FunctionPointerIshType).getBaseType()
}
private class PostUpdateNodeImpl extends PartialDefinitionNode, TPostUpdateNodeImpl {
/**
* INTERNAL: Do not use.
*/
class PostUpdateNodeImpl extends PartialDefinitionNode, TPostUpdateNodeImpl {
int indirectionIndex;
Operand operand;