19#include "llvm/ADT/StringExtras.h"
26 bool FromInclude =
false) {
29 if (
auto *LSD = dyn_cast<LinkageSpecDecl>(DC)) {
30 switch (LSD->getLanguage()) {
31 case LinkageSpecLanguageIDs::C:
33 ExternCLoc = LSD->getBeginLoc();
35 case LinkageSpecLanguageIDs::CXX:
41 while (isa<LinkageSpecDecl>(DC) || isa<ExportDecl>(DC))
44 if (!isa<TranslationUnitDecl>(DC)) {
46 ? diag::ext_module_import_not_at_top_level_noop
47 : diag::err_module_import_not_at_top_level_fatal)
49 S.
Diag(cast<Decl>(DC)->getBeginLoc(),
50 diag::note_module_import_not_at_top_level)
53 S.
Diag(ImportLoc, diag::ext_module_import_in_extern_c)
55 S.
Diag(ExternCLoc, diag::note_extern_c_begins_here);
68 for (
auto &Piece :
Path) {
71 Name += Piece.first->getName();
86 Module *&FoundPrimaryModuleInterface) {
97 if (FoundPrimaryModuleInterface)
98 return Imported == FoundPrimaryModuleInterface;
113 assert(!FoundPrimaryModuleInterface ||
114 FoundPrimaryModuleInterface == Imported);
115 FoundPrimaryModuleInterface = Imported;
132 bool IsImportingPrimaryModuleInterface =
false) {
134 "'makeTransitiveImportsVisible()' is intended for standard C++ named "
138 Worklist.push_back(Imported);
140 Module *FoundPrimaryModuleInterface =
141 IsImportingPrimaryModuleInterface ? Imported :
nullptr;
143 while (!Worklist.empty()) {
144 Module *Importing = Worklist.pop_back_val();
151 VisibleModules.
setVisible(Importing, ImportLoc);
154 FoundPrimaryModuleInterface))
156 if (!VisibleModules.
isVisible(TransImported))
157 Worklist.push_back(TransImported);
165 PushGlobalModuleFragment(ModuleLoc);