Skip to content

Commit 0cf872e

Browse files
authored
Merge pull request #1846 from hvitved/csharp/autoformat
Approved by jbj
2 parents 00fe473 + 75eb7f9 commit 0cf872e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+5186
-8350
lines changed
Lines changed: 26 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
private import internal.EdgeKindInternal
22

33
private newtype TEdgeKind =
4-
TGotoEdge() or // Single successor (including fall-through)
5-
TTrueEdge() or // 'true' edge of conditional branch
6-
TFalseEdge() or // 'false' edge of conditional branch
7-
TExceptionEdge() or // Thrown exception
8-
TDefaultEdge() or // 'default' label of switch
9-
TCaseEdge(string minValue, string maxValue) { // Case label of switch
4+
TGotoEdge() or // Single successor (including fall-through)
5+
TTrueEdge() or // 'true' edge of conditional branch
6+
TFalseEdge() or // 'false' edge of conditional branch
7+
TExceptionEdge() or // Thrown exception
8+
TDefaultEdge() or // 'default' label of switch
9+
TCaseEdge(string minValue, string maxValue) {
10+
// Case label of switch
1011
Language::hasCaseEdge(minValue, maxValue)
1112
}
1213

@@ -24,99 +25,71 @@ abstract class EdgeKind extends TEdgeKind {
2425
* or `IRBlock`.
2526
*/
2627
class GotoEdge extends EdgeKind, TGotoEdge {
27-
override final string toString() {
28-
result = "Goto"
29-
}
28+
final override string toString() { result = "Goto" }
3029
}
3130

32-
GotoEdge gotoEdge() {
33-
result = TGotoEdge()
34-
}
31+
GotoEdge gotoEdge() { result = TGotoEdge() }
3532

3633
/**
3734
* A "true" edge, representing the successor of a conditional branch when the
3835
* condition is non-zero.
3936
*/
4037
class TrueEdge extends EdgeKind, TTrueEdge {
41-
override final string toString() {
42-
result = "True"
43-
}
38+
final override string toString() { result = "True" }
4439
}
4540

46-
TrueEdge trueEdge() {
47-
result = TTrueEdge()
48-
}
41+
TrueEdge trueEdge() { result = TTrueEdge() }
4942

5043
/**
5144
* A "false" edge, representing the successor of a conditional branch when the
5245
* condition is zero.
5346
*/
5447
class FalseEdge extends EdgeKind, TFalseEdge {
55-
override final string toString() {
56-
result = "False"
57-
}
48+
final override string toString() { result = "False" }
5849
}
5950

60-
FalseEdge falseEdge() {
61-
result = TFalseEdge()
62-
}
51+
FalseEdge falseEdge() { result = TFalseEdge() }
6352

6453
/**
6554
* An "exception" edge, representing the successor of an instruction when that
6655
* instruction's evaluation throws an exception.
6756
*/
6857
class ExceptionEdge extends EdgeKind, TExceptionEdge {
69-
override final string toString() {
70-
result = "Exception"
71-
}
58+
final override string toString() { result = "Exception" }
7259
}
7360

74-
ExceptionEdge exceptionEdge() {
75-
result = TExceptionEdge()
76-
}
61+
ExceptionEdge exceptionEdge() { result = TExceptionEdge() }
7762

7863
/**
7964
* A "default" edge, representing the successor of a `Switch` instruction when
8065
* none of the case values matches the condition value.
8166
*/
8267
class DefaultEdge extends EdgeKind, TDefaultEdge {
83-
override final string toString() {
84-
result = "Default"
85-
}
68+
final override string toString() { result = "Default" }
8669
}
8770

88-
DefaultEdge defaultEdge() {
89-
result = TDefaultEdge()
90-
}
71+
DefaultEdge defaultEdge() { result = TDefaultEdge() }
9172

9273
/**
9374
* A "case" edge, representing the successor of a `Switch` instruction when the
9475
* the condition value matches a correponding `case` label.
9576
*/
9677
class CaseEdge extends EdgeKind, TCaseEdge {
9778
string minValue;
79+
9880
string maxValue;
9981

100-
CaseEdge() {
101-
this = TCaseEdge(minValue, maxValue)
102-
}
82+
CaseEdge() { this = TCaseEdge(minValue, maxValue) }
10383

104-
override final string toString() {
105-
if minValue = maxValue then
106-
result = "Case[" + minValue + "]"
107-
else
108-
result = "Case[" + minValue + ".." + maxValue + "]"
84+
final override string toString() {
85+
if minValue = maxValue
86+
then result = "Case[" + minValue + "]"
87+
else result = "Case[" + minValue + ".." + maxValue + "]"
10988
}
11089

111-
string getMinValue() {
112-
result = minValue
113-
}
90+
string getMinValue() { result = minValue }
11491

115-
string getMaxValue() {
116-
result = maxValue
117-
}
92+
string getMaxValue() { result = maxValue }
11893
}
11994

120-
CaseEdge caseEdge(string minValue, string maxValue) {
121-
result = TCaseEdge(minValue, maxValue)
122-
}
95+
CaseEdge caseEdge(string minValue, string maxValue) { result = TCaseEdge(minValue, maxValue) }

cpp/ql/src/semmle/code/cpp/ir/implementation/MemoryAccessKind.qll

Lines changed: 17 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -15,45 +15,33 @@ private newtype TMemoryAccessKind =
1515
* memory result.
1616
*/
1717
class MemoryAccessKind extends TMemoryAccessKind {
18-
string toString() {
19-
none()
20-
}
18+
string toString() { none() }
2119

2220
/**
2321
* Holds if the operand or result accesses memory pointed to by the `AddressOperand` on the
2422
* same instruction.
2523
*/
26-
predicate usesAddressOperand() {
27-
none()
28-
}
24+
predicate usesAddressOperand() { none() }
2925
}
3026

3127
/**
3228
* The operand or result accesses memory at the address specified by the `AddressOperand` on the
3329
* same instruction.
3430
*/
3531
class IndirectMemoryAccess extends MemoryAccessKind, TIndirectMemoryAccess {
36-
override string toString() {
37-
result = "indirect"
38-
}
39-
40-
override final predicate usesAddressOperand() {
41-
any()
42-
}
32+
override string toString() { result = "indirect" }
33+
34+
final override predicate usesAddressOperand() { any() }
4335
}
4436

4537
/**
4638
* The operand or result may access some, all, or none of the memory at the address specified by the
4739
* `AddressOperand` on the same instruction.
4840
*/
4941
class IndirectMayMemoryAccess extends MemoryAccessKind, TIndirectMayMemoryAccess {
50-
override string toString() {
51-
result = "indirect(may)"
52-
}
42+
override string toString() { result = "indirect(may)" }
5343

54-
override final predicate usesAddressOperand() {
55-
any()
56-
}
44+
final override predicate usesAddressOperand() { any() }
5745
}
5846

5947
/**
@@ -62,13 +50,9 @@ class IndirectMayMemoryAccess extends MemoryAccessKind, TIndirectMayMemoryAccess
6250
* `BufferSizeOperand`.
6351
*/
6452
class BufferMemoryAccess extends MemoryAccessKind, TBufferMemoryAccess {
65-
override string toString() {
66-
result = "buffer"
67-
}
53+
override string toString() { result = "buffer" }
6854

69-
override final predicate usesAddressOperand() {
70-
any()
71-
}
55+
final override predicate usesAddressOperand() { any() }
7256
}
7357

7458
/**
@@ -77,69 +61,53 @@ class BufferMemoryAccess extends MemoryAccessKind, TBufferMemoryAccess {
7761
* elements given by the `BufferSizeOperand`.
7862
*/
7963
class BufferMayMemoryAccess extends MemoryAccessKind, TBufferMayMemoryAccess {
80-
override string toString() {
81-
result = "buffer(may)"
82-
}
64+
override string toString() { result = "buffer(may)" }
8365

84-
override final predicate usesAddressOperand() {
85-
any()
86-
}
66+
final override predicate usesAddressOperand() { any() }
8767
}
8868

8969
/**
9070
* The operand or result accesses all memory whose address has escaped.
9171
*/
9272
class EscapedMemoryAccess extends MemoryAccessKind, TEscapedMemoryAccess {
93-
override string toString() {
94-
result = "escaped"
95-
}
73+
override string toString() { result = "escaped" }
9674
}
9775

9876
/**
9977
* The operand or result may access all memory whose address has escaped.
10078
*/
10179
class EscapedMayMemoryAccess extends MemoryAccessKind, TEscapedMayMemoryAccess {
102-
override string toString() {
103-
result = "escaped(may)"
104-
}
80+
override string toString() { result = "escaped(may)" }
10581
}
10682

10783
/**
10884
* The operand is a Phi operand, which accesses the same memory as its
10985
* definition.
11086
*/
11187
class PhiMemoryAccess extends MemoryAccessKind, TPhiMemoryAccess {
112-
override string toString() {
113-
result = "phi"
114-
}
88+
override string toString() { result = "phi" }
11589
}
11690

11791
/**
11892
* The operand is a ChiTotal operand, which accesses the same memory as its
11993
* definition.
12094
*/
12195
class ChiTotalMemoryAccess extends MemoryAccessKind, TChiTotalMemoryAccess {
122-
override string toString() {
123-
result = "chi(total)"
124-
}
96+
override string toString() { result = "chi(total)" }
12597
}
12698

12799
/**
128100
* The operand is a ChiPartial operand, which accesses the same memory as its
129101
* definition.
130102
*/
131103
class ChiPartialMemoryAccess extends MemoryAccessKind, TChiPartialMemoryAccess {
132-
override string toString() {
133-
result = "chi(partial)"
134-
}
104+
override string toString() { result = "chi(partial)" }
135105
}
136106

137107
/**
138108
* The operand accesses memory not modeled in SSA. Used only on the result of
139109
* `UnmodeledDefinition` and on the operands of `UnmodeledUse`.
140110
*/
141111
class UnmodeledMemoryAccess extends MemoryAccessKind, TUnmodeledMemoryAccess {
142-
override string toString() {
143-
result = "unmodeled"
144-
}
112+
override string toString() { result = "unmodeled" }
145113
}

0 commit comments

Comments
 (0)