@@ -105,6 +105,9 @@ class VariableNameInferrer {
105
105
bool empty () const { return !insertionPointIndex; }
106
106
};
107
107
108
+ // / ASTContext for forming identifiers when we need to.
109
+ ASTContext &astContext;
110
+
108
111
// / The stacklist that we use to print out variable names.
109
112
// /
110
113
// / Has to be a small vector since we push/pop the last segment start. This
@@ -128,12 +131,13 @@ class VariableNameInferrer {
128
131
129
132
public:
130
133
VariableNameInferrer (SILFunction *fn, SmallString<64 > &resultingString)
131
- : variableNamePath(), resultingString(resultingString) {}
134
+ : astContext(fn->getASTContext ()), variableNamePath(),
135
+ resultingString(resultingString) {}
132
136
133
137
VariableNameInferrer (SILFunction *fn, Options options,
134
138
SmallString<64 > &resultingString)
135
- : variableNamePath(), resultingString(resultingString), options(options) {
136
- }
139
+ : astContext(fn-> getASTContext ()), variableNamePath(),
140
+ resultingString(resultingString), options(options) { }
137
141
138
142
// / Attempts to infer a name from just uses of \p searchValue.
139
143
// /
@@ -238,10 +242,7 @@ class VariableNameInferrer {
238
242
llvm::raw_svector_ostream stream (indexString);
239
243
stream << index;
240
244
}
241
- return rootValue->getFunction ()
242
- ->getASTContext ()
243
- .getIdentifier (indexString)
244
- .str ();
245
+ return astContext.getIdentifier (indexString).str ();
245
246
}
246
247
};
247
248
0 commit comments