@@ -105,6 +105,9 @@ class VariableNameInferrer {
105105 bool empty () const { return !insertionPointIndex; }
106106 };
107107
108+ // / ASTContext for forming identifiers when we need to.
109+ ASTContext &astContext;
110+
108111 // / The stacklist that we use to print out variable names.
109112 // /
110113 // / Has to be a small vector since we push/pop the last segment start. This
@@ -128,12 +131,13 @@ class VariableNameInferrer {
128131
129132public:
130133 VariableNameInferrer (SILFunction *fn, SmallString<64 > &resultingString)
131- : variableNamePath(), resultingString(resultingString) {}
134+ : astContext(fn->getASTContext ()), variableNamePath(),
135+ resultingString(resultingString) {}
132136
133137 VariableNameInferrer (SILFunction *fn, Options options,
134138 SmallString<64 > &resultingString)
135- : variableNamePath(), resultingString(resultingString), options(options) {
136- }
139+ : astContext(fn-> getASTContext ()), variableNamePath(),
140+ resultingString(resultingString), options(options) { }
137141
138142 // / Attempts to infer a name from just uses of \p searchValue.
139143 // /
@@ -238,10 +242,7 @@ class VariableNameInferrer {
238242 llvm::raw_svector_ostream stream (indexString);
239243 stream << index;
240244 }
241- return rootValue->getFunction ()
242- ->getASTContext ()
243- .getIdentifier (indexString)
244- .str ();
245+ return astContext.getIdentifier (indexString).str ();
245246 }
246247};
247248
0 commit comments