File tree Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Expand file tree Collapse file tree 2 files changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -29,6 +29,8 @@ namespace swift {
29
29
class ValueBaseUseIterator ;
30
30
class ValueUseIterator ;
31
31
class SILBasicBlock ;
32
+ class SILFunction ;
33
+ class SILModule ;
32
34
class SILInstruction ;
33
35
class SILLocation ;
34
36
class DominanceInfo ;
@@ -119,6 +121,14 @@ class alignas(8) ValueBase : public SILAllocated<ValueBase> {
119
121
// / If this is a SILArgument or a SILInstruction get its parent basic block,
120
122
// / otherwise return null.
121
123
SILBasicBlock *getParentBB ();
124
+
125
+ // / If this is a SILArgument or a SILInstruction get its parent function,
126
+ // / otherwise return null.
127
+ SILFunction *getFunction ();
128
+
129
+ // / If this is a SILArgument or a SILInstruction get its parent module,
130
+ // / otherwise return null.
131
+ SILModule *getModule ();
122
132
};
123
133
124
134
inline llvm::raw_ostream &operator <<(llvm::raw_ostream &OS,
Original file line number Diff line number Diff line change @@ -38,3 +38,19 @@ SILBasicBlock *ValueBase::getParentBB() {
38
38
return Arg->getParent ();
39
39
return nullptr ;
40
40
}
41
+
42
+ SILFunction *ValueBase::getFunction () {
43
+ if (auto Inst = dyn_cast<SILInstruction>(this ))
44
+ return Inst->getFunction ();
45
+ if (auto Arg = dyn_cast<SILArgument>(this ))
46
+ return Arg->getFunction ();
47
+ return nullptr ;
48
+ }
49
+
50
+ SILModule *ValueBase::getModule () {
51
+ if (auto Inst = dyn_cast<SILInstruction>(this ))
52
+ return &Inst->getModule ();
53
+ if (auto Arg = dyn_cast<SILArgument>(this ))
54
+ return &Arg->getModule ();
55
+ return nullptr ;
56
+ }
You can’t perform that action at this time.
0 commit comments