@@ -56,9 +56,6 @@ struct UnboundImport {
56
56
// / determine the behavior expected for this import.
57
57
AttributedImport<UnloadedImportedModule> import;
58
58
59
- // / The source location to use when diagnosing errors for this import.
60
- SourceLoc importLoc;
61
-
62
59
// / If this UnboundImport directly represents an ImportDecl, contains the
63
60
// / ImportDecl it represents. This should only be used for diagnostics and
64
61
// / for updating the AST; if you want to read information about the import,
@@ -480,7 +477,8 @@ ModuleImplicitImportsRequest::evaluate(Evaluator &evaluator,
480
477
!clangImporter->importBridgingHeader (bridgingHeaderPath, module)) {
481
478
auto *headerModule = clangImporter->getImportedHeaderModule ();
482
479
assert (headerModule && " Didn't load bridging header?" );
483
- imports.emplace_back (ImportedModule (headerModule), ImportFlags::Exported);
480
+ imports.emplace_back (
481
+ ImportedModule (headerModule), SourceLoc (), ImportFlags::Exported);
484
482
}
485
483
486
484
// Implicitly import the underlying Clang half of this module if needed.
@@ -490,7 +488,7 @@ ModuleImplicitImportsRequest::evaluate(Evaluator &evaluator,
490
488
ImportPath::Builder importPath (module->getName ());
491
489
unloadedImports.emplace_back (UnloadedImportedModule (importPath.copyTo (ctx),
492
490
/* isScoped=*/ false ),
493
- ImportFlags::Exported);
491
+ SourceLoc (), ImportFlags::Exported);
494
492
}
495
493
496
494
return { ctx.AllocateCopy (imports), ctx.AllocateCopy (unloadedImports) };
@@ -513,7 +511,7 @@ void ImportResolver::addImplicitImports() {
513
511
}
514
512
515
513
UnboundImport::UnboundImport (AttributedImport<UnloadedImportedModule> implicit)
516
- : import(implicit), importLoc(),
514
+ : import(implicit),
517
515
importOrUnderlyingModuleDecl(static_cast <ImportDecl *>(nullptr )) {}
518
516
519
517
// ===----------------------------------------------------------------------===//
@@ -523,8 +521,8 @@ UnboundImport::UnboundImport(AttributedImport<UnloadedImportedModule> implicit)
523
521
// / Create an UnboundImport for a user-written import declaration.
524
522
UnboundImport::UnboundImport (ImportDecl *ID)
525
523
: import(UnloadedImportedModule(ID->getImportPath (), ID->getImportKind()),
526
- {}),
527
- importLoc(ID-> getLoc ()), importOrUnderlyingModuleDecl(ID)
524
+ ID->getStartLoc(), {}),
525
+ importOrUnderlyingModuleDecl(ID)
528
526
{
529
527
if (ID->isExported ())
530
528
import.options |= ImportFlags::Exported;
@@ -571,10 +569,11 @@ bool UnboundImport::checkNotTautological(const SourceFile &SF) {
571
569
572
570
StringRef filename = llvm::sys::path::filename (SF.getFilename ());
573
571
if (filename.empty ())
574
- ctx.Diags .diagnose (importLoc, diag::sema_import_current_module,
572
+ ctx.Diags .diagnose (import. importLoc , diag::sema_import_current_module,
575
573
modulePath.front ().Item );
576
574
else
577
- ctx.Diags .diagnose (importLoc, diag::sema_import_current_module_with_file,
575
+ ctx.Diags .diagnose (import.importLoc ,
576
+ diag::sema_import_current_module_with_file,
578
577
filename, modulePath.front ().Item );
579
578
580
579
return false ;
@@ -584,7 +583,7 @@ bool UnboundImport::checkModuleLoaded(ModuleDecl *M, SourceFile &SF) {
584
583
if (M)
585
584
return true ;
586
585
587
- diagnoseNoSuchModule (SF.getParentModule (), importLoc,
586
+ diagnoseNoSuchModule (SF.getParentModule (), import. importLoc ,
588
587
import.module .getModulePath (), /* nonfatalInREPL=*/ true );
589
588
return false ;
590
589
}
@@ -963,9 +962,9 @@ UnboundImport::UnboundImport(
963
962
ASTContext &ctx, const UnboundImport &base, Identifier overlayName,
964
963
const AttributedImport<ImportedModule> &declaringImport,
965
964
const AttributedImport<ImportedModule> &bystandingImport)
966
- : import(makeUnimportedCrossImportOverlay(ctx, overlayName, base,
967
- declaringImport), {} ),
968
- importLoc( base.importLoc),
965
+ : import(makeUnimportedCrossImportOverlay(
966
+ ctx, overlayName, base, declaringImport ),
967
+ base.import. importLoc, {} ),
969
968
importOrUnderlyingModuleDecl (declaringImport.module.importedModule)
970
969
{
971
970
// A cross-import is never private or testable, and never comes from a private
@@ -1099,15 +1098,16 @@ void ImportResolver::findCrossImports(
1099
1098
// Find modules we need to import.
1100
1099
SmallVector<Identifier, 4 > names;
1101
1100
declaringImport.module .importedModule ->findDeclaredCrossImportOverlays (
1102
- bystandingImport.module .importedModule ->getName (), names, I.importLoc );
1101
+ bystandingImport.module .importedModule ->getName (), names,
1102
+ I.import .importLoc );
1103
1103
1104
1104
// If we're diagnosing cases where we cross-import in both directions, get the
1105
1105
// inverse list. Otherwise, leave the list empty.
1106
1106
SmallVector<Identifier, 4 > oppositeNames;
1107
1107
if (shouldDiagnoseRedundantCrossImports)
1108
1108
bystandingImport.module .importedModule ->findDeclaredCrossImportOverlays (
1109
1109
declaringImport.module .importedModule ->getName (), oppositeNames,
1110
- I.importLoc );
1110
+ I.import . importLoc );
1111
1111
1112
1112
if (ctx.Stats && !names.empty ())
1113
1113
++ctx.Stats ->getFrontendCounters ().NumCrossImportsFound ;
@@ -1124,13 +1124,14 @@ void ImportResolver::findCrossImports(
1124
1124
declaringImport, bystandingImport);
1125
1125
1126
1126
if (llvm::is_contained (oppositeNames, name))
1127
- ctx.Diags .diagnose (I.importLoc , diag::cross_imported_by_both_modules,
1127
+ ctx.Diags .diagnose (I.import .importLoc ,
1128
+ diag::cross_imported_by_both_modules,
1128
1129
declaringImport.module .importedModule ->getName (),
1129
1130
bystandingImport.module .importedModule ->getName (),
1130
1131
name);
1131
1132
1132
1133
if (ctx.LangOpts .EnableCrossImportRemarks )
1133
- ctx.Diags .diagnose (I.importLoc , diag::cross_import_added,
1134
+ ctx.Diags .diagnose (I.import . importLoc , diag::cross_import_added,
1134
1135
declaringImport.module .importedModule ->getName (),
1135
1136
bystandingImport.module .importedModule ->getName (),
1136
1137
name);
0 commit comments