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

Skip to content

Commit 609ca03

Browse files
dave-bartolomeoAndreiDiaconu1
authored andcommitted
C#/C++: Share IR implementation
1 parent 50ba4d1 commit 609ca03

51 files changed

Lines changed: 831 additions & 470 deletions

Some content is hidden

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

config/identical-files.json

Lines changed: 66 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,42 +39,82 @@
3939
"IR Instruction": [
4040
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Instruction.qll",
4141
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Instruction.qll",
42-
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll"
42+
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Instruction.qll",
43+
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/Instruction.qll"
4344
],
4445
"IR IRBlock": [
4546
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/IRBlock.qll",
4647
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/IRBlock.qll",
47-
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IRBlock.qll"
48+
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IRBlock.qll",
49+
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/IRBlock.qll"
4850
],
4951
"IR IRVariable": [
5052
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/IRVariable.qll",
5153
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/IRVariable.qll",
52-
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IRVariable.qll"
54+
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IRVariable.qll",
55+
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/IRVariable.qll"
5356
],
5457
"IR IRFunction": [
5558
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/IRFunction.qll",
5659
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/IRFunction.qll",
57-
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IRFunction.qll"
60+
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IRFunction.qll",
61+
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/IRFunction.qll"
5862
],
5963
"IR Operand": [
6064
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/Operand.qll",
6165
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/Operand.qll",
62-
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Operand.qll"
66+
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/Operand.qll",
67+
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/Operand.qll"
6368
],
6469
"IR IR": [
6570
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/IR.qll",
6671
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/IR.qll",
67-
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IR.qll"
72+
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IR.qll",
73+
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/IR.qll"
6874
],
6975
"IR IRSanity": [
7076
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/IRSanity.qll",
7177
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/IRSanity.qll",
72-
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IRSanity.qll"
78+
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IRSanity.qll",
79+
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/IRSanity.qll"
7380
],
7481
"IR PrintIR": [
7582
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/PrintIR.qll",
7683
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/PrintIR.qll",
77-
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/PrintIR.qll"
84+
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/PrintIR.qll",
85+
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/PrintIR.qll"
86+
],
87+
"IR IntegerConstant": [
88+
"cpp/ql/src/semmle/code/cpp/ir/internal/IntegerConstant.qll",
89+
"csharp/ql/src/semmle/code/csharp/ir/internal/IntegerConstant.qll"
90+
],
91+
"IR IntegerInteval": [
92+
"cpp/ql/src/semmle/code/cpp/ir/internal/IntegerInterval.qll",
93+
"csharp/ql/src/semmle/code/csharp/ir/internal/IntegerInterval.qll"
94+
],
95+
"IR IntegerPartial": [
96+
"cpp/ql/src/semmle/code/cpp/ir/internal/IntegerPartial.qll",
97+
"csharp/ql/src/semmle/code/csharp/ir/internal/IntegerPartial.qll"
98+
],
99+
"IR Overlap": [
100+
"cpp/ql/src/semmle/code/cpp/ir/internal/Overlap.qll",
101+
"csharp/ql/src/semmle/code/csharp/ir/internal/Overlap.qll"
102+
],
103+
"IR EdgeKind": [
104+
"cpp/ql/src/semmle/code/cpp/ir/implementation/EdgeKind.qll",
105+
"csharp/ql/src/semmle/code/csharp/ir/implementation/EdgeKind.qll"
106+
],
107+
"IR MemoryAccessKind": [
108+
"cpp/ql/src/semmle/code/cpp/ir/implementation/MemoryAccessKind.qll",
109+
"csharp/ql/src/semmle/code/csharp/ir/implementation/MemoryAccessKind.qll"
110+
],
111+
"IR TempVariableTag": [
112+
"cpp/ql/src/semmle/code/cpp/ir/implementation/TempVariableTag.qll",
113+
"csharp/ql/src/semmle/code/csharp/ir/implementation/TempVariableTag.qll"
114+
],
115+
"IR Opcode": [
116+
"cpp/ql/src/semmle/code/cpp/ir/implementation/Opcode.qll",
117+
"csharp/ql/src/semmle/code/csharp/ir/implementation/Opcode.qll"
78118
],
79119
"C++ IR InstructionImports": [
80120
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/InstructionImports.qll",
@@ -148,5 +188,23 @@
148188
"C++ IR PrintDominance": [
149189
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/reachability/PrintDominance.qll",
150190
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/reachability/PrintDominance.qll"
191+
],
192+
"C# IR InstructionImports": [
193+
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/InstructionImports.qll"
194+
],
195+
"C# IR IRImports": [
196+
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/IRImports.qll"
197+
],
198+
"C# IR IRBlockImports": [
199+
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/IRBlockImports.qll"
200+
],
201+
"C# IR IRVariableImports": [
202+
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/IRVariableImports.qll"
203+
],
204+
"C# IR OperandImports": [
205+
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/OperandImports.qll"
206+
],
207+
"C# IR PrintIRImports": [
208+
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/PrintIRImports.qll"
151209
]
152210
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ private newtype TOpcode =
4242
TDynamicCastToVoid() or
4343
TVariableAddress() or
4444
TFieldAddress() or
45+
TIndexedElementAddress() or
4546
TFunctionAddress() or
4647
TConstant() or
4748
TStringConstant() or
@@ -190,6 +191,7 @@ module Opcode {
190191
class DynamicCastToVoid extends UnaryOpcode, TDynamicCastToVoid { override final string toString() { result = "DynamicCastToVoid" } }
191192
class VariableAddress extends Opcode, TVariableAddress { override final string toString() { result = "VariableAddress" } }
192193
class FieldAddress extends UnaryOpcode, TFieldAddress { override final string toString() { result = "FieldAddress" } }
194+
class IndexedElementAddress extends BinaryOpcode, TIndexedElementAddress { override final string toString() { result = "IndexedElementAddress" } }
193195
class FunctionAddress extends Opcode, TFunctionAddress { override final string toString() { result = "FunctionAddress" } }
194196
class Constant extends Opcode, TConstant { override final string toString() { result = "Constant" } }
195197
class StringConstant extends Opcode, TStringConstant { override final string toString() { result = "StringConstant" } }

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
private import semmle.code.cpp.ir.internal.TempVariableTag
1+
private import internal.TempVariableTagInternal
2+
private import Imports::TempVariableTag
23

34
class TempVariableTag extends TTempVariableTag {
45
string toString() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ class Instruction extends Construction::TInstruction {
512512
else if getResultType() instanceof Language::UnknownType then
513513
result = Construction::getInstructionResultSize(this)
514514
else (
515-
result = getResultType().getSize()
515+
result = Language::getTypeSize(getResultType())
516516
)
517517
}
518518

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class Operand extends TOperand {
186186
* a known constant size, this predicate does not hold.
187187
*/
188188
int getSize() {
189-
result = getType().getSize()
189+
result = Language::getTypeSize(getType())
190190
}
191191
}
192192

@@ -450,7 +450,7 @@ class SideEffectOperand extends TypedOperand {
450450
if getType() instanceof Language::UnknownType then
451451
result = Construction::getInstructionOperandSize(useInstr, tag)
452452
else
453-
result = getType().getSize()
453+
result = Language::getTypeSize(getType())
454454
}
455455

456456
override MemoryAccessKind getMemoryAccess() {
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import semmle.code.cpp.ir.internal.IRCppLanguage as Language
2+
private import semmle.code.cpp.ir.internal.TempVariableTag as TempVariableTag_
3+
4+
module Imports {
5+
module TempVariableTag = TempVariableTag_;
6+
}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ class Instruction extends Construction::TInstruction {
512512
else if getResultType() instanceof Language::UnknownType then
513513
result = Construction::getInstructionResultSize(this)
514514
else (
515-
result = getResultType().getSize()
515+
result = Language::getTypeSize(getResultType())
516516
)
517517
}
518518

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class Operand extends TOperand {
186186
* a known constant size, this predicate does not hold.
187187
*/
188188
int getSize() {
189-
result = getType().getSize()
189+
result = Language::getTypeSize(getType())
190190
}
191191
}
192192

@@ -450,7 +450,7 @@ class SideEffectOperand extends TypedOperand {
450450
if getType() instanceof Language::UnknownType then
451451
result = Construction::getInstructionOperandSize(useInstr, tag)
452452
else
453-
result = getType().getSize()
453+
result = Language::getTypeSize(getType())
454454
}
455455

456456
override MemoryAccessKind getMemoryAccess() {

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -512,7 +512,7 @@ class Instruction extends Construction::TInstruction {
512512
else if getResultType() instanceof Language::UnknownType then
513513
result = Construction::getInstructionResultSize(this)
514514
else (
515-
result = getResultType().getSize()
515+
result = Language::getTypeSize(getResultType())
516516
)
517517
}
518518

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ class Operand extends TOperand {
186186
* a known constant size, this predicate does not hold.
187187
*/
188188
int getSize() {
189-
result = getType().getSize()
189+
result = Language::getTypeSize(getType())
190190
}
191191
}
192192

@@ -450,7 +450,7 @@ class SideEffectOperand extends TypedOperand {
450450
if getType() instanceof Language::UnknownType then
451451
result = Construction::getInstructionOperandSize(useInstr, tag)
452452
else
453-
result = getType().getSize()
453+
result = Language::getTypeSize(getType())
454454
}
455455

456456
override MemoryAccessKind getMemoryAccess() {

0 commit comments

Comments
 (0)