Lines Matching full:module

23 static void checkModuleImportContext(Sema &S, Module *M,  in checkModuleImportContext()
59 // of the hierarchical access path for a clang module. However for C++20
78 ModuleScopes.back().Module->Kind == Module::GlobalModuleFragment) { in ActOnGlobalModuleFragmentDecl()
79 // Under -std=c++2a -fmodules-ts, we can find an explicit 'module;' after in ActOnGlobalModuleFragmentDecl()
80 // already implicitly entering the global module fragment. That's OK. in ActOnGlobalModuleFragmentDecl()
82 "unexpectedly encountered multiple global module fragment decls"); in ActOnGlobalModuleFragmentDecl()
87 // We start in the global module; all those declarations are implicitly in ActOnGlobalModuleFragmentDecl()
88 // module-private (though they do not have module linkage). in ActOnGlobalModuleFragmentDecl()
89 Module *GlobalModule = in ActOnGlobalModuleFragmentDecl()
92 // All declarations created from now on are owned by the global module. in ActOnGlobalModuleFragmentDecl()
94 // [module.global.frag]p2 in ActOnGlobalModuleFragmentDecl()
95 // A global-module-fragment specifies the contents of the global module in ActOnGlobalModuleFragmentDecl()
96 // fragment for a module unit. The global module fragment can be used to in ActOnGlobalModuleFragmentDecl()
97 // provide declarations that are attached to the global module and usable in ActOnGlobalModuleFragmentDecl()
98 // within the module unit. in ActOnGlobalModuleFragmentDecl()
100 // So the declations in the global module shouldn't be visible by default. in ActOnGlobalModuleFragmentDecl()
130 Module::Header H{HUName.str(), HUName.str(), *F}; in HandleStartOfHeaderUnit()
132 Module *Mod = Map.createHeaderUnit(StartOfTU, HUName, H); in HandleStartOfHeaderUnit()
133 assert(Mod && "module creation should not fail"); in HandleStartOfHeaderUnit()
136 ModuleScopes.back().Module = Mod; in HandleStartOfHeaderUnit()
141 // From now on, we have an owning module for all declarations we see. in HandleStartOfHeaderUnit()
148 /// Tests whether the given identifier is reserved as a module name and
159 if (II->isStr("module") || II->isStr("import")) in DiagReservedModuleName()
183 "should only have module decl in Modules TS or C++20"); in ActOnModuleDecl()
188 // module state; in ActOnModuleDecl()
204 // A (non-partition) module implementation unit requires that we are not in ActOnModuleDecl()
205 // compiling a module of any kind. A partition implementation emits an in ActOnModuleDecl()
208 // A module interface unit requires that we are not compiling a module map. in ActOnModuleDecl()
211 // It's OK to compile a module interface as a normal translation unit. in ActOnModuleDecl()
218 // We were asked to compile a module interface unit but this is a module in ActOnModuleDecl()
234 assert(ModuleScopes.size() <= 1 && "expected to be at global module scope"); in ActOnModuleDecl()
239 // Only one module-declaration is permitted per source file. in ActOnModuleDecl()
242 Diag(VisibleModules.getImportLoc(ModuleScopes.back().Module), in ActOnModuleDecl()
249 "mismatched global module state"); in ActOnModuleDecl()
251 // In C++20, the module-declaration must be the first declaration if there in ActOnModuleDecl()
252 // is no global module fragment. in ActOnModuleDecl()
261 << FixItHint::CreateInsertion(BeginLoc, "module;\n"); in ActOnModuleDecl()
265 // C++2b [module.unit]p1: ... The identifiers module and import shall not in ActOnModuleDecl()
266 // appear as identifiers in a module-name or module-partition. All in ActOnModuleDecl()
267 // module-names either beginning with an identifier consisting of std in ActOnModuleDecl()
270 // module-declaration; no diagnostic is required. in ActOnModuleDecl()
291 // Flatten the dots in a module name. Unlike Clang's hierarchical module map in ActOnModuleDecl()
293 // module name. in ActOnModuleDecl()
299 // If a module name was explicitly specified on the command line, it must be in ActOnModuleDecl()
313 Module *Mod; in ActOnModuleDecl()
318 // We can't have parsed or imported a definition of this module or parsed a in ActOnModuleDecl()
319 // module map defining it already. in ActOnModuleDecl()
331 // Create a Module for the module that we're defining. in ActOnModuleDecl()
334 Mod->Kind = Module::ModulePartitionInterface; in ActOnModuleDecl()
335 assert(Mod && "module creation should not fail"); in ActOnModuleDecl()
340 // C++20 A module-declaration that contains neither an export- in ActOnModuleDecl()
341 // keyword nor a module-partition implicitly imports the primary in ActOnModuleDecl()
342 // module interface unit of the module as if by a module-import- in ActOnModuleDecl()
347 // The module loader will assume we're trying to import the module that in ActOnModuleDecl()
350 // module loader work properly. in ActOnModuleDecl()
353 Module::AllVisible, in ActOnModuleDecl()
359 // Create an empty module interface unit for error recovery. in ActOnModuleDecl()
369 Mod->Kind = Module::ModulePartitionImplementation; in ActOnModuleDecl()
378 // We're done with the global module fragment now. in ActOnModuleDecl()
382 // Switch from the global module fragment (if any) to the named module. in ActOnModuleDecl()
384 ModuleScopes.back().Module = Mod; in ActOnModuleDecl()
389 // From now on, we have an owning module for all declarations we see. in ActOnModuleDecl()
392 // Otherwise, those declarations are module-private unless explicitly in ActOnModuleDecl()
398 // We are in the module purview, but before any other (non import) in ActOnModuleDecl()
420 // A private-module-fragment shall appear only in a primary module in ActOnPrivateModuleFragmentDecl()
422 switch (ModuleScopes.empty() ? Module::GlobalModuleFragment in ActOnPrivateModuleFragmentDecl()
423 : ModuleScopes.back().Module->Kind) { in ActOnPrivateModuleFragmentDecl()
424 case Module::ModuleMapModule: in ActOnPrivateModuleFragmentDecl()
425 case Module::GlobalModuleFragment: in ActOnPrivateModuleFragmentDecl()
426 case Module::ModulePartitionImplementation: in ActOnPrivateModuleFragmentDecl()
427 case Module::ModulePartitionInterface: in ActOnPrivateModuleFragmentDecl()
428 case Module::ModuleHeaderUnit: in ActOnPrivateModuleFragmentDecl()
432 case Module::PrivateModuleFragment: in ActOnPrivateModuleFragmentDecl()
437 case Module::ModuleInterfaceUnit: in ActOnPrivateModuleFragmentDecl()
449 // FIXME: Check this isn't a module interface partition. in ActOnPrivateModuleFragmentDecl()
451 // such imports would violate [basic.link]/2's "shall be the only module unit" in ActOnPrivateModuleFragmentDecl()
458 Module *PrivateModuleFragment = in ActOnPrivateModuleFragmentDecl()
460 ModuleScopes.back().Module, PrivateLoc); in ActOnPrivateModuleFragmentDecl()
461 assert(PrivateModuleFragment && "module creation should not fail"); in ActOnPrivateModuleFragmentDecl()
463 // Enter the scope of the private module fragment. in ActOnPrivateModuleFragmentDecl()
466 ModuleScopes.back().Module = PrivateModuleFragment; in ActOnPrivateModuleFragmentDecl()
470 // All declarations created from now on are scoped to the private module in ActOnPrivateModuleFragmentDecl()
471 // fragment (and are neither visible nor reachable in importers of the module in ActOnPrivateModuleFragmentDecl()
489 // For a C++20 module name, flatten into a single identifier with the source in ActOnModuleImport()
495 // We already checked that we are in a module purview in the parser. in ActOnModuleImport()
496 assert(!ModuleScopes.empty() && "in a module purview, but no module?"); in ActOnModuleImport()
497 Module *NamedMod = ModuleScopes.back().Module; in ActOnModuleImport()
498 // If we are importing into a partition, find the owning named module, in ActOnModuleImport()
499 // otherwise, the name of the importing named module. in ActOnModuleImport()
512 // [module.import]/9 in ActOnModuleImport()
513 // A module implementation unit of a module M that is not a module partition in ActOnModuleImport()
514 // shall not contain a module-import-declaration nominating M. in ActOnModuleImport()
515 // (for an implementation, the module interface is imported implicitly, in ActOnModuleImport()
516 // but that's handled in the module decl code). in ActOnModuleImport()
525 Module *Mod = getModuleLoader().loadModule( in ActOnModuleImport()
526 ImportLoc, Path, Module::AllVisible, /*IsInclusionDirective=*/false); in ActOnModuleImport()
543 SourceLocation ImportLoc, Module *Mod, in ActOnModuleImport()
550 // of the same top-level module. Until we do, make it an error rather than in ActOnModuleImport()
552 // FIXME: Should we warn on a redundant import of the current module? in ActOnModuleImport()
567 for (Module *ModCheck = Mod; ModCheck; ModCheck = ModCheck->Parent) in ActOnModuleImport()
573 Module *ModCheck = Mod; in ActOnModuleImport()
575 // If we've run out of module parents, just drop the remaining in ActOnModuleImport()
589 // Sequence initialization of the imported module before that of the current in ActOnModuleImport()
590 // module, if any. in ActOnModuleImport()
592 Context.addModuleInitializer(ModuleScopes.back().Module, Import); in ActOnModuleImport()
594 // A module (partition) implementation unit shall not be exported. in ActOnModuleImport()
596 Mod->Kind == Module::ModuleKind::ModulePartitionImplementation) { in ActOnModuleImport()
602 ModuleScopes.back().Module->isGlobalModule()))) { in ActOnModuleImport()
603 // Re-export the module if the imported module is exported. in ActOnModuleImport()
604 // Note that we don't need to add re-exported module to Imports field in ActOnModuleImport()
605 // since `Exports` implies the module is imported already. in ActOnModuleImport()
611 // [module.interface]p1: in ActOnModuleImport()
613 // purview of a module interface unit. in ActOnModuleImport()
620 // imported module (as opposed to a transitive import). This avoids in ActOnModuleImport()
627 void Sema::ActOnModuleInclude(SourceLocation DirectiveLoc, Module *Mod) { in ActOnModuleInclude()
632 void Sema::BuildModuleInclude(SourceLocation DirectiveLoc, Module *Mod) { in BuildModuleInclude()
633 // Determine whether we're in the #include buffer for a module. The #includes in BuildModuleInclude()
634 // in that buffer do not qualify as module imports; they're just an in BuildModuleInclude()
635 // implementation detail of us building the module. in BuildModuleInclude()
644 // If this module import was due to an inclusion directive, create an in BuildModuleInclude()
652 Context.addModuleInitializer(ModuleScopes.back().Module, ImportD); in BuildModuleInclude()
657 getModuleLoader().makeModuleVisible(Mod, Module::AllVisible, DirectiveLoc); in BuildModuleInclude()
661 Module *ThisModule = PP.getHeaderSearchInfo().lookupModule( in BuildModuleInclude()
664 assert(ThisModule && "was expecting a module if building one"); in BuildModuleInclude()
668 void Sema::ActOnModuleBegin(SourceLocation DirectiveLoc, Module *Mod) { in ActOnModuleBegin()
672 ModuleScopes.back().Module = Mod; in ActOnModuleBegin()
678 // The enclosing context is now part of this module. in ActOnModuleBegin()
680 // lexically within the module. in ActOnModuleBegin()
692 void Sema::ActOnModuleEnd(SourceLocation EomLoc, Module *Mod) { in ActOnModuleEnd()
695 // Leaving a module hides namespace names, so our visible namespace cache in ActOnModuleEnd()
700 assert(!ModuleScopes.empty() && ModuleScopes.back().Module == Mod && in ActOnModuleEnd()
701 "left the wrong module scope"); in ActOnModuleEnd()
704 // We got to the end of processing a local module. Create an in ActOnModuleEnd()
705 // ImportDecl as we would for an imported module. in ActOnModuleEnd()
709 // We reached the end of a #included module header. Use the #include loc. in ActOnModuleEnd()
719 // Any further declarations are in whatever module we returned to. in ActOnModuleEnd()
722 // the module within. in ActOnModuleEnd()
733 Module *Mod) { in createImplicitModuleImportForErrorRecovery()
734 // Bail if we're not allowed to implicitly import a module here. in createImplicitModuleImportForErrorRecovery()
746 // Make the module visible. in createImplicitModuleImportForErrorRecovery()
747 getModuleLoader().makeModuleVisible(Mod, Module::AllVisible, Loc); in createImplicitModuleImportForErrorRecovery()
763 // C++2a [module.interface]p1: in ActOnStartExportDecl()
764 // An export-declaration shall appear only [...] in the purview of a module in ActOnStartExportDecl()
766 // indirectly within [...] a private-module-fragment. in ActOnStartExportDecl()
778 } else if (ModuleScopes.back().Module->Kind == in ActOnStartExportDecl()
779 Module::PrivateModuleFragment) { in ActOnStartExportDecl()
886 // C++2a [module.interface]p3: in checkExportedDecl()
904 // C++2a [module.interface]p5: in checkExportedDecl()
963 // If an inline function or variable that is attached to a named module in ActOnFinishExportDecl()
978 Module *Sema::PushGlobalModuleFragment(SourceLocation BeginLoc, in PushGlobalModuleFragment()
980 // We shouldn't create new global module fragment if there is already in PushGlobalModuleFragment()
988 assert(GlobalModuleFragment && "module creation should not fail"); in PushGlobalModuleFragment()
990 // Enter the scope of the global module. in PushGlobalModuleFragment()
1003 "left the wrong module scope, which is not global module fragment"); in PopGlobalModuleFragment()
1007 bool Sema::isModuleUnitOfCurrentTU(const Module *M) const { in isModuleUnitOfCurrentTU()
1010 Module *CurrentModuleUnit = getCurrentModule(); in isModuleUnitOfCurrentTU()
1012 // If we are not in a module currently, M must not be the module unit of in isModuleUnitOfCurrentTU()