Skip to content

Commit 8188e28

Browse files
committed
QL: Autoformat
1 parent 6632b7d commit 8188e28

File tree

1 file changed

+38
-103
lines changed

1 file changed

+38
-103
lines changed

ql/ql/src/codeql_ql/dataflow/DataFlow.qll

Lines changed: 38 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ private import internal.GlobalFlow as GlobalFlow
1616
*/
1717
class Node extends TNode {
1818
string toString() { none() } // overridden in subclasses
19+
1920
Location getLocation() { none() } // overridden in subclasses
2021

2122
/**
@@ -48,31 +49,21 @@ class AstNodeNode extends Node, MkAstNodeNode {
4849

4950
AstNodeNode() { this = MkAstNodeNode(ast) }
5051

51-
override string toString() {
52-
result = ast.toString()
53-
}
52+
override string toString() { result = ast.toString() }
5453

55-
override Location getLocation() {
56-
result = ast.getLocation()
57-
}
54+
override Location getLocation() { result = ast.getLocation() }
5855

5956
/** Gets the AST node. */
60-
AstNode getAstNode() {
61-
result = ast
62-
}
57+
AstNode getAstNode() { result = ast }
6358

64-
override Predicate getEnclosingPredicate() {
65-
result = ast.getEnclosingPredicate()
66-
}
59+
override Predicate getEnclosingPredicate() { result = ast.getEnclosingPredicate() }
6760
}
6861

6962
/**
7063
* Gets the data-flow node correspoinding to the given AST node.
7164
*/
7265
pragma[inline]
73-
Node astNode(AstNode node) {
74-
result = MkAstNodeNode(node)
75-
}
66+
Node astNode(AstNode node) { result = MkAstNodeNode(node) }
7667

7768
/**
7869
* A data-flow node representing a variable within a specific scope.
@@ -84,35 +75,27 @@ class ScopedVariableNode extends Node, MkScopedVariable {
8475
ScopedVariableNode() { this = MkScopedVariable(var, scope) }
8576

8677
override string toString() {
87-
result = "Variable '" + var.getName() + "' scoped to " + scope.getLocation().getStartLine() + ":" + scope.getLocation().getStartColumn()
78+
result =
79+
"Variable '" + var.getName() + "' scoped to " + scope.getLocation().getStartLine() + ":" +
80+
scope.getLocation().getStartColumn()
8881
}
8982

90-
override Location getLocation() {
91-
result = scope.getLocation()
92-
}
83+
override Location getLocation() { result = scope.getLocation() }
9384

9485
/** Gets the variable being refined to a specific scope. */
95-
VarDef getVariable() {
96-
result = var
97-
}
86+
VarDef getVariable() { result = var }
9887

9988
/** Gets the scope to which this variable has been refined. */
100-
AstNode getScope() {
101-
result = scope
102-
}
89+
AstNode getScope() { result = scope }
10390

104-
override Predicate getEnclosingPredicate() {
105-
result = var.getEnclosingPredicate()
106-
}
91+
override Predicate getEnclosingPredicate() { result = var.getEnclosingPredicate() }
10792
}
10893

10994
/**
11095
* Gets the data-flow node corresponding to `var` restricted to `scope`.
11196
*/
11297
pragma[inline]
113-
Node scopedVariable(VarDef var, AstNode scope) {
114-
result = MkScopedVariable(var, scope)
115-
}
98+
Node scopedVariable(VarDef var, AstNode scope) { result = MkScopedVariable(var, scope) }
11699

117100
/**
118101
* A data-flow node representing `this` within a class predicate, charpred, or newtype branch.
@@ -122,31 +105,21 @@ class ThisNode extends Node, MkThisNode {
122105

123106
ThisNode() { this = MkThisNode(pred) }
124107

125-
override string toString() {
126-
result = "'this' in " + pred.getName()
127-
}
108+
override string toString() { result = "'this' in " + pred.getName() }
128109

129-
override Location getLocation() {
130-
result = pred.getLocation()
131-
}
110+
override Location getLocation() { result = pred.getLocation() }
132111

133112
/** Gets the class predicate, charpred, or newtype branch whose 'this' parameter is represented by this node. */
134-
Predicate getPredicate() {
135-
result = pred
136-
}
113+
Predicate getPredicate() { result = pred }
137114

138-
override Predicate getEnclosingPredicate() {
139-
result = pred
140-
}
115+
override Predicate getEnclosingPredicate() { result = pred }
141116
}
142117

143118
/**
144119
* Gets the data-flow node representing `this` within the given class predicate, charpred, or newtype branch.
145120
*/
146121
pragma[inline]
147-
Node thisNode(Predicate pred) {
148-
result = MkThisNode(pred)
149-
}
122+
Node thisNode(Predicate pred) { result = MkThisNode(pred) }
150123

151124
/**
152125
* A data-flow node representing `result` within a predicate that has a result.
@@ -156,31 +129,21 @@ class ResultNode extends Node, MkResultNode {
156129

157130
ResultNode() { this = MkResultNode(pred) }
158131

159-
override string toString() {
160-
result = "'result' in " + pred.getName()
161-
}
132+
override string toString() { result = "'result' in " + pred.getName() }
162133

163-
override Location getLocation() {
164-
result = pred.getLocation()
165-
}
134+
override Location getLocation() { result = pred.getLocation() }
166135

167136
/** Gets the predicate whose 'result' parameter is represented by this node. */
168-
Predicate getPredicate() {
169-
result = pred
170-
}
137+
Predicate getPredicate() { result = pred }
171138

172-
override Predicate getEnclosingPredicate() {
173-
result = pred
174-
}
139+
override Predicate getEnclosingPredicate() { result = pred }
175140
}
176141

177142
/**
178143
* Gets the data-flow node representing `result` within the given predicate.
179144
*/
180145
pragma[inline]
181-
Node resultNode(Predicate pred) {
182-
result = MkResultNode(pred)
183-
}
146+
Node resultNode(Predicate pred) { result = MkResultNode(pred) }
184147

185148
/**
186149
* A data-flow node representing the view of a field in the enclosing class, as seen
@@ -193,39 +156,25 @@ class FieldNode extends Node, MkFieldNode {
193156
FieldNode() { this = MkFieldNode(pred, fieldDecl) }
194157

195158
/** Gets the member predicate or charpred for which this node represents access to the field. */
196-
Predicate getPredicate() {
197-
result = pred
198-
}
159+
Predicate getPredicate() { result = pred }
199160

200-
FieldDecl getFieldDeclaration() {
201-
result = fieldDecl
202-
}
161+
FieldDecl getFieldDeclaration() { result = fieldDecl }
203162

204-
string getFieldName() {
205-
result = fieldDecl.getName()
206-
}
163+
string getFieldName() { result = fieldDecl.getName() }
207164

208-
override string toString() {
209-
result = "'" + this.getFieldName() + "' in " + pred.getName()
210-
}
165+
override string toString() { result = "'" + this.getFieldName() + "' in " + pred.getName() }
211166

212-
override Location getLocation() {
213-
result = pred.getLocation()
214-
}
167+
override Location getLocation() { result = pred.getLocation() }
215168

216-
override Predicate getEnclosingPredicate() {
217-
result = pred
218-
}
169+
override Predicate getEnclosingPredicate() { result = pred }
219170
}
220171

221172
/**
222173
* Gets the data-flow node representing the given predicate's view of the given field
223174
* in the enclosing class.
224175
*/
225176
pragma[inline]
226-
Node fieldNode(Predicate pred, FieldDecl fieldDecl) {
227-
result = MkFieldNode(pred, fieldDecl)
228-
}
177+
Node fieldNode(Predicate pred, FieldDecl fieldDecl) { result = MkFieldNode(pred, fieldDecl) }
229178

230179
/**
231180
* A collection of data-flow nodes in the same predicate, locally bound by equalities.
@@ -238,14 +187,10 @@ class SuperNode extends LocalFlow::TSuperNode {
238187
SuperNode() { this = LocalFlow::MkSuperNode(repr) }
239188

240189
/** Gets a data-flow node that is part of this super node. */
241-
Node getANode() {
242-
LocalFlow::getRepr(result) = repr
243-
}
190+
Node getANode() { LocalFlow::getRepr(result) = repr }
244191

245192
/** Gets an AST node from any of the nodes in this super node. */
246-
AstNode asAstNode() {
247-
result = getANode().asAstNode()
248-
}
193+
AstNode asAstNode() { result = getANode().asAstNode() }
249194

250195
/**
251196
* Gets a single node from this super node.
@@ -255,16 +200,12 @@ class SuperNode extends LocalFlow::TSuperNode {
255200
* - An `AstNodeNode` is preferred over other nodes.
256201
* - A node occuring earlier is preferred over one occurring later.
257202
*/
258-
Node getArbitraryRepr() {
259-
result = min(Node n | n = getANode() | n order by getInternalId(n))
260-
}
203+
Node getArbitraryRepr() { result = min(Node n | n = getANode() | n order by getInternalId(n)) }
261204

262205
/**
263206
* Gets the predicate containing all nodes that are part of this super node.
264207
*/
265-
Predicate getEnclosingPredicate() {
266-
result = getANode().getEnclosingPredicate()
267-
}
208+
Predicate getEnclosingPredicate() { result = getANode().getEnclosingPredicate() }
268209

269210
/** Gets a string representation of this super node. */
270211
string toString() {
@@ -275,14 +216,10 @@ class SuperNode extends LocalFlow::TSuperNode {
275216
}
276217

277218
/** Gets the location of an arbitrary node in this super node. */
278-
Location getLocation() {
279-
result = getArbitraryRepr().getLocation()
280-
}
219+
Location getLocation() { result = getArbitraryRepr().getLocation() }
281220

282221
/** Gets any member call whose receiver is in the same super node. */
283-
MemberCall getALocalMemberCall() {
284-
superNode(result.getBase()) = this
285-
}
222+
MemberCall getALocalMemberCall() { superNode(result.getBase()) = this }
286223

287224
/** Gets any member call whose receiver is in the same super node. */
288225
MemberCall getALocalMemberCall(string name) {
@@ -382,9 +319,7 @@ class SuperNode extends LocalFlow::TSuperNode {
382319

383320
/** Gets the super node for the given AST node. */
384321
pragma[inline]
385-
SuperNode superNode(AstNode node) {
386-
result = astNode(node).getSuperNode()
387-
}
322+
SuperNode superNode(AstNode node) { result = astNode(node).getSuperNode() }
388323

389324
/**
390325
* A summary of the steps needed to reach a node in the global data flow graph,

0 commit comments

Comments
 (0)