aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaModule.cpp
diff options
context:
space:
mode:
authorChuanqi Xu <yedeng.yd@linux.alibaba.com>2022-03-02 23:06:07 +0800
committerChuanqi Xu <yedeng.yd@linux.alibaba.com>2022-03-02 23:06:36 +0800
commit3eb2da76d77044802135350668da16d433a7c7b6 (patch)
treec287a4c19ee87d023ea18ce56d05054be0044592 /clang/lib/Sema/SemaModule.cpp
parent63c9aca12afad6745173861f5315ee96fbec72ed (diff)
downloadllvm-3eb2da76d77044802135350668da16d433a7c7b6.zip
llvm-3eb2da76d77044802135350668da16d433a7c7b6.tar.gz
llvm-3eb2da76d77044802135350668da16d433a7c7b6.tar.bz2
[NFC] [C++20] [Modules] Simplify ActOnModuleImport by merging Path and Parition
Reviewed By: iains Differential Revision: https://reviews.llvm.org/D120793
Diffstat (limited to 'clang/lib/Sema/SemaModule.cpp')
-rw-r--r--clang/lib/Sema/SemaModule.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index 6bb886b..d12de22 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -365,13 +365,10 @@ Sema::ActOnPrivateModuleFragmentDecl(SourceLocation ModuleLoc,
DeclResult Sema::ActOnModuleImport(SourceLocation StartLoc,
SourceLocation ExportLoc,
SourceLocation ImportLoc, ModuleIdPath Path,
- ModuleIdPath Partition) {
+ bool IsPartition) {
- bool IsPartition = !Partition.empty();
bool Cxx20Mode = getLangOpts().CPlusPlusModules || getLangOpts().ModulesTS;
assert((!IsPartition || Cxx20Mode) && "partition seen in non-C++20 code?");
- assert((!IsPartition || Path.empty()) &&
- "trying to import a partition with its named module specified?");
// For a C++20 module name, flatten into a single identifier with the source
// location of the first component.
@@ -386,9 +383,9 @@ DeclResult Sema::ActOnModuleImport(SourceLocation StartLoc,
// otherwise, the name of the importing named module.
ModuleName = NamedMod->getPrimaryModuleInterfaceName().str();
ModuleName += ":";
- ModuleName += stringFromPath(Partition);
- ModuleNameLoc = {PP.getIdentifierInfo(ModuleName), Partition[0].second};
- Partition = ModuleIdPath(ModuleNameLoc);
+ ModuleName += stringFromPath(Path);
+ ModuleNameLoc = {PP.getIdentifierInfo(ModuleName), Path[0].second};
+ Path = ModuleIdPath(ModuleNameLoc);
} else if (Cxx20Mode) {
ModuleName = stringFromPath(Path);
ModuleNameLoc = {PP.getIdentifierInfo(ModuleName), Path[0].second};
@@ -410,13 +407,11 @@ DeclResult Sema::ActOnModuleImport(SourceLocation StartLoc,
}
Module *Mod = getModuleLoader().loadModule(
- ImportLoc, IsPartition ? Partition : Path, Module::AllVisible,
- /*IsInclusionDirective=*/false);
+ ImportLoc, Path, Module::AllVisible, /*IsInclusionDirective=*/false);
if (!Mod)
return true;
- return ActOnModuleImport(StartLoc, ExportLoc, ImportLoc, Mod,
- IsPartition ? Partition : Path);
+ return ActOnModuleImport(StartLoc, ExportLoc, ImportLoc, Mod, Path);
}
/// Determine whether \p D is lexically within an export-declaration.