Skip to content

Commit d2bee79

Browse files
authored
Merge pull request #1600 from AndreiDiaconu1/ircsharp
C#: Initial port of IR for C#
2 parents 36f99c1 + deeff07 commit d2bee79

File tree

94 files changed

+12801
-19
lines changed

Some content is hidden

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

94 files changed

+12801
-19
lines changed

config/identical-files.json

Lines changed: 74 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -39,42 +39,90 @@
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"
68+
],
69+
"IR Operand Tag": [
70+
"cpp/ql/src/semmle/code/cpp/ir/implementation/internal/OperandTag.qll",
71+
"csharp/ql/src/semmle/code/csharp/ir/implementation/internal/OperandTag.qll"
72+
],
73+
"IR TIRVariable":[
74+
"cpp/ql/src/semmle/code/cpp/ir/implementation/internal/TIRVariable.qll",
75+
"csharp/ql/src/semmle/code/csharp/ir/implementation/internal/TIRVariable.qll"
6376
],
6477
"IR IR": [
6578
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/IR.qll",
6679
"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"
80+
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IR.qll",
81+
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/IR.qll"
6882
],
6983
"IR IRSanity": [
7084
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/IRSanity.qll",
7185
"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"
86+
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/IRSanity.qll",
87+
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/IRSanity.qll"
7388
],
7489
"IR PrintIR": [
7590
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/PrintIR.qll",
7691
"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"
92+
"cpp/ql/src/semmle/code/cpp/ir/implementation/aliased_ssa/PrintIR.qll",
93+
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/PrintIR.qll"
94+
],
95+
"IR IntegerConstant": [
96+
"cpp/ql/src/semmle/code/cpp/ir/internal/IntegerConstant.qll",
97+
"csharp/ql/src/semmle/code/csharp/ir/internal/IntegerConstant.qll"
98+
],
99+
"IR IntegerInteval": [
100+
"cpp/ql/src/semmle/code/cpp/ir/internal/IntegerInterval.qll",
101+
"csharp/ql/src/semmle/code/csharp/ir/internal/IntegerInterval.qll"
102+
],
103+
"IR IntegerPartial": [
104+
"cpp/ql/src/semmle/code/cpp/ir/internal/IntegerPartial.qll",
105+
"csharp/ql/src/semmle/code/csharp/ir/internal/IntegerPartial.qll"
106+
],
107+
"IR Overlap": [
108+
"cpp/ql/src/semmle/code/cpp/ir/internal/Overlap.qll",
109+
"csharp/ql/src/semmle/code/csharp/ir/internal/Overlap.qll"
110+
],
111+
"IR EdgeKind": [
112+
"cpp/ql/src/semmle/code/cpp/ir/implementation/EdgeKind.qll",
113+
"csharp/ql/src/semmle/code/csharp/ir/implementation/EdgeKind.qll"
114+
],
115+
"IR MemoryAccessKind": [
116+
"cpp/ql/src/semmle/code/cpp/ir/implementation/MemoryAccessKind.qll",
117+
"csharp/ql/src/semmle/code/csharp/ir/implementation/MemoryAccessKind.qll"
118+
],
119+
"IR TempVariableTag": [
120+
"cpp/ql/src/semmle/code/cpp/ir/implementation/TempVariableTag.qll",
121+
"csharp/ql/src/semmle/code/csharp/ir/implementation/TempVariableTag.qll"
122+
],
123+
"IR Opcode": [
124+
"cpp/ql/src/semmle/code/cpp/ir/implementation/Opcode.qll",
125+
"csharp/ql/src/semmle/code/csharp/ir/implementation/Opcode.qll"
78126
],
79127
"C++ IR InstructionImports": [
80128
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/InstructionImports.qll",
@@ -148,5 +196,23 @@
148196
"C++ IR PrintDominance": [
149197
"cpp/ql/src/semmle/code/cpp/ir/implementation/raw/internal/reachability/PrintDominance.qll",
150198
"cpp/ql/src/semmle/code/cpp/ir/implementation/unaliased_ssa/internal/reachability/PrintDominance.qll"
199+
],
200+
"C# IR InstructionImports": [
201+
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/InstructionImports.qll"
202+
],
203+
"C# IR IRImports": [
204+
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/IRImports.qll"
205+
],
206+
"C# IR IRBlockImports": [
207+
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/IRBlockImports.qll"
208+
],
209+
"C# IR IRVariableImports": [
210+
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/IRVariableImports.qll"
211+
],
212+
"C# IR OperandImports": [
213+
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/OperandImports.qll"
214+
],
215+
"C# IR PrintIRImports": [
216+
"csharp/ql/src/semmle/code/csharp/ir/implementation/raw/internal/PrintIRImports.qll"
151217
]
152218
}

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ private newtype TOpcode =
4343
TVariableAddress() or
4444
TFieldAddress() or
4545
TFunctionAddress() or
46+
TElementsAddress() or
4647
TConstant() or
4748
TStringConstant() or
4849
TConditionalBranch() or
@@ -72,7 +73,8 @@ private newtype TOpcode =
7273
TBufferMayWriteSideEffect() or
7374
TChi() or
7475
TInlineAsm() or
75-
TUnreached()
76+
TUnreached() or
77+
TNewObj()
7678

7779
class Opcode extends TOpcode {
7880
string toString() {
@@ -190,6 +192,7 @@ module Opcode {
190192
class DynamicCastToVoid extends UnaryOpcode, TDynamicCastToVoid { override final string toString() { result = "DynamicCastToVoid" } }
191193
class VariableAddress extends Opcode, TVariableAddress { override final string toString() { result = "VariableAddress" } }
192194
class FieldAddress extends UnaryOpcode, TFieldAddress { override final string toString() { result = "FieldAddress" } }
195+
class ElementsAddress extends UnaryOpcode, TElementsAddress { override final string toString() { result = "ElementsAddress" } }
193196
class FunctionAddress extends Opcode, TFunctionAddress { override final string toString() { result = "FunctionAddress" } }
194197
class Constant extends Opcode, TConstant { override final string toString() { result = "Constant" } }
195198
class StringConstant extends Opcode, TStringConstant { override final string toString() { result = "StringConstant" } }
@@ -221,4 +224,5 @@ module Opcode {
221224
class Chi extends Opcode, TChi { override final string toString() { result = "Chi" } }
222225
class InlineAsm extends Opcode, TInlineAsm { override final string toString() { result = "InlineAsm" } }
223226
class Unreached extends Opcode, TUnreached { override final string toString() { result = "Unreached" } }
227+
class NewObj extends Opcode, TNewObj { override final string toString() { result = "NewObj" } }
224228
}

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)