File tree Expand file tree Collapse file tree
csharp/ql/src/experimental/ir/implementation Expand file tree Collapse file tree Original file line number Diff line number Diff 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
3131private newtype TIREscapeAnalysisConfiguration = MkIREscapeAnalysisConfiguration ( )
Original file line number Diff line number Diff line change 55private import IRFunctionBaseInternal
66
77private 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 */
1415class 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}
Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 */
3535private 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
4545private string getAdditionalInstructionProperty ( Instruction instr , string key ) {
Original file line number Diff line number Diff 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}
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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 */
3535private 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
4545private string getAdditionalInstructionProperty ( Instruction instr , string key ) {
You can’t perform that action at this time.
0 commit comments