aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaModule.cpp
diff options
context:
space:
mode:
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>2023-11-09 15:15:50 +0800
committerChuanqi Xu <yedeng.yd@linux.alibaba.com>2023-11-09 15:20:32 +0800
commit427f13bd724d332681ca5adb2455b7241af7177d (patch)
treed427453eef941b22cd7f04fbfbea17774d310f83 /clang/lib/Sema/SemaModule.cpp
parente179b125fb019dae54aecbb5687f77c6dd67a17d (diff)
downloadllvm-427f13bd724d332681ca5adb2455b7241af7177d.zip
llvm-427f13bd724d332681ca5adb2455b7241af7177d.tar.gz
llvm-427f13bd724d332681ca5adb2455b7241af7177d.tar.bz2
[NFC] [C++20] [Modules] Remove 'ModuleInterface' bit in Sema::ModuleScope
The 'ModuleInterface' in Sema::ModuleScope is confusing. It actually means 'not implementation'. This patch removes that bit and extract the information from the recorded clang::Module.
Diffstat (limited to 'clang/lib/Sema/SemaModule.cpp')
-rw-r--r--clang/lib/Sema/SemaModule.cpp14
1 files changed, 3 insertions, 11 deletions
diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index 8a29683..99b4d7d 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -125,7 +125,6 @@ void Sema::HandleStartOfHeaderUnit() {
ModuleScopes.push_back({}); // No GMF
ModuleScopes.back().BeginLoc = StartOfTU;
ModuleScopes.back().Module = Mod;
- ModuleScopes.back().ModuleInterface = true;
VisibleModules.setVisible(Mod, StartOfTU);
// From now on, we have an owning module for all declarations we see.
@@ -375,7 +374,6 @@ Sema::ActOnModuleDecl(SourceLocation StartLoc, SourceLocation ModuleLoc,
// Switch from the global module fragment (if any) to the named module.
ModuleScopes.back().BeginLoc = StartLoc;
ModuleScopes.back().Module = Mod;
- ModuleScopes.back().ModuleInterface = MDK != ModuleDeclKind::Implementation;
VisibleModules.setVisible(Mod, ModuleLoc);
// From now on, we have an owning module for all declarations we see.
@@ -470,7 +468,6 @@ Sema::ActOnPrivateModuleFragmentDecl(SourceLocation ModuleLoc,
ModuleScopes.push_back({});
ModuleScopes.back().BeginLoc = ModuleLoc;
ModuleScopes.back().Module = PrivateModuleFragment;
- ModuleScopes.back().ModuleInterface = true;
VisibleModules.setVisible(PrivateModuleFragment, ModuleLoc);
// All declarations created from now on are scoped to the private module
@@ -523,7 +520,7 @@ DeclResult Sema::ActOnModuleImport(SourceLocation StartLoc,
if (getLangOpts().CPlusPlusModules && isCurrentModulePurview() &&
getCurrentModule()->Name == ModuleName) {
Diag(ImportLoc, diag::err_module_self_import_cxx20)
- << ModuleName << !ModuleScopes.back().ModuleInterface;
+ << ModuleName << currentModuleIsImplementation();
return true;
}
@@ -609,10 +606,7 @@ DeclResult Sema::ActOnModuleImport(SourceLocation StartLoc,
Mod->Kind == Module::ModuleKind::ModulePartitionImplementation) {
Diag(ExportLoc, diag::err_export_partition_impl)
<< SourceRange(ExportLoc, Path.back().second);
- } else if (!ModuleScopes.empty() &&
- (ModuleScopes.back().ModuleInterface ||
- (getLangOpts().CPlusPlusModules &&
- ModuleScopes.back().Module->isGlobalModule()))) {
+ } else if (!ModuleScopes.empty() && !currentModuleIsImplementation()) {
// Re-export the module if the imported module is exported.
// Note that we don't need to add re-exported module to Imports field
// since `Exports` implies the module is imported already.
@@ -772,7 +766,7 @@ Decl *Sema::ActOnStartExportDecl(Scope *S, SourceLocation ExportLoc,
Diag(ExportLoc, diag::err_export_not_in_module_interface) << 0;
D->setInvalidDecl();
return D;
- } else if (!ModuleScopes.back().ModuleInterface) {
+ } else if (currentModuleIsImplementation()) {
Diag(ExportLoc, diag::err_export_not_in_module_interface) << 1;
Diag(ModuleScopes.back().BeginLoc,
diag::note_not_module_interface_add_export)
@@ -932,7 +926,6 @@ Module *Sema::PushGlobalModuleFragment(SourceLocation BeginLoc) {
// Enter the scope of the global module.
ModuleScopes.push_back({BeginLoc, TheGlobalModuleFragment,
- /*ModuleInterface=*/false,
/*OuterVisibleModules=*/{}});
VisibleModules.setVisible(TheGlobalModuleFragment, BeginLoc);
@@ -959,7 +952,6 @@ Module *Sema::PushImplicitGlobalModuleFragment(SourceLocation BeginLoc,
// Enter the scope of the global module.
ModuleScopes.push_back({BeginLoc, *M,
- /*ModuleInterface=*/false,
/*OuterVisibleModules=*/{}});
VisibleModules.setVisible(*M, BeginLoc);
return *M;