Skip to content

Commit 15011fb

Browse files
committed
Change getSourceFileOfCodeToBeGenerated to getPrimaryOrMainSourceFile.
# Conflicts: # lib/FrontendTool/FrontendTool.cpp
1 parent 34df54a commit 15011fb

File tree

1 file changed

+15
-17
lines changed

1 file changed

+15
-17
lines changed

lib/FrontendTool/FrontendTool.cpp

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -660,9 +660,8 @@ static void dumpAndPrintScopeMap(CompilerInvocation &Invocation,
660660
scope.print(llvm::errs());
661661
}
662662

663-
static SourceFile *
664-
getSourceFileOfCodeToBeGenerated(CompilerInvocation &Invocation,
665-
CompilerInstance &Instance) {
663+
static SourceFile *getPrimaryOrMainSourceFile(CompilerInvocation &Invocation,
664+
CompilerInstance &Instance) {
666665
SourceFile *SF = Instance.getPrimarySourceFile();
667666
if (!SF) {
668667
SourceFileKind Kind = Invocation.getSourceFileKind();
@@ -686,36 +685,35 @@ static Optional<bool> dumpASTIfNeeded(CompilerInvocation &Invocation,
686685
return None;
687686

688687
case FrontendOptions::ActionType::PrintAST:
689-
getSourceFileOfCodeToBeGenerated(Invocation, Instance)
688+
getPrimaryOrMainSourceFile(Invocation, Instance)
690689
->print(llvm::outs(), PrintOptions::printEverything());
691690
break;
692691

693692
case FrontendOptions::ActionType::DumpScopeMaps:
694-
dumpAndPrintScopeMap(
695-
Invocation, Instance,
696-
getSourceFileOfCodeToBeGenerated(Invocation, Instance));
693+
dumpAndPrintScopeMap(Invocation, Instance,
694+
getPrimaryOrMainSourceFile(Invocation, Instance));
697695
break;
698696

699697
case FrontendOptions::ActionType::DumpTypeRefinementContexts:
700-
getSourceFileOfCodeToBeGenerated(Invocation, Instance)
698+
getPrimaryOrMainSourceFile(Invocation, Instance)
701699
->getTypeRefinementContext()
702700
->dump(llvm::errs(), Context.SourceMgr);
703701
break;
704702

705703
case FrontendOptions::ActionType::DumpInterfaceHash:
706-
getSourceFileOfCodeToBeGenerated(Invocation, Instance)
704+
getPrimaryOrMainSourceFile(Invocation, Instance)
707705
->dumpInterfaceHash(llvm::errs());
708706
break;
709707

710708
case FrontendOptions::ActionType::EmitSyntax:
711-
emitSyntax(getSourceFileOfCodeToBeGenerated(Invocation, Instance),
709+
emitSyntax(getPrimaryOrMainSourceFile(Invocation, Instance),
712710
Invocation.getLangOptions(), Instance.getSourceMgr(),
713711
opts.InputsAndOutputs.getSingleOutputFilename());
714712
break;
715713

716714
case FrontendOptions::ActionType::DumpParse:
717715
case FrontendOptions::ActionType::DumpAST:
718-
getSourceFileOfCodeToBeGenerated(Invocation, Instance)->dump();
716+
getPrimaryOrMainSourceFile(Invocation, Instance)->dump();
719717
break;
720718

721719
case FrontendOptions::ActionType::EmitImportedModules:
@@ -1039,8 +1037,8 @@ static void setPrivateDiscriminatorIfNeeded(IRGenOptions &IRGenOpts,
10391037
IRGenOpts.DWARFDebugFlags += (" -private-discriminator " + PD.str()).str();
10401038
}
10411039

1042-
static bool serializeSIBIfNeeded(FrontendOptions &opts, SILModule *SM,
1043-
ASTContext &Context, ModuleOrSourceFile MSF) {
1040+
static bool serializeSIB(FrontendOptions &opts, SILModule *SM,
1041+
ASTContext &Context, ModuleOrSourceFile MSF) {
10441042
const std::string &moduleOutputPath = opts.ModuleOutputPath;
10451043
assert(!moduleOutputPath.empty() && "must have an output path");
10461044

@@ -1177,8 +1175,8 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
11771175

11781176
if (Action == FrontendOptions::ActionType::EmitSIBGen) {
11791177
linkAllIfNeeded(Invocation, SM.get());
1180-
serializeSIBIfNeeded(Invocation.getFrontendOptions(), SM.get(),
1181-
Instance.getASTContext(), MSF);
1178+
serializeSIB(Invocation.getFrontendOptions(), SM.get(),
1179+
Instance.getASTContext(), MSF);
11821180
return Context.hadError();
11831181
}
11841182

@@ -1237,8 +1235,8 @@ static bool performCompileStepsPostSILGen(CompilerInstance &Instance,
12371235
opts.ImplicitObjCHeaderPath, moduleIsPublic);
12381236

12391237
if (Action == FrontendOptions::ActionType::EmitSIB)
1240-
return serializeSIBIfNeeded(Invocation.getFrontendOptions(), SM.get(),
1241-
Instance.getASTContext(), MSF);
1238+
return serializeSIB(Invocation.getFrontendOptions(), SM.get(),
1239+
Instance.getASTContext(), MSF);
12421240

12431241
const bool haveModulePath =
12441242
!opts.ModuleOutputPath.empty() || !opts.ModuleDocOutputPath.empty();

0 commit comments

Comments
 (0)