aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema
diff options
context:
space:
mode:
authorMitch Phillips <31459023+hctim@users.noreply.github.com>2023-03-27 04:33:53 -0700
committerMitch Phillips <31459023+hctim@users.noreply.github.com>2023-03-27 05:01:53 -0700
commit074f6fd61d382ff6bf108472ea701d214b02f64b (patch)
treedb2237cc4871c1634b3cf910f25751da51a06a06 /clang/lib/Sema
parent5ca710ab148b0815c2b7b03fe2af643e637bbc7d (diff)
downloadllvm-074f6fd61d382ff6bf108472ea701d214b02f64b.zip
llvm-074f6fd61d382ff6bf108472ea701d214b02f64b.tar.gz
llvm-074f6fd61d382ff6bf108472ea701d214b02f64b.tar.bz2
Revert "[C++20][Modules] Introduce an implementation module."
This reverts commit c6e9823724ef6bdfee262289ee34d162db436af0. Reason: Broke the ASan buildbots, see https://reviews.llvm.org/D126959 (the original phabricator review) for more info.
Diffstat (limited to 'clang/lib/Sema')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp20
-rw-r--r--clang/lib/Sema/SemaModule.cpp59
2 files changed, 31 insertions, 48 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index dd001db..6403439 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -1661,19 +1661,13 @@ bool Sema::CheckRedeclarationModuleOwnership(NamedDecl *New, NamedDecl *Old) {
if (NewM == OldM)
return false;
- if (NewM && OldM) {
- // A module implementation unit has visibility of the decls in its
- // implicitly imported interface.
- if (NewM->isModuleImplementation() && OldM == ThePrimaryInterface)
- return false;
-
- // Partitions are part of the module, but a partition could import another
- // module, so verify that the PMIs agree.
- if ((NewM->isModulePartition() || OldM->isModulePartition()) &&
- NewM->getPrimaryModuleInterfaceName() ==
- OldM->getPrimaryModuleInterfaceName())
- return false;
- }
+ // Partitions are part of the module, but a partition could import another
+ // module, so verify that the PMIs agree.
+ if (NewM && OldM &&
+ (NewM->isModulePartition() || OldM->isModulePartition()) &&
+ NewM->getPrimaryModuleInterfaceName() ==
+ OldM->getPrimaryModuleInterfaceName())
+ return false;
bool NewIsModuleInterface = NewM && NewM->isModulePurview();
bool OldIsModuleInterface = OldM && OldM->isModulePurview();
diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index c02b9d2..8c120d2 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -298,8 +298,8 @@ Sema::ActOnModuleDecl(SourceLocation StartLoc, SourceLocation ModuleLoc,
const_cast<LangOptions&>(getLangOpts()).CurrentModule = ModuleName;
auto &Map = PP.getHeaderSearchInfo().getModuleMap();
- Module *Mod; // The module we are creating.
- Module *Interface = nullptr; // The interface for an implementation.
+ Module *Mod;
+
switch (MDK) {
case ModuleDeclKind::Interface:
case ModuleDeclKind::PartitionInterface: {
@@ -336,19 +336,18 @@ Sema::ActOnModuleDecl(SourceLocation StartLoc, SourceLocation ModuleLoc,
// we're building if `LangOpts.CurrentModule` equals to 'ModuleName'.
// Change the value for `LangOpts.CurrentModule` temporarily to make the
// module loader work properly.
- const_cast<LangOptions &>(getLangOpts()).CurrentModule = "";
- Interface = getModuleLoader().loadModule(ModuleLoc, {ModuleNameLoc},
- Module::AllVisible,
- /*IsInclusionDirective=*/false);
+ const_cast<LangOptions&>(getLangOpts()).CurrentModule = "";
+ Mod = getModuleLoader().loadModule(ModuleLoc, {ModuleNameLoc},
+ Module::AllVisible,
+ /*IsInclusionDirective=*/false);
const_cast<LangOptions&>(getLangOpts()).CurrentModule = ModuleName;
- if (!Interface) {
+ if (!Mod) {
Diag(ModuleLoc, diag::err_module_not_defined) << ModuleName;
// Create an empty module interface unit for error recovery.
Mod = Map.createModuleForInterfaceUnit(ModuleLoc, ModuleName);
- } else {
- Mod = Map.createModuleForImplementationUnit(ModuleLoc, ModuleName);
}
+
} break;
case ModuleDeclKind::PartitionImplementation:
@@ -387,31 +386,19 @@ Sema::ActOnModuleDecl(SourceLocation StartLoc, SourceLocation ModuleLoc,
// statements, so imports are allowed.
ImportState = ModuleImportState::ImportAllowed;
- getASTContext().setNamedModuleForCodeGen(Mod);
-
- // We already potentially made an implicit import (in the case of a module
- // implementation unit importing its interface). Make this module visible
- // and return the import decl to be added to the current TU.
- if (Interface) {
-
- VisibleModules.setVisible(Interface, ModuleLoc);
-
- // Make the import decl for the interface in the impl module.
- ImportDecl *Import = ImportDecl::Create(Context, CurContext, ModuleLoc,
- Interface, Path[0].second);
- CurContext->addDecl(Import);
-
- // Sequence initialization of the imported module before that of the current
- // module, if any.
- Context.addModuleInitializer(ModuleScopes.back().Module, Import);
- Mod->Imports.insert(Interface); // As if we imported it.
- // Also save this as a shortcut to checking for decls in the interface
- ThePrimaryInterface = Interface;
- // If we made an implicit import of the module interface, then return the
- // imported module decl.
+ // For an implementation, We already made an implicit import (its interface).
+ // Make and return the import decl to be added to the current TU.
+ if (MDK == ModuleDeclKind::Implementation) {
+ // Make the import decl for the interface.
+ ImportDecl *Import =
+ ImportDecl::Create(Context, CurContext, ModuleLoc, Mod, Path[0].second);
+ // and return it to be added.
return ConvertDeclToDeclGroup(Import);
}
+ getASTContext().setNamedModuleForCodeGen(Mod);
+
+ // FIXME: Create a ModuleDecl.
return nullptr;
}
@@ -437,17 +424,19 @@ Sema::ActOnPrivateModuleFragmentDecl(SourceLocation ModuleLoc,
Diag(ModuleScopes.back().BeginLoc, diag::note_previous_definition);
return nullptr;
- case Module::ModuleImplementationUnit:
+ case Module::ModuleInterfaceUnit:
+ break;
+ }
+
+ if (!ModuleScopes.back().ModuleInterface) {
Diag(PrivateLoc, diag::err_private_module_fragment_not_module_interface);
Diag(ModuleScopes.back().BeginLoc,
diag::note_not_module_interface_add_export)
<< FixItHint::CreateInsertion(ModuleScopes.back().BeginLoc, "export ");
return nullptr;
-
- case Module::ModuleInterfaceUnit:
- break;
}
+ // FIXME: Check this isn't a module interface partition.
// FIXME: Check that this translation unit does not import any partitions;
// such imports would violate [basic.link]/2's "shall be the only module unit"
// restriction.