Skip to content

Commit 32e128d

Browse files
author
Robert Marsh
committed
C#: sync IR files
1 parent 5bb6441 commit 32e128d

8 files changed

Lines changed: 25 additions & 20 deletions

File tree

csharp/ql/src/experimental/ir/implementation/IRConfiguration.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class IRConfiguration extends TIRConfiguration {
1616
/**
1717
* Holds if IR should be created for function `func`. By default, holds for all functions.
1818
*/
19-
predicate shouldCreateIRForFunction(Language::Function func) { any() }
19+
predicate shouldCreateIRForFunction(Language::Declaration func) { any() }
2020

2121
/**
2222
* Holds if the strings used as part of an IR dump should be generated for function `func`.
@@ -25,7 +25,7 @@ class IRConfiguration extends TIRConfiguration {
2525
* of debug strings for IR that will not be dumped. We still generate the actual IR for these
2626
* functions, however, to preserve the results of any interprocedural analysis.
2727
*/
28-
predicate shouldEvaluateDebugStringsForFunction(Language::Function func) { any() }
28+
predicate shouldEvaluateDebugStringsForFunction(Language::Declaration func) { any() }
2929
}
3030

3131
private newtype TIREscapeAnalysisConfiguration = MkIREscapeAnalysisConfiguration()

csharp/ql/src/experimental/ir/implementation/internal/IRFunctionBase.qll

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,28 @@
55
private import IRFunctionBaseInternal
66

77
private newtype TIRFunction =
8-
MkIRFunction(Language::Function func) { IRConstruction::Raw::functionHasIR(func) }
8+
TFunctionIRFunction(Language::Function func) { IRConstruction::Raw::functionHasIR(func) } or
9+
TVarInitIRFunction(Language::GlobalVariable var) { IRConstruction::Raw::varHasIRFunc(var) }
910

1011
/**
1112
* The IR for a function. This base class contains only the predicates that are the same between all
1213
* phases of the IR. Each instantiation of `IRFunction` extends this class.
1314
*/
1415
class IRFunctionBase extends TIRFunction {
15-
Language::Function func;
16+
Language::Declaration decl;
1617

17-
IRFunctionBase() { this = MkIRFunction(func) }
18+
IRFunctionBase() {
19+
this = TFunctionIRFunction(decl)
20+
or
21+
this = TVarInitIRFunction(decl)
22+
}
1823

1924
/** Gets a textual representation of this element. */
20-
final string toString() { result = "IR: " + func.toString() }
25+
final string toString() { result = "IR: " + decl.toString() }
2126

2227
/** Gets the function whose IR is represented. */
23-
final Language::Function getFunction() { result = func }
28+
final Language::Declaration getFunction() { result = decl }
2429

2530
/** Gets the location of the function. */
26-
final Language::Location getLocation() { result = func.getLocation() }
31+
final Language::Location getLocation() { result = decl.getLocation() }
2732
}

csharp/ql/src/experimental/ir/implementation/raw/IRBlock.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class IRBlockBase extends TIRBlock {
9797
/**
9898
* Gets the `Function` that contains this block.
9999
*/
100-
final Language::Function getEnclosingFunction() {
100+
final Language::Declaration getEnclosingFunction() {
101101
result = getFirstInstruction(this).getEnclosingFunction()
102102
}
103103
}

csharp/ql/src/experimental/ir/implementation/raw/Instruction.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class Instruction extends Construction::TStageInstruction {
194194
/**
195195
* Gets the function that contains this instruction.
196196
*/
197-
final Language::Function getEnclosingFunction() {
197+
final Language::Declaration getEnclosingFunction() {
198198
result = this.getEnclosingIRFunction().getFunction()
199199
}
200200

csharp/ql/src/experimental/ir/implementation/raw/PrintIR.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ class PrintIRConfiguration extends TPrintIRConfiguration {
2626
* Holds if the IR for `func` should be printed. By default, holds for all
2727
* functions.
2828
*/
29-
predicate shouldPrintFunction(Language::Function func) { any() }
29+
predicate shouldPrintFunction(Language::Declaration decl) { any() }
3030
}
3131

3232
/**
3333
* Override of `IRConfiguration` to only evaluate debug strings for the functions that are to be dumped.
3434
*/
3535
private class FilteredIRConfiguration extends IRConfiguration {
36-
override predicate shouldEvaluateDebugStringsForFunction(Language::Function func) {
36+
override predicate shouldEvaluateDebugStringsForFunction(Language::Declaration func) {
3737
shouldPrintFunction(func)
3838
}
3939
}
4040

41-
private predicate shouldPrintFunction(Language::Function func) {
42-
exists(PrintIRConfiguration config | config.shouldPrintFunction(func))
41+
private predicate shouldPrintFunction(Language::Declaration decl) {
42+
exists(PrintIRConfiguration config | config.shouldPrintFunction(decl))
4343
}
4444

4545
private string getAdditionalInstructionProperty(Instruction instr, string key) {

csharp/ql/src/experimental/ir/implementation/unaliased_ssa/IRBlock.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ class IRBlockBase extends TIRBlock {
9797
/**
9898
* Gets the `Function` that contains this block.
9999
*/
100-
final Language::Function getEnclosingFunction() {
100+
final Language::Declaration getEnclosingFunction() {
101101
result = getFirstInstruction(this).getEnclosingFunction()
102102
}
103103
}

csharp/ql/src/experimental/ir/implementation/unaliased_ssa/Instruction.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ class Instruction extends Construction::TStageInstruction {
194194
/**
195195
* Gets the function that contains this instruction.
196196
*/
197-
final Language::Function getEnclosingFunction() {
197+
final Language::Declaration getEnclosingFunction() {
198198
result = this.getEnclosingIRFunction().getFunction()
199199
}
200200

csharp/ql/src/experimental/ir/implementation/unaliased_ssa/PrintIR.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,20 +26,20 @@ class PrintIRConfiguration extends TPrintIRConfiguration {
2626
* Holds if the IR for `func` should be printed. By default, holds for all
2727
* functions.
2828
*/
29-
predicate shouldPrintFunction(Language::Function func) { any() }
29+
predicate shouldPrintFunction(Language::Declaration decl) { any() }
3030
}
3131

3232
/**
3333
* Override of `IRConfiguration` to only evaluate debug strings for the functions that are to be dumped.
3434
*/
3535
private class FilteredIRConfiguration extends IRConfiguration {
36-
override predicate shouldEvaluateDebugStringsForFunction(Language::Function func) {
36+
override predicate shouldEvaluateDebugStringsForFunction(Language::Declaration func) {
3737
shouldPrintFunction(func)
3838
}
3939
}
4040

41-
private predicate shouldPrintFunction(Language::Function func) {
42-
exists(PrintIRConfiguration config | config.shouldPrintFunction(func))
41+
private predicate shouldPrintFunction(Language::Declaration decl) {
42+
exists(PrintIRConfiguration config | config.shouldPrintFunction(decl))
4343
}
4444

4545
private string getAdditionalInstructionProperty(Instruction instr, string key) {

0 commit comments

Comments
 (0)