[clang] 9044226 - [NFC] [C++20] [Modules] Remove unused Global Module Fragment variables/arguments
Chuanqi Xu via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 14 19:51:28 PST 2022
Author: Chuanqi Xu
Date: 2022-11-15T11:51:13+08:00
New Revision: 9044226ba2dab1c8c4e7fb352c4c5b4d399052b4
URL: https://github.com/llvm/llvm-project/commit/9044226ba2dab1c8c4e7fb352c4c5b4d399052b4
DIFF: https://github.com/llvm/llvm-project/commit/9044226ba2dab1c8c4e7fb352c4c5b4d399052b4.diff
LOG: [NFC] [C++20] [Modules] Remove unused Global Module Fragment variables/arguments
Added:
Modified:
clang/include/clang/Lex/ModuleMap.h
clang/lib/Lex/ModuleMap.cpp
clang/lib/Sema/SemaModule.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/Lex/ModuleMap.h b/clang/include/clang/Lex/ModuleMap.h
index ca04ce623616e..35c5c2297a042 100644
--- a/clang/include/clang/Lex/ModuleMap.h
+++ b/clang/include/clang/Lex/ModuleMap.h
@@ -564,8 +564,7 @@ class ModuleMap {
/// Note that this also sets the current module to the newly-created module.
///
/// \returns The newly-created module.
- Module *createModuleForInterfaceUnit(SourceLocation Loc, StringRef Name,
- Module *GlobalModule);
+ Module *createModuleForInterfaceUnit(SourceLocation Loc, StringRef Name);
/// Create a header module from the specified list of headers.
Module *createHeaderModule(StringRef Name, ArrayRef<Module::Header> Headers);
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index 2d8970516a5d2..210fab72fc81e 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -873,8 +873,7 @@ ModuleMap::createPrivateModuleFragmentForInterfaceUnit(Module *Parent,
}
Module *ModuleMap::createModuleForInterfaceUnit(SourceLocation Loc,
- StringRef Name,
- Module *GlobalModule) {
+ StringRef Name) {
assert(LangOpts.CurrentModule == Name && "module name mismatch");
assert(!Modules[Name] && "redefining existing module");
diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index 1db716e77e7d5..3d4fef1d141d1 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -244,14 +244,8 @@ Sema::ActOnModuleDecl(SourceLocation StartLoc, SourceLocation ModuleLoc,
return nullptr;
}
- // Find the global module fragment we're adopting into this module, if any.
- Module *GlobalModuleFragment = nullptr;
- if (!ModuleScopes.empty() &&
- ModuleScopes.back().Module->Kind == Module::GlobalModuleFragment)
- GlobalModuleFragment = ModuleScopes.back().Module;
-
assert((!getLangOpts().CPlusPlusModules || getLangOpts().ModulesTS ||
- SeenGMF == (bool)GlobalModuleFragment) &&
+ SeenGMF == (bool)this->GlobalModuleFragment) &&
"mismatched global module state");
// In C++20, the module-declaration must be the first declaration if there
@@ -335,8 +329,7 @@ Sema::ActOnModuleDecl(SourceLocation StartLoc, SourceLocation ModuleLoc,
}
// Create a Module for the module that we're defining.
- Mod = Map.createModuleForInterfaceUnit(ModuleLoc, ModuleName,
- GlobalModuleFragment);
+ Mod = Map.createModuleForInterfaceUnit(ModuleLoc, ModuleName);
if (MDK == ModuleDeclKind::PartitionInterface)
Mod->Kind = Module::ModulePartitionInterface;
assert(Mod && "module creation should not fail");
@@ -356,21 +349,19 @@ Sema::ActOnModuleDecl(SourceLocation StartLoc, SourceLocation ModuleLoc,
if (!Mod) {
Diag(ModuleLoc, diag::err_module_not_defined) << ModuleName;
// Create an empty module interface unit for error recovery.
- Mod = Map.createModuleForInterfaceUnit(ModuleLoc, ModuleName,
- GlobalModuleFragment);
+ Mod = Map.createModuleForInterfaceUnit(ModuleLoc, ModuleName);
}
} break;
case ModuleDeclKind::PartitionImplementation:
// Create an interface, but note that it is an implementation
// unit.
- Mod = Map.createModuleForInterfaceUnit(ModuleLoc, ModuleName,
- GlobalModuleFragment);
+ Mod = Map.createModuleForInterfaceUnit(ModuleLoc, ModuleName);
Mod->Kind = Module::ModulePartitionImplementation;
break;
}
- if (!GlobalModuleFragment) {
+ if (!this->GlobalModuleFragment) {
ModuleScopes.push_back({});
if (getLangOpts().ModulesLocalVisibility)
ModuleScopes.back().OuterVisibleModules = std::move(VisibleModules);
More information about the cfe-commits
mailing list