Skip to content

Commit 8c4a0ae

Browse files
committed
[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
1 parent c6ff96f commit 8c4a0ae

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

lib/SILGen/SILGen.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1122,7 +1122,7 @@ void SILGenModule::emitFunctionDefinition(SILDeclRef constant, SILFunction *f) {
11221122

11231123
// TODO: Handle main SourceFile emission (currently done by
11241124
// SourceFileScope).
1125-
auto loc = RegularLocation::getModuleLocation();
1125+
auto loc = constant.getAsRegularLocation();
11261126
preEmitFunction(constant, f, loc);
11271127
auto *decl = constant.getDecl();
11281128
auto *dc = decl->getDeclContext();

lib/SILGen/SILGenFunction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -775,7 +775,7 @@ void SILGenFunction::emitArtificialTopLevel(Decl *mainDecl) {
775775
// Emit a call to the main static function.
776776
// return Module.$main();
777777
auto *mainFunc = cast<FuncDecl>(mainDecl);
778-
auto moduleLoc = RegularLocation::getModuleLocation();
778+
auto moduleLoc = SILLocation(mainDecl);
779779
auto *entryBlock = B.getInsertionBB();
780780

781781
SILDeclRef mainFunctionDeclRef(mainFunc, SILDeclRef::Kind::Func);
@@ -862,7 +862,7 @@ void SILGenFunction::emitArtificialTopLevel(Decl *mainDecl) {
862862
}
863863

864864
void SILGenFunction::emitAsyncMainThreadStart(SILDeclRef entryPoint) {
865-
auto moduleLoc = RegularLocation::getModuleLocation();
865+
auto moduleLoc = entryPoint.getAsRegularLocation();
866866
auto *entryBlock = B.getInsertionBB();
867867
auto paramTypeIter = F.getConventions()
868868
.getParameterSILTypes(getTypeExpansionContext())

0 commit comments

Comments
 (0)