@@ -458,14 +458,6 @@ static bool dumpAndPrintScopeMap(const CompilerInstance &Instance,
458
458
return Instance.getASTContext ().hadError ();
459
459
}
460
460
461
- static SourceFile &
462
- getPrimaryOrMainSourceFile (const CompilerInstance &Instance) {
463
- if (SourceFile *SF = Instance.getPrimarySourceFile ()) {
464
- return *SF;
465
- }
466
- return Instance.getMainModule ()->getMainSourceFile ();
467
- }
468
-
469
461
// / Dumps the AST of all available primary source files. If corresponding output
470
462
// / files were specified, use them; otherwise, dump the AST to stdout.
471
463
static bool dumpAST (CompilerInstance &Instance,
@@ -512,7 +504,7 @@ static bool dumpAST(CompilerInstance &Instance,
512
504
} else {
513
505
// Some invocations don't have primary files. In that case, we default to
514
506
// looking for the main file and dumping it to `stdout`.
515
- auto &SF = getPrimaryOrMainSourceFile (Instance );
507
+ auto &SF = Instance. getPrimaryOrMainSourceFile ();
516
508
dumpAST (&SF, llvm::outs ());
517
509
}
518
510
return Instance.getASTContext ().hadError ();
@@ -1041,7 +1033,7 @@ static void performEndOfPipelineActions(CompilerInstance &Instance) {
1041
1033
ctx.getClangModuleLoader ()->dumpSwiftLookupTables ();
1042
1034
1043
1035
if (opts.DumpAvailabilityScopes )
1044
- getPrimaryOrMainSourceFile (Instance ).getAvailabilityScope ()->dump (
1036
+ Instance. getPrimaryOrMainSourceFile ().getAvailabilityScope ()->dump (
1045
1037
llvm::errs (), Instance.getASTContext ().SourceMgr );
1046
1038
1047
1039
// Report mangling stats if there was no error.
@@ -1286,14 +1278,14 @@ static bool performAction(CompilerInstance &Instance,
1286
1278
case FrontendOptions::ActionType::PrintAST:
1287
1279
return withSemanticAnalysis (
1288
1280
Instance, observer, [](CompilerInstance &Instance) {
1289
- getPrimaryOrMainSourceFile (Instance ).print (
1281
+ Instance. getPrimaryOrMainSourceFile ().print (
1290
1282
llvm::outs (), PrintOptions::printEverything ());
1291
1283
return Instance.getASTContext ().hadError ();
1292
1284
});
1293
1285
case FrontendOptions::ActionType::PrintASTDecl:
1294
1286
return withSemanticAnalysis (
1295
1287
Instance, observer, [](CompilerInstance &Instance) {
1296
- getPrimaryOrMainSourceFile (Instance ).print (
1288
+ Instance. getPrimaryOrMainSourceFile ().print (
1297
1289
llvm::outs (), PrintOptions::printDeclarations ());
1298
1290
return Instance.getASTContext ().hadError ();
1299
1291
});
@@ -1302,11 +1294,11 @@ static bool performAction(CompilerInstance &Instance,
1302
1294
Instance, observer,
1303
1295
[](CompilerInstance &Instance) {
1304
1296
return dumpAndPrintScopeMap (Instance,
1305
- getPrimaryOrMainSourceFile (Instance ));
1297
+ Instance. getPrimaryOrMainSourceFile ());
1306
1298
},
1307
1299
/* runDespiteErrors=*/ true );
1308
1300
case FrontendOptions::ActionType::DumpInterfaceHash:
1309
- getPrimaryOrMainSourceFile (Instance ).dumpInterfaceHash (llvm::errs ());
1301
+ Instance. getPrimaryOrMainSourceFile ().dumpInterfaceHash (llvm::errs ());
1310
1302
return Instance.getASTContext ().hadError ();
1311
1303
case FrontendOptions::ActionType::EmitImportedModules:
1312
1304
return emitImportedModules (Instance.getMainModule (), opts,
0 commit comments