Skip to content

Commit a75e249

Browse files
committed
C++: Autoformat test.
1 parent 18e60fa commit a75e249

File tree

1 file changed

+37
-34
lines changed

1 file changed

+37
-34
lines changed

cpp/ql/test/library-tests/allocators/allocators.ql

Lines changed: 37 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
import default
22
import semmle.code.cpp.models.implementations.Allocation
33

4-
query predicate newExprs(NewExpr expr, string type, string sig, int size, int alignment, string form, string placement) {
4+
query predicate newExprs(
5+
NewExpr expr, string type, string sig, int size, int alignment, string form, string placement
6+
) {
57
exists(Function allocator, Type allocatedType |
68
expr.getAllocator() = allocator and
79
sig = allocator.getFullSignature() and
810
allocatedType = expr.getAllocatedType() and
911
type = allocatedType.toString() and
1012
size = allocatedType.getSize() and
1113
alignment = allocatedType.getAlignment() and
12-
if expr.hasAlignedAllocation() then form = "aligned" else form = "" and
13-
if exists(expr.getPlacementPointer()) then placement = expr.getPlacementPointer().toString() else placement = ""
14+
(if expr.hasAlignedAllocation() then form = "aligned" else form = "") and
15+
if exists(expr.getPlacementPointer())
16+
then placement = expr.getPlacementPointer().toString()
17+
else placement = ""
1418
)
1519
}
1620

@@ -29,7 +33,9 @@ query predicate newArrayExprs(
2933
alignment = elementType.getAlignment() and
3034
(if expr.hasAlignedAllocation() then form = "aligned" else form = "") and
3135
extents = concat(Expr e | e = expr.getExtent() | e.toString(), ", ") and
32-
if exists(expr.getPlacementPointer()) then placement = expr.getPlacementPointer().toString() else placement = ""
36+
if exists(expr.getPlacementPointer())
37+
then placement = expr.getPlacementPointer().toString()
38+
else placement = ""
3339
)
3440
}
3541

@@ -106,55 +112,52 @@ query predicate deleteArrayExprs(
106112
}
107113

108114
string describeAllocationFunction(AllocationFunction f) {
109-
result = "getSizeArg = " + f.getSizeArg().toString()
110-
or
111-
result = "getSizeMult = " + f.getSizeMult().toString()
112-
or
113-
result = "getReallocPtrArg = " + f.getReallocPtrArg().toString()
114-
or
115-
(
116-
f.requiresDealloc() and
117-
result = "requiresDealloc"
118-
)
119-
or
120-
result = "getPlacementArgument = " + f.(OperatorNewAllocationFunction).getPlacementArgument().toString()
115+
result = "getSizeArg = " + f.getSizeArg().toString()
116+
or
117+
result = "getSizeMult = " + f.getSizeMult().toString()
118+
or
119+
result = "getReallocPtrArg = " + f.getReallocPtrArg().toString()
120+
or
121+
f.requiresDealloc() and
122+
result = "requiresDealloc"
123+
or
124+
result =
125+
"getPlacementArgument = " + f.(OperatorNewAllocationFunction).getPlacementArgument().toString()
121126
}
122127

123128
query predicate allocationFunctions(AllocationFunction f, string descr) {
124-
descr = concat(describeAllocationFunction(f), ", ")
129+
descr = concat(describeAllocationFunction(f), ", ")
125130
}
126131

127132
string describeAllocationExpr(AllocationExpr e) {
128-
result = "getSizeExpr = " + e.getSizeExpr().toString()
129-
or
130-
result = "getSizeMult = " + e.getSizeMult().toString()
131-
or
132-
result = "getSizeBytes = " + e.getSizeBytes().toString()
133-
or
134-
result = "getReallocPtr = " + e.getReallocPtr().toString()
135-
or
136-
(
137-
e.requiresDealloc() and
138-
result = "requiresDealloc"
139-
)
133+
result = "getSizeExpr = " + e.getSizeExpr().toString()
134+
or
135+
result = "getSizeMult = " + e.getSizeMult().toString()
136+
or
137+
result = "getSizeBytes = " + e.getSizeBytes().toString()
138+
or
139+
result = "getReallocPtr = " + e.getReallocPtr().toString()
140+
or
141+
e.requiresDealloc() and
142+
result = "requiresDealloc"
140143
}
141144

142145
query predicate allocationExprs(AllocationExpr e, string descr) {
143-
descr = concat(describeAllocationExpr(e), ", ")
146+
descr = concat(describeAllocationExpr(e), ", ")
144147
}
145148

146149
string describeDeallocationFunction(DeallocationFunction f) {
147-
result = "getFreedArg = " + f.getFreedArg().toString()
150+
result = "getFreedArg = " + f.getFreedArg().toString()
148151
}
149152

150153
query predicate deallocationFunctions(DeallocationFunction f, string descr) {
151-
descr = concat(describeDeallocationFunction(f), ", ")
154+
descr = concat(describeDeallocationFunction(f), ", ")
152155
}
153156

154157
string describeDeallocationExpr(DeallocationExpr e) {
155-
result = "getFreedExpr = " + e.getFreedExpr().toString()
158+
result = "getFreedExpr = " + e.getFreedExpr().toString()
156159
}
157160

158161
query predicate deallocationExprs(DeallocationExpr e, string descr) {
159-
descr = concat(describeDeallocationExpr(e), ", ")
162+
descr = concat(describeDeallocationExpr(e), ", ")
160163
}

0 commit comments

Comments
 (0)