Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2d3a742

Browse files
author
Robert Marsh
committed
C++: autoformat and accept test changes
1 parent 6922074 commit 2d3a742

8 files changed

Lines changed: 114 additions & 113 deletions

File tree

cpp/ql/src/semmle/code/cpp/ir/dataflow/DefaultTaintTracking.qll

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,9 @@ predicate tainted(Expr source, Element tainted) {
348348
)
349349
}
350350

351-
predicate tainted_instruction(Function sourceFunc,Instruction source, Function sinkFunc, Instruction sink) {
351+
predicate tainted_instruction(
352+
Function sourceFunc, Instruction source, Function sinkFunc, Instruction sink
353+
) {
352354
sourceFunc = source.getEnclosingFunction() and
353355
sinkFunc = sink.getEnclosingFunction() and
354356
exists(DefaultTaintTrackingCfg cfg |

cpp/ql/src/semmle/code/cpp/ir/dataflow/internal/DataFlowPrivate.qll

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class ArgumentNode extends Node {
2424
DataFlowCall getCall() { this.argumentOf(result, _) }
2525
}
2626

27-
private newtype TReturnKind =
27+
private newtype TReturnKind =
2828
TNormalReturnKind() or
2929
TIndirectReturnKind(ParameterIndex index)
3030

@@ -44,20 +44,23 @@ private class NormalReturnKind extends ReturnKind, TNormalReturnKind {
4444
private class IndirectReturnKind extends ReturnKind, TIndirectReturnKind {
4545
ParameterIndex index;
4646

47-
IndirectReturnKind() {
48-
this = TIndirectReturnKind(index)
49-
}
47+
IndirectReturnKind() { this = TIndirectReturnKind(index) }
5048

51-
override string toString() { result = "outparam[" + index.toString() +"]" }
49+
override string toString() { result = "outparam[" + index.toString() + "]" }
5250
}
5351

5452
/** A data flow node that occurs as the result of a `ReturnStmt`. */
5553
class ReturnNode extends Node {
5654
Instruction primary;
55+
5756
ReturnNode() {
58-
exists(ReturnValueInstruction ret | this.asInstruction() = ret.getReturnValue() and primary = ret)
57+
exists(ReturnValueInstruction ret |
58+
this.asInstruction() = ret.getReturnValue() and primary = ret
59+
)
5960
or
60-
exists(ReturnIndirectionInstruction rii | this.asInstruction() = rii.getSideEffectOperand().getAnyDef() and primary = rii)
61+
exists(ReturnIndirectionInstruction rii |
62+
this.asInstruction() = rii.getSideEffectOperand().getAnyDef() and primary = rii
63+
)
6164
}
6265

6366
/** Gets the kind of this returned value. */
@@ -67,13 +70,13 @@ class ReturnNode extends Node {
6770
class ReturnValueNode extends ReturnNode {
6871
override ReturnValueInstruction primary;
6972

70-
override ReturnKind getKind() { result = TNormalReturnKind() }
73+
override ReturnKind getKind() { result = TNormalReturnKind() }
7174
}
7275

7376
class ReturnIndirectionNode extends ReturnNode {
7477
override ReturnIndirectionInstruction primary;
7578

76-
override ReturnKind getKind() { result = TIndirectReturnKind(primary.getParameter().getIndex()) }
79+
override ReturnKind getKind() { result = TIndirectReturnKind(primary.getParameter().getIndex()) }
7780
}
7881

7982
/** A data flow node that represents the output of a call. */
@@ -92,26 +95,19 @@ class OutNode extends Node {
9295
private class CallOutNode extends OutNode {
9396
override CallInstruction instr;
9497

95-
override DataFlowCall getCall() {
96-
result = instr
97-
}
98+
override DataFlowCall getCall() { result = instr }
9899

99-
override ReturnKind getReturnKind() {
100-
result instanceof NormalReturnKind
101-
}
100+
override ReturnKind getReturnKind() { result instanceof NormalReturnKind }
102101
}
103102

104103
private class SideEffectOutNode extends OutNode {
105104
override WriteSideEffectInstruction instr;
106105

107-
override DataFlowCall getCall() {
108-
result = instr.getPrimaryInstruction()
109-
}
106+
override DataFlowCall getCall() { result = instr.getPrimaryInstruction() }
110107

111-
override ReturnKind getReturnKind() {
112-
result = TIndirectReturnKind(instr.getIndex())
113-
}
108+
override ReturnKind getReturnKind() { result = TIndirectReturnKind(instr.getIndex()) }
114109
}
110+
115111
/**
116112
* Gets a node that can read the value returned from `call` with return kind
117113
* `kind`.

cpp/ql/test/library-tests/ir/ir/aliased_ssa_sanity.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
missingOperand
2+
| ir.cpp:736:5:736:19 | Chi: call to String | Instruction 'Chi' is missing an expected operand with tag 'ChiTotal' in function '$@'. | ir.cpp:724:6:724:13 | IR: TryCatch | void TryCatch(bool) |
23
| ir.cpp:809:7:809:13 | IndirectMayWriteSideEffect: call to Base | Instruction 'IndirectMayWriteSideEffect' is missing an expected operand with tag 'Address' in function '$@'. | ir.cpp:799:6:799:25 | IR: HierarchyConversions | void HierarchyConversions() |
34
| ir.cpp:810:7:810:26 | IndirectMayWriteSideEffect: call to Base | Instruction 'IndirectMayWriteSideEffect' is missing an expected operand with tag 'Address' in function '$@'. | ir.cpp:799:6:799:25 | IR: HierarchyConversions | void HierarchyConversions() |
45
| ir.cpp:823:7:823:13 | IndirectMayWriteSideEffect: call to Base | Instruction 'IndirectMayWriteSideEffect' is missing an expected operand with tag 'Address' in function '$@'. | ir.cpp:799:6:799:25 | IR: HierarchyConversions | void HierarchyConversions() |
56
| ir.cpp:824:7:824:26 | IndirectMayWriteSideEffect: call to Base | Instruction 'IndirectMayWriteSideEffect' is missing an expected operand with tag 'Address' in function '$@'. | ir.cpp:799:6:799:25 | IR: HierarchyConversions | void HierarchyConversions() |
7+
| ir.cpp:1145:5:1145:19 | Chi: call to String | Instruction 'Chi' is missing an expected operand with tag 'ChiTotal' in function '$@'. | ir.cpp:1133:6:1133:23 | IR: TryCatchNoCatchAny | void TryCatchNoCatchAny(bool) |
8+
| ir.cpp:1170:3:1170:33 | Chi: call to String | Instruction 'Chi' is missing an expected operand with tag 'ChiTotal' in function '$@'. | ir.cpp:1169:8:1169:30 | IR: ReturnConstructorResult | String ReturnConstructorResult() |
69
unexpectedOperand
710
duplicateOperand
811
missingPhiOperand

cpp/ql/test/library-tests/ir/ir/raw_ir.expected

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ bad_asts.cpp:
7979
# 27| r27_6(Point) = Load : &:r27_5, ~mu26_4
8080
# 27| mu27_7(Point) = Store : &:r27_1, r27_6
8181
# 28| v28_1(void) = NoOp :
82-
# 26| v26_9(void) = ReturnIndirection : &:r26_7, ~mu26_4
82+
# 26| v26_9(void) = ReturnIndirection[a] : &:r26_7, ~mu26_4
8383
# 26| v26_10(void) = ReturnVoid :
8484
# 26| v26_11(void) = UnmodeledUse : mu*
8585
# 26| v26_12(void) = AliasedUse : ~mu26_4
@@ -836,7 +836,7 @@ ir.cpp:
836836
# 168| r168_6(glval<bool>) = VariableAddress[b] :
837837
# 168| mu168_7(bool) = Store : &:r168_6, r168_5
838838
# 169| v169_1(void) = NoOp :
839-
# 153| v153_11(void) = ReturnIndirection : &:r153_7, ~mu153_4
839+
# 153| v153_11(void) = ReturnIndirection[p] : &:r153_7, ~mu153_4
840840
# 153| v153_12(void) = ReturnVoid :
841841
# 153| v153_13(void) = UnmodeledUse : mu*
842842
# 153| v153_14(void) = AliasedUse : ~mu153_4
@@ -923,7 +923,7 @@ ir.cpp:
923923
# 184| r184_7(glval<int>) = PointerAdd[4] : r184_4, r184_6
924924
# 184| mu184_8(int) = Store : &:r184_7, r184_2
925925
# 185| v185_1(void) = NoOp :
926-
# 171| v171_11(void) = ReturnIndirection : &:r171_7, ~mu171_4
926+
# 171| v171_11(void) = ReturnIndirection[p] : &:r171_7, ~mu171_4
927927
# 171| v171_12(void) = ReturnVoid :
928928
# 171| v171_13(void) = UnmodeledUse : mu*
929929
# 171| v171_14(void) = AliasedUse : ~mu171_4
@@ -1023,8 +1023,8 @@ ir.cpp:
10231023
# 201| r201_6(glval<bool>) = VariableAddress[b] :
10241024
# 201| mu201_7(bool) = Store : &:r201_6, r201_5
10251025
# 202| v202_1(void) = NoOp :
1026-
# 193| v193_13(void) = ReturnIndirection : &:r193_7, ~mu193_4
1027-
# 193| v193_14(void) = ReturnIndirection : &:r193_11, ~mu193_4
1026+
# 193| v193_13(void) = ReturnIndirection[p] : &:r193_7, ~mu193_4
1027+
# 193| v193_14(void) = ReturnIndirection[q] : &:r193_11, ~mu193_4
10281028
# 193| v193_15(void) = ReturnVoid :
10291029
# 193| v193_16(void) = UnmodeledUse : mu*
10301030
# 193| v193_17(void) = AliasedUse : ~mu193_4
@@ -1073,7 +1073,7 @@ ir.cpp:
10731073
# 210| r210_7(glval<int *>) = VariableAddress[q] :
10741074
# 210| mu210_8(int *) = Store : &:r210_7, r210_6
10751075
# 211| v211_1(void) = NoOp :
1076-
# 204| v204_9(void) = ReturnIndirection : &:r204_7, ~mu204_4
1076+
# 204| v204_9(void) = ReturnIndirection[p] : &:r204_7, ~mu204_4
10771077
# 204| v204_10(void) = ReturnVoid :
10781078
# 204| v204_11(void) = UnmodeledUse : mu*
10791079
# 204| v204_12(void) = AliasedUse : ~mu204_4
@@ -1684,7 +1684,7 @@ ir.cpp:
16841684
# 343| r343_3(int *) = Load : &:r343_2, ~mu341_4
16851685
# 343| r343_4(int) = Load : &:r343_3, ~mu341_4
16861686
# 343| mu343_5(int) = Store : &:r343_1, r343_4
1687-
# 341| v341_9(void) = ReturnIndirection : &:r341_7, ~mu341_4
1687+
# 341| v341_9(void) = ReturnIndirection[p] : &:r341_7, ~mu341_4
16881688
# 341| r341_10(glval<int>) = VariableAddress[#return] :
16891689
# 341| v341_11(void) = ReturnValue : &:r341_10, ~mu341_4
16901690
# 341| v341_12(void) = UnmodeledUse : mu*
@@ -2984,8 +2984,8 @@ ir.cpp:
29842984
# 625| v625_6(void) = ^BufferReadSideEffect[-1] : &:r625_2, ~mu622_4
29852985
# 625| mu625_7(String) = ^IndirectMayWriteSideEffect[-1] : &:r625_2
29862986
# 626| v626_1(void) = NoOp :
2987-
# 622| v622_15(void) = ReturnIndirection : &:r622_7, ~mu622_4
2988-
# 622| v622_16(void) = ReturnIndirection : &:r622_11, ~mu622_4
2987+
# 622| v622_15(void) = ReturnIndirection[r] : &:r622_7, ~mu622_4
2988+
# 622| v622_16(void) = ReturnIndirection[p] : &:r622_11, ~mu622_4
29892989
# 622| v622_17(void) = ReturnVoid :
29902990
# 622| v622_18(void) = UnmodeledUse : mu*
29912991
# 622| v622_19(void) = AliasedUse : ~mu622_4
@@ -3177,7 +3177,7 @@ ir.cpp:
31773177
# 676| r676_3(int &) = Load : &:r676_2, ~mu675_4
31783178
# 676| r676_4(int) = Load : &:r676_3, ~mu675_4
31793179
# 676| mu676_5(int) = Store : &:r676_1, r676_4
3180-
# 675| v675_9(void) = ReturnIndirection : &:r675_7, ~mu675_4
3180+
# 675| v675_9(void) = ReturnIndirection[r] : &:r675_7, ~mu675_4
31813181
# 675| r675_10(glval<int>) = VariableAddress[#return] :
31823182
# 675| v675_11(void) = ReturnValue : &:r675_10, ~mu675_4
31833183
# 675| v675_12(void) = UnmodeledUse : mu*
@@ -3370,7 +3370,7 @@ ir.cpp:
33703370
# 716| r716_1(glval<long>) = VariableAddress[#return] :
33713371
# 716| r716_2(long) = Constant[0] :
33723372
# 716| mu716_3(long) = Store : &:r716_1, r716_2
3373-
# 715| v715_11(void) = ReturnIndirection : &:r715_7, ~mu715_4
3373+
# 715| v715_11(void) = ReturnIndirection[x] : &:r715_7, ~mu715_4
33743374
# 715| r715_12(glval<long>) = VariableAddress[#return] :
33753375
# 715| v715_13(void) = ReturnValue : &:r715_12, ~mu715_4
33763376
# 715| v715_14(void) = UnmodeledUse : mu*
@@ -3557,7 +3557,7 @@ ir.cpp:
35573557
#-----| r0_20(glval<Base>) = CopyValue : r0_19
35583558
#-----| r0_21(Base &) = CopyValue : r0_20
35593559
#-----| mu0_22(Base &) = Store : &:r0_18, r0_21
3560-
#-----| v0_23(void) = ReturnIndirection : &:r0_3, ~mu745_4
3560+
#-----| v0_23(void) = ReturnIndirection[p#0] : &:r0_3, ~mu745_4
35613561
# 745| r745_9(glval<Base &>) = VariableAddress[#return] :
35623562
# 745| v745_10(void) = ReturnValue : &:r745_9, ~mu745_4
35633563
# 745| v745_11(void) = UnmodeledUse : mu*
@@ -3581,7 +3581,7 @@ ir.cpp:
35813581
# 745| mu745_9(unknown) = ^CallSideEffect : ~mu745_4
35823582
# 745| mu745_10(String) = ^IndirectMayWriteSideEffect[-1] : &:r745_6
35833583
# 745| v745_11(void) = NoOp :
3584-
#-----| v0_5(void) = ReturnIndirection : &:r0_3, ~mu745_4
3584+
#-----| v0_5(void) = ReturnIndirection[p#0] : &:r0_3, ~mu745_4
35853585
# 745| v745_12(void) = ReturnVoid :
35863586
# 745| v745_13(void) = UnmodeledUse : mu*
35873587
# 745| v745_14(void) = AliasedUse : ~mu745_4
@@ -3671,7 +3671,7 @@ ir.cpp:
36713671
#-----| r0_34(glval<Middle>) = CopyValue : r0_33
36723672
#-----| r0_35(Middle &) = CopyValue : r0_34
36733673
#-----| mu0_36(Middle &) = Store : &:r0_32, r0_35
3674-
#-----| v0_37(void) = ReturnIndirection : &:r0_3, ~mu754_4
3674+
#-----| v0_37(void) = ReturnIndirection[p#0] : &:r0_3, ~mu754_4
36753675
# 754| r754_12(glval<Middle &>) = VariableAddress[#return] :
36763676
# 754| v754_13(void) = ReturnValue : &:r754_12, ~mu754_4
36773677
# 754| v754_14(void) = UnmodeledUse : mu*
@@ -3771,7 +3771,7 @@ ir.cpp:
37713771
#-----| r0_34(glval<Derived>) = CopyValue : r0_33
37723772
#-----| r0_35(Derived &) = CopyValue : r0_34
37733773
#-----| mu0_36(Derived &) = Store : &:r0_32, r0_35
3774-
#-----| v0_37(void) = ReturnIndirection : &:r0_3, ~mu763_4
3774+
#-----| v0_37(void) = ReturnIndirection[p#0] : &:r0_3, ~mu763_4
37753775
# 763| r763_12(glval<Derived &>) = VariableAddress[#return] :
37763776
# 763| v763_13(void) = ReturnValue : &:r763_12, ~mu763_4
37773777
# 763| v763_14(void) = UnmodeledUse : mu*
@@ -4328,10 +4328,10 @@ ir.cpp:
43284328
#-----| mu0_4(PolymorphicBase) = ^IndirectMayWriteSideEffect[-1] : &:r850_1
43294329
# 851| r851_1(glval<PolymorphicDerived>) = VariableAddress[d] :
43304330
# 851| mu851_2(PolymorphicDerived) = Uninitialized[d] : &:r851_1
4331-
#-----| r0_5(glval<unknown>) = FunctionAddress[PolymorphicDerived] :
4332-
#-----| v0_6(void) = Call : func:r0_5, this:r851_1
4333-
#-----| mu0_7(unknown) = ^CallSideEffect : ~mu849_4
4334-
#-----| mu0_8(PolymorphicDerived) = ^IndirectMayWriteSideEffect[-1] : &:r851_1
4331+
# 851| r851_3(glval<unknown>) = FunctionAddress[PolymorphicDerived] :
4332+
# 851| v851_4(void) = Call : func:r851_3, this:r851_1
4333+
# 851| mu851_5(unknown) = ^CallSideEffect : ~mu849_4
4334+
# 851| mu851_6(PolymorphicDerived) = ^IndirectMayWriteSideEffect[-1] : &:r851_1
43354335
# 853| r853_1(glval<PolymorphicBase *>) = VariableAddress[pb] :
43364336
# 853| r853_2(glval<PolymorphicBase>) = VariableAddress[b] :
43374337
# 853| r853_3(PolymorphicBase *) = CopyValue : r853_2
@@ -4475,7 +4475,7 @@ ir.cpp:
44754475
# 885| r885_4(glval<..(*)(..)>) = VariableAddress[pfn] :
44764476
# 885| mu885_5(..(*)(..)) = Store : &:r885_4, r885_3
44774477
# 886| v886_1(void) = NoOp :
4478-
# 883| v883_11(void) = ReturnIndirection : &:r883_9, ~mu883_4
4478+
# 883| v883_11(void) = ReturnIndirection[p] : &:r883_9, ~mu883_4
44794479
# 883| v883_12(void) = ReturnVoid :
44804480
# 883| v883_13(void) = UnmodeledUse : mu*
44814481
# 883| v883_14(void) = AliasedUse : ~mu883_4
@@ -4959,7 +4959,7 @@ ir.cpp:
49594959
# 988| mu988_11(unknown) = ^CallSideEffect : ~mu987_4
49604960
# 988| r988_12(int) = Add : r988_6, r988_10
49614961
# 988| mu988_13(int) = Store : &:r988_1, r988_12
4962-
# 987| v987_11(void) = ReturnIndirection : &:r987_7, ~mu987_4
4962+
# 987| v987_11(void) = ReturnIndirection[a] : &:r987_7, ~mu987_4
49634963
# 987| r987_12(glval<int>) = VariableAddress[#return] :
49644964
# 987| v987_13(void) = ReturnValue : &:r987_12, ~mu987_4
49654965
# 987| v987_14(void) = UnmodeledUse : mu*
@@ -5269,7 +5269,7 @@ ir.cpp:
52695269
# 1046| v1046_7(void) = ^BufferReadSideEffect[-1] : &:r1046_2, ~mu1031_4
52705270
# 1046| mu1046_8(decltype([...](...){...})) = ^IndirectMayWriteSideEffect[-1] : &:r1046_2
52715271
# 1047| v1047_1(void) = NoOp :
5272-
# 1031| v1031_11(void) = ReturnIndirection : &:r1031_9, ~mu1031_4
5272+
# 1031| v1031_11(void) = ReturnIndirection[s] : &:r1031_9, ~mu1031_4
52735273
# 1031| v1031_12(void) = ReturnVoid :
52745274
# 1031| v1031_13(void) = UnmodeledUse : mu*
52755275
# 1031| v1031_14(void) = AliasedUse : ~mu1031_4
@@ -5620,13 +5620,13 @@ ir.cpp:
56205620
#-----| Goto -> Block 5
56215621

56225622
# 1079| Block 5
5623-
# 1079| v1079_1(void) = NoOp :
5624-
# 1080| v1080_1(void) = NoOp :
5625-
# 1068| v1068_9(void) = ReturnIndirection : &:r1068_7, ~mu1068_4
5626-
# 1068| v1068_10(void) = ReturnVoid :
5627-
# 1068| v1068_11(void) = UnmodeledUse : mu*
5628-
# 1068| v1068_12(void) = AliasedUse : ~mu1068_4
5629-
# 1068| v1068_13(void) = ExitFunction :
5623+
# 1079| v1079_1(void) = NoOp :
5624+
# 1080| v1080_1(void) = NoOp :
5625+
# 1068| v1068_9(void) = ReturnIndirection[v] : &:r1068_7, ~mu1068_4
5626+
# 1068| v1068_10(void) = ReturnVoid :
5627+
# 1068| v1068_11(void) = UnmodeledUse : mu*
5628+
# 1068| v1068_12(void) = AliasedUse : ~mu1068_4
5629+
# 1068| v1068_13(void) = ExitFunction :
56305630

56315631
#-----| Block 6
56325632
#-----| r0_24(glval<iterator>) = VariableAddress[(__begin)] :
@@ -5753,8 +5753,8 @@ ir.cpp:
57535753
# 1109| r1109_9(unsigned int) = Load : &:r1109_8, ~mu1104_4
57545754
# 1106| mu1106_1(unknown) = InlineAsm : ~mu1104_4, 0:r1109_3, 1:r1109_4, 2:r1109_7, 3:r1109_9
57555755
# 1111| v1111_1(void) = NoOp :
5756-
# 1104| v1104_17(void) = ReturnIndirection : &:r1104_7, ~mu1104_4
5757-
# 1104| v1104_18(void) = ReturnIndirection : &:r1104_13, ~mu1104_4
5756+
# 1104| v1104_17(void) = ReturnIndirection[a] : &:r1104_7, ~mu1104_4
5757+
# 1104| v1104_18(void) = ReturnIndirection[c] : &:r1104_13, ~mu1104_4
57585758
# 1104| v1104_19(void) = ReturnVoid :
57595759
# 1104| v1104_20(void) = UnmodeledUse : mu*
57605760
# 1104| v1104_21(void) = AliasedUse : ~mu1104_4

0 commit comments

Comments
 (0)