@@ -4865,34 +4865,30 @@ SILGenFunction::emitApplyOfLibraryIntrinsic(SILLocation loc,
4865
4865
finalArgs, calleeTypeInfo, ApplyOptions::None, ctx);
4866
4866
}
4867
4867
4868
- static StringRef
4869
- getMagicFunctionString (SILGenFunction &SGF) {
4870
- assert (SGF.MagicFunctionName
4868
+ StringRef SILGenFunction::getMagicFunctionString () {
4869
+ assert (MagicFunctionName
4871
4870
&& " asking for #function but we don't have a function name?!" );
4872
- if (SGF. MagicFunctionString .empty ()) {
4873
- llvm::raw_string_ostream os (SGF. MagicFunctionString );
4874
- SGF. MagicFunctionName .print (os);
4871
+ if (MagicFunctionString.empty ()) {
4872
+ llvm::raw_string_ostream os (MagicFunctionString);
4873
+ MagicFunctionName.print (os);
4875
4874
}
4876
- return SGF. MagicFunctionString ;
4875
+ return MagicFunctionString;
4877
4876
}
4878
4877
4879
- static StringRef
4880
- getMagicFilePathString (SILGenFunction &SGF, SourceLoc loc) {
4881
- if (!loc.isValid ())
4882
- return " " ;
4883
-
4884
- return SGF.getASTContext ().SourceMgr .getDisplayNameForLoc (loc);
4878
+ StringRef SILGenFunction::getMagicFilePathString (SourceLoc loc) {
4879
+ assert (loc.isValid ());
4880
+ return getSourceManager ().getDisplayNameForLoc (loc);
4885
4881
}
4886
4882
4887
- static std::string
4888
- getConciseMagicFileString (SILGenFunction &SGF, SourceLoc loc) {
4889
- if (!loc.isValid ())
4890
- return " " ;
4883
+ std::string SILGenFunction::getMagicFileString (SourceLoc loc) {
4884
+ auto path = getMagicFilePathString (loc);
4885
+
4886
+ if (!getASTContext ().LangOpts .EnableConcisePoundFile )
4887
+ return path;
4891
4888
4892
- auto path = getMagicFilePathString (SGF, loc);
4893
4889
auto value = llvm::sys::path::filename (path).str ();
4894
4890
value += " (" ;
4895
- value += SGF. getModule ().getSwiftModule ()->getNameStr ();
4891
+ value += getModule ().getSwiftModule ()->getNameStr ();
4896
4892
value += " )" ;
4897
4893
return value;
4898
4894
}
@@ -5152,9 +5148,7 @@ RValue SILGenFunction::emitLiteral(LiteralExpr *literal, SGFContext C) {
5152
5148
auto magicLiteral = cast<MagicIdentifierLiteralExpr>(literal);
5153
5149
switch (magicLiteral->getKind ()) {
5154
5150
case MagicIdentifierLiteralExpr::File: {
5155
- std::string value = getASTContext ().LangOpts .EnableConcisePoundFile
5156
- ? getConciseMagicFileString (*this , loc)
5157
- : getMagicFilePathString (*this , loc).str ();
5151
+ std::string value = loc.isValid () ? getMagicFileString (loc) : " " ;
5158
5152
builtinLiteralArgs = emitStringLiteral (*this , literal, value, C,
5159
5153
magicLiteral->getStringEncoding ());
5160
5154
builtinInit = magicLiteral->getBuiltinInitializer ();
@@ -5163,7 +5157,7 @@ RValue SILGenFunction::emitLiteral(LiteralExpr *literal, SGFContext C) {
5163
5157
}
5164
5158
5165
5159
case MagicIdentifierLiteralExpr::FilePath: {
5166
- StringRef value = getMagicFilePathString (* this , loc);
5160
+ StringRef value = loc. isValid () ? getMagicFilePathString ( loc) : " " ;
5167
5161
builtinLiteralArgs = emitStringLiteral (*this , literal, value, C,
5168
5162
magicLiteral->getStringEncoding ());
5169
5163
builtinInit = magicLiteral->getBuiltinInitializer ();
@@ -5172,9 +5166,7 @@ RValue SILGenFunction::emitLiteral(LiteralExpr *literal, SGFContext C) {
5172
5166
}
5173
5167
5174
5168
case MagicIdentifierLiteralExpr::Function: {
5175
- StringRef value = " " ;
5176
- if (loc.isValid ())
5177
- value = getMagicFunctionString (*this );
5169
+ StringRef value = loc.isValid () ? getMagicFunctionString () : " " ;
5178
5170
builtinLiteralArgs = emitStringLiteral (*this , literal, value, C,
5179
5171
magicLiteral->getStringEncoding ());
5180
5172
builtinInit = magicLiteral->getBuiltinInitializer ();
0 commit comments