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

Skip to content

Commit 49088e7

Browse files
author
Robert Marsh
committed
C++: Fix formatting and dropped line
1 parent 3d56224 commit 49088e7

4 files changed

Lines changed: 144 additions & 172 deletions

File tree

cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,32 @@ module InstructionSanity {
2020
exists(Opcode opcode |
2121
opcode = instr.getOpcode() and
2222
(
23-
opcode instanceof UnaryOpcode and tag instanceof UnaryOperandTag or
23+
opcode instanceof UnaryOpcode and tag instanceof UnaryOperandTag
24+
or
25+
opcode instanceof BinaryOpcode and
2426
(
25-
opcode instanceof BinaryOpcode and
26-
(
27-
tag instanceof LeftOperandTag or
28-
tag instanceof RightOperandTag
29-
)
30-
) or
31-
opcode instanceof MemoryAccessOpcode and tag instanceof AddressOperandTag or
32-
opcode instanceof OpcodeWithCondition and tag instanceof ConditionOperandTag or
33-
opcode instanceof OpcodeWithLoad and tag instanceof LoadOperandTag or
34-
opcode instanceof Opcode::Store and tag instanceof StoreValueOperandTag or
35-
opcode instanceof Opcode::UnmodeledUse and tag instanceof UnmodeledUseOperandTag or
36-
opcode instanceof Opcode::Call and tag instanceof CallTargetOperandTag or
37-
opcode instanceof Opcode::Chi and tag instanceof ChiTotalOperandTag or
38-
opcode instanceof Opcode::Chi and tag instanceof ChiPartialOperandTag or
39-
27+
tag instanceof LeftOperandTag or
28+
tag instanceof RightOperandTag
29+
)
30+
or
31+
opcode instanceof MemoryAccessOpcode and tag instanceof AddressOperandTag
32+
or
33+
opcode instanceof BufferAccessOpcode and tag instanceof BufferSizeOperand
34+
or
35+
opcode instanceof OpcodeWithCondition and tag instanceof ConditionOperandTag
36+
or
37+
opcode instanceof OpcodeWithLoad and tag instanceof LoadOperandTag
38+
or
39+
opcode instanceof Opcode::Store and tag instanceof StoreValueOperandTag
40+
or
41+
opcode instanceof Opcode::UnmodeledUse and tag instanceof UnmodeledUseOperandTag
42+
or
43+
opcode instanceof Opcode::Call and tag instanceof CallTargetOperandTag
44+
or
45+
opcode instanceof Opcode::Chi and tag instanceof ChiTotalOperandTag
46+
or
47+
opcode instanceof Opcode::Chi and tag instanceof ChiPartialOperandTag
48+
or
4049
(
4150
opcode instanceof ReadSideEffectOpcode or
4251
opcode instanceof MayWriteSideEffectOpcode or
@@ -600,9 +609,7 @@ class VariableInstruction extends Instruction {
600609

601610
VariableInstruction() { var = Construction::getInstructionVariable(this) }
602611

603-
override string getImmediateString() {
604-
result = var.toString()
605-
}
612+
override string getImmediateString() { result = var.toString() }
606613

607614
final IRVariable getVariable() { result = var }
608615
}
@@ -648,9 +655,9 @@ class VariableAddressInstruction extends VariableInstruction {
648655
class InitializeParameterInstruction extends VariableInstruction {
649656
InitializeParameterInstruction() { getOpcode() instanceof Opcode::InitializeParameter }
650657

651-
override final MemoryAccessKind getResultMemoryAccess() {
652-
result instanceof IndirectMemoryAccess
653-
}
658+
final Language::Parameter getParameter() { result = var.(IRUserVariable).getVariable() }
659+
660+
final override MemoryAccessKind getResultMemoryAccess() { result instanceof IndirectMemoryAccess }
654661
}
655662

656663
/**
@@ -1167,39 +1174,27 @@ class CallReadSideEffectInstruction extends SideEffectInstruction {
11671174
* An instruction representing the read of an indirect parameter within a function call.
11681175
*/
11691176
class IndirectReadSideEffectInstruction extends SideEffectInstruction {
1170-
IndirectReadSideEffectInstruction() {
1171-
getOpcode() instanceof Opcode::IndirectReadSideEffect
1172-
}
1177+
IndirectReadSideEffectInstruction() { getOpcode() instanceof Opcode::IndirectReadSideEffect }
11731178

1174-
Instruction getArgumentInstruction() {
1175-
result = getAnOperand().(AddressOperand).getDef()
1176-
}
1179+
Instruction getArgumentInstruction() { result = getAnOperand().(AddressOperand).getDef() }
11771180
}
11781181

11791182
/**
11801183
* An instruction representing the read of an indirect buffer parameter within a function call.
11811184
*/
11821185
class BufferReadSideEffectInstruction extends SideEffectInstruction {
1183-
BufferReadSideEffectInstruction() {
1184-
getOpcode() instanceof Opcode::BufferReadSideEffect
1185-
}
1186+
BufferReadSideEffectInstruction() { getOpcode() instanceof Opcode::BufferReadSideEffect }
11861187

1187-
Instruction getArgumentInstruction() {
1188-
result = getAnOperand().(AddressOperand).getDef()
1189-
}
1188+
Instruction getArgumentInstruction() { result = getAnOperand().(AddressOperand).getDef() }
11901189
}
11911190

11921191
/**
11931192
* An instruction representing a side effect of a function call.
11941193
*/
11951194
class WriteSideEffectInstruction extends SideEffectInstruction {
1196-
WriteSideEffectInstruction() {
1197-
getOpcode() instanceof WriteSideEffectOpcode
1198-
}
1195+
WriteSideEffectInstruction() { getOpcode() instanceof WriteSideEffectOpcode }
11991196

1200-
Instruction getArgumentInstruction() {
1201-
result = getAnOperand().(AddressOperand).getDef()
1202-
}
1197+
Instruction getArgumentInstruction() { result = getAnOperand().(AddressOperand).getDef() }
12031198
}
12041199

12051200
/**
@@ -1245,9 +1240,7 @@ class IndirectMayWriteSideEffectInstruction extends WriteSideEffectInstruction {
12451240
* Unlike `BufferWriteSideEffectInstruction`, the buffer might not be completely overwritten.
12461241
*/
12471242
class BufferMayWriteSideEffectInstruction extends WriteSideEffectInstruction {
1248-
BufferMayWriteSideEffectInstruction() {
1249-
getOpcode() instanceof Opcode::BufferMayWriteSideEffect
1250-
}
1243+
BufferMayWriteSideEffectInstruction() { getOpcode() instanceof Opcode::BufferMayWriteSideEffect }
12511244

12521245
final override MemoryAccessKind getResultMemoryAccess() {
12531246
result instanceof BufferMayMemoryAccess

cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Instruction.qll

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,32 @@ module InstructionSanity {
2020
exists(Opcode opcode |
2121
opcode = instr.getOpcode() and
2222
(
23-
opcode instanceof UnaryOpcode and tag instanceof UnaryOperandTag or
23+
opcode instanceof UnaryOpcode and tag instanceof UnaryOperandTag
24+
or
25+
opcode instanceof BinaryOpcode and
2426
(
25-
opcode instanceof BinaryOpcode and
26-
(
27-
tag instanceof LeftOperandTag or
28-
tag instanceof RightOperandTag
29-
)
30-
) or
31-
opcode instanceof MemoryAccessOpcode and tag instanceof AddressOperandTag or
32-
opcode instanceof OpcodeWithCondition and tag instanceof ConditionOperandTag or
33-
opcode instanceof OpcodeWithLoad and tag instanceof LoadOperandTag or
34-
opcode instanceof Opcode::Store and tag instanceof StoreValueOperandTag or
35-
opcode instanceof Opcode::UnmodeledUse and tag instanceof UnmodeledUseOperandTag or
36-
opcode instanceof Opcode::Call and tag instanceof CallTargetOperandTag or
37-
opcode instanceof Opcode::Chi and tag instanceof ChiTotalOperandTag or
38-
opcode instanceof Opcode::Chi and tag instanceof ChiPartialOperandTag or
39-
27+
tag instanceof LeftOperandTag or
28+
tag instanceof RightOperandTag
29+
)
30+
or
31+
opcode instanceof MemoryAccessOpcode and tag instanceof AddressOperandTag
32+
or
33+
opcode instanceof BufferAccessOpcode and tag instanceof BufferSizeOperand
34+
or
35+
opcode instanceof OpcodeWithCondition and tag instanceof ConditionOperandTag
36+
or
37+
opcode instanceof OpcodeWithLoad and tag instanceof LoadOperandTag
38+
or
39+
opcode instanceof Opcode::Store and tag instanceof StoreValueOperandTag
40+
or
41+
opcode instanceof Opcode::UnmodeledUse and tag instanceof UnmodeledUseOperandTag
42+
or
43+
opcode instanceof Opcode::Call and tag instanceof CallTargetOperandTag
44+
or
45+
opcode instanceof Opcode::Chi and tag instanceof ChiTotalOperandTag
46+
or
47+
opcode instanceof Opcode::Chi and tag instanceof ChiPartialOperandTag
48+
or
4049
(
4150
opcode instanceof ReadSideEffectOpcode or
4251
opcode instanceof MayWriteSideEffectOpcode or
@@ -600,9 +609,7 @@ class VariableInstruction extends Instruction {
600609

601610
VariableInstruction() { var = Construction::getInstructionVariable(this) }
602611

603-
override string getImmediateString() {
604-
result = var.toString()
605-
}
612+
override string getImmediateString() { result = var.toString() }
606613

607614
final IRVariable getVariable() { result = var }
608615
}
@@ -648,9 +655,9 @@ class VariableAddressInstruction extends VariableInstruction {
648655
class InitializeParameterInstruction extends VariableInstruction {
649656
InitializeParameterInstruction() { getOpcode() instanceof Opcode::InitializeParameter }
650657

651-
override final MemoryAccessKind getResultMemoryAccess() {
652-
result instanceof IndirectMemoryAccess
653-
}
658+
final Language::Parameter getParameter() { result = var.(IRUserVariable).getVariable() }
659+
660+
final override MemoryAccessKind getResultMemoryAccess() { result instanceof IndirectMemoryAccess }
654661
}
655662

656663
/**
@@ -1167,39 +1174,27 @@ class CallReadSideEffectInstruction extends SideEffectInstruction {
11671174
* An instruction representing the read of an indirect parameter within a function call.
11681175
*/
11691176
class IndirectReadSideEffectInstruction extends SideEffectInstruction {
1170-
IndirectReadSideEffectInstruction() {
1171-
getOpcode() instanceof Opcode::IndirectReadSideEffect
1172-
}
1177+
IndirectReadSideEffectInstruction() { getOpcode() instanceof Opcode::IndirectReadSideEffect }
11731178

1174-
Instruction getArgumentInstruction() {
1175-
result = getAnOperand().(AddressOperand).getDef()
1176-
}
1179+
Instruction getArgumentInstruction() { result = getAnOperand().(AddressOperand).getDef() }
11771180
}
11781181

11791182
/**
11801183
* An instruction representing the read of an indirect buffer parameter within a function call.
11811184
*/
11821185
class BufferReadSideEffectInstruction extends SideEffectInstruction {
1183-
BufferReadSideEffectInstruction() {
1184-
getOpcode() instanceof Opcode::BufferReadSideEffect
1185-
}
1186+
BufferReadSideEffectInstruction() { getOpcode() instanceof Opcode::BufferReadSideEffect }
11861187

1187-
Instruction getArgumentInstruction() {
1188-
result = getAnOperand().(AddressOperand).getDef()
1189-
}
1188+
Instruction getArgumentInstruction() { result = getAnOperand().(AddressOperand).getDef() }
11901189
}
11911190

11921191
/**
11931192
* An instruction representing a side effect of a function call.
11941193
*/
11951194
class WriteSideEffectInstruction extends SideEffectInstruction {
1196-
WriteSideEffectInstruction() {
1197-
getOpcode() instanceof WriteSideEffectOpcode
1198-
}
1195+
WriteSideEffectInstruction() { getOpcode() instanceof WriteSideEffectOpcode }
11991196

1200-
Instruction getArgumentInstruction() {
1201-
result = getAnOperand().(AddressOperand).getDef()
1202-
}
1197+
Instruction getArgumentInstruction() { result = getAnOperand().(AddressOperand).getDef() }
12031198
}
12041199

12051200
/**
@@ -1245,9 +1240,7 @@ class IndirectMayWriteSideEffectInstruction extends WriteSideEffectInstruction {
12451240
* Unlike `BufferWriteSideEffectInstruction`, the buffer might not be completely overwritten.
12461241
*/
12471242
class BufferMayWriteSideEffectInstruction extends WriteSideEffectInstruction {
1248-
BufferMayWriteSideEffectInstruction() {
1249-
getOpcode() instanceof Opcode::BufferMayWriteSideEffect
1250-
}
1243+
BufferMayWriteSideEffectInstruction() { getOpcode() instanceof Opcode::BufferMayWriteSideEffect }
12511244

12521245
final override MemoryAccessKind getResultMemoryAccess() {
12531246
result instanceof BufferMayMemoryAccess

cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll

Lines changed: 36 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -20,23 +20,32 @@ module InstructionSanity {
2020
exists(Opcode opcode |
2121
opcode = instr.getOpcode() and
2222
(
23-
opcode instanceof UnaryOpcode and tag instanceof UnaryOperandTag or
23+
opcode instanceof UnaryOpcode and tag instanceof UnaryOperandTag
24+
or
25+
opcode instanceof BinaryOpcode and
2426
(
25-
opcode instanceof BinaryOpcode and
26-
(
27-
tag instanceof LeftOperandTag or
28-
tag instanceof RightOperandTag
29-
)
30-
) or
31-
opcode instanceof MemoryAccessOpcode and tag instanceof AddressOperandTag or
32-
opcode instanceof OpcodeWithCondition and tag instanceof ConditionOperandTag or
33-
opcode instanceof OpcodeWithLoad and tag instanceof LoadOperandTag or
34-
opcode instanceof Opcode::Store and tag instanceof StoreValueOperandTag or
35-
opcode instanceof Opcode::UnmodeledUse and tag instanceof UnmodeledUseOperandTag or
36-
opcode instanceof Opcode::Call and tag instanceof CallTargetOperandTag or
37-
opcode instanceof Opcode::Chi and tag instanceof ChiTotalOperandTag or
38-
opcode instanceof Opcode::Chi and tag instanceof ChiPartialOperandTag or
39-
27+
tag instanceof LeftOperandTag or
28+
tag instanceof RightOperandTag
29+
)
30+
or
31+
opcode instanceof MemoryAccessOpcode and tag instanceof AddressOperandTag
32+
or
33+
opcode instanceof BufferAccessOpcode and tag instanceof BufferSizeOperand
34+
or
35+
opcode instanceof OpcodeWithCondition and tag instanceof ConditionOperandTag
36+
or
37+
opcode instanceof OpcodeWithLoad and tag instanceof LoadOperandTag
38+
or
39+
opcode instanceof Opcode::Store and tag instanceof StoreValueOperandTag
40+
or
41+
opcode instanceof Opcode::UnmodeledUse and tag instanceof UnmodeledUseOperandTag
42+
or
43+
opcode instanceof Opcode::Call and tag instanceof CallTargetOperandTag
44+
or
45+
opcode instanceof Opcode::Chi and tag instanceof ChiTotalOperandTag
46+
or
47+
opcode instanceof Opcode::Chi and tag instanceof ChiPartialOperandTag
48+
or
4049
(
4150
opcode instanceof ReadSideEffectOpcode or
4251
opcode instanceof MayWriteSideEffectOpcode or
@@ -600,9 +609,7 @@ class VariableInstruction extends Instruction {
600609

601610
VariableInstruction() { var = Construction::getInstructionVariable(this) }
602611

603-
override string getImmediateString() {
604-
result = var.toString()
605-
}
612+
override string getImmediateString() { result = var.toString() }
606613

607614
final IRVariable getVariable() { result = var }
608615
}
@@ -648,9 +655,9 @@ class VariableAddressInstruction extends VariableInstruction {
648655
class InitializeParameterInstruction extends VariableInstruction {
649656
InitializeParameterInstruction() { getOpcode() instanceof Opcode::InitializeParameter }
650657

651-
override final MemoryAccessKind getResultMemoryAccess() {
652-
result instanceof IndirectMemoryAccess
653-
}
658+
final Language::Parameter getParameter() { result = var.(IRUserVariable).getVariable() }
659+
660+
final override MemoryAccessKind getResultMemoryAccess() { result instanceof IndirectMemoryAccess }
654661
}
655662

656663
/**
@@ -1167,39 +1174,27 @@ class CallReadSideEffectInstruction extends SideEffectInstruction {
11671174
* An instruction representing the read of an indirect parameter within a function call.
11681175
*/
11691176
class IndirectReadSideEffectInstruction extends SideEffectInstruction {
1170-
IndirectReadSideEffectInstruction() {
1171-
getOpcode() instanceof Opcode::IndirectReadSideEffect
1172-
}
1177+
IndirectReadSideEffectInstruction() { getOpcode() instanceof Opcode::IndirectReadSideEffect }
11731178

1174-
Instruction getArgumentInstruction() {
1175-
result = getAnOperand().(AddressOperand).getDef()
1176-
}
1179+
Instruction getArgumentInstruction() { result = getAnOperand().(AddressOperand).getDef() }
11771180
}
11781181

11791182
/**
11801183
* An instruction representing the read of an indirect buffer parameter within a function call.
11811184
*/
11821185
class BufferReadSideEffectInstruction extends SideEffectInstruction {
1183-
BufferReadSideEffectInstruction() {
1184-
getOpcode() instanceof Opcode::BufferReadSideEffect
1185-
}
1186+
BufferReadSideEffectInstruction() { getOpcode() instanceof Opcode::BufferReadSideEffect }
11861187

1187-
Instruction getArgumentInstruction() {
1188-
result = getAnOperand().(AddressOperand).getDef()
1189-
}
1188+
Instruction getArgumentInstruction() { result = getAnOperand().(AddressOperand).getDef() }
11901189
}
11911190

11921191
/**
11931192
* An instruction representing a side effect of a function call.
11941193
*/
11951194
class WriteSideEffectInstruction extends SideEffectInstruction {
1196-
WriteSideEffectInstruction() {
1197-
getOpcode() instanceof WriteSideEffectOpcode
1198-
}
1195+
WriteSideEffectInstruction() { getOpcode() instanceof WriteSideEffectOpcode }
11991196

1200-
Instruction getArgumentInstruction() {
1201-
result = getAnOperand().(AddressOperand).getDef()
1202-
}
1197+
Instruction getArgumentInstruction() { result = getAnOperand().(AddressOperand).getDef() }
12031198
}
12041199

12051200
/**
@@ -1245,9 +1240,7 @@ class IndirectMayWriteSideEffectInstruction extends WriteSideEffectInstruction {
12451240
* Unlike `BufferWriteSideEffectInstruction`, the buffer might not be completely overwritten.
12461241
*/
12471242
class BufferMayWriteSideEffectInstruction extends WriteSideEffectInstruction {
1248-
BufferMayWriteSideEffectInstruction() {
1249-
getOpcode() instanceof Opcode::BufferMayWriteSideEffect
1250-
}
1243+
BufferMayWriteSideEffectInstruction() { getOpcode() instanceof Opcode::BufferMayWriteSideEffect }
12511244

12521245
final override MemoryAccessKind getResultMemoryAccess() {
12531246
result instanceof BufferMayMemoryAccess

0 commit comments

Comments
 (0)