From d90fc67c094f4fcb2013ccbd1253697f91aeda92 Mon Sep 17 00:00:00 2001 From: Nate Chandler Date: Thu, 23 Mar 2023 13:12:59 -0700 Subject: [PATCH] [SILGen] Use decl location for main's functions. Previously, the location used for functions corresponding to @main was just RegularLocation::getModuleLocation(). Make that more specific by using the annotated type's location instead. rdar://79508092 --- lib/SILGen/SILGen.cpp | 2 +- lib/SILGen/SILGenFunction.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/SILGen/SILGen.cpp b/lib/SILGen/SILGen.cpp index cbe970dfc2a75..70d262df81fd6 100644 --- a/lib/SILGen/SILGen.cpp +++ b/lib/SILGen/SILGen.cpp @@ -1106,7 +1106,7 @@ void SILGenModule::emitFunctionDefinition(SILDeclRef constant, SILFunction *f) { // TODO: Handle main SourceFile emission (currently done by // SourceFileScope). - auto loc = RegularLocation::getModuleLocation(); + auto loc = constant.getAsRegularLocation(); preEmitFunction(constant, f, loc); auto *decl = constant.getDecl(); auto *dc = decl->getDeclContext(); diff --git a/lib/SILGen/SILGenFunction.cpp b/lib/SILGen/SILGenFunction.cpp index ed65a918cd5d7..ca518d5d1edf8 100644 --- a/lib/SILGen/SILGenFunction.cpp +++ b/lib/SILGen/SILGenFunction.cpp @@ -914,7 +914,7 @@ void SILGenFunction::emitArtificialTopLevel(Decl *mainDecl) { // Emit a call to the main static function. // return Module.$main(); auto *mainFunc = cast(mainDecl); - auto moduleLoc = RegularLocation::getModuleLocation(); + auto moduleLoc = SILLocation(mainDecl); auto *entryBlock = B.getInsertionBB(); SILDeclRef mainFunctionDeclRef(mainFunc, SILDeclRef::Kind::Func); @@ -1001,7 +1001,7 @@ void SILGenFunction::emitArtificialTopLevel(Decl *mainDecl) { } void SILGenFunction::emitAsyncMainThreadStart(SILDeclRef entryPoint) { - auto moduleLoc = RegularLocation::getModuleLocation(); + auto moduleLoc = entryPoint.getAsRegularLocation(); auto *entryBlock = B.getInsertionBB(); auto paramTypeIter = F.getConventions() .getParameterSILTypes(getTypeExpansionContext())