diff options
author | Iain Sandoe <iain@sandoe.co.uk> | 2021-05-01 13:07:45 +0100 |
---|---|---|
committer | Iain Sandoe <iain@sandoe.co.uk> | 2022-02-28 08:50:25 +0000 |
commit | b3fcfcb9464b90dd56a591e6269d33b124b96fee (patch) | |
tree | c17104b7097e5e6075380ea4dad234d6ec866bb6 /clang/lib/Sema/SemaModule.cpp | |
parent | 8d01ac75e7f33be0c17ea24cb43e96b777eb642e (diff) | |
download | llvm-b3fcfcb9464b90dd56a591e6269d33b124b96fee.zip llvm-b3fcfcb9464b90dd56a591e6269d33b124b96fee.tar.gz llvm-b3fcfcb9464b90dd56a591e6269d33b124b96fee.tar.bz2 |
[C++20][Modules][7/8] Find the primary interface name for a module.
When we are building modules, there are cases where the only way to determine
validity of access is by comparing primary interface names. This is because we need
to be able to associate a primary interface name with an imported partition, but
before the primary interface module is complete - so that textual comparison is
necessary.
If this turns out to be needed many times, we could cache the result, but it seems
unlikely to be significant (at this time); cases with very many imported partitions
would seem unusual.
Differential Revision: https://reviews.llvm.org/D118598
Diffstat (limited to 'clang/lib/Sema/SemaModule.cpp')
-rw-r--r-- | clang/lib/Sema/SemaModule.cpp | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp index a829693..6bb886b 100644 --- a/clang/lib/Sema/SemaModule.cpp +++ b/clang/lib/Sema/SemaModule.cpp @@ -382,17 +382,10 @@ DeclResult Sema::ActOnModuleImport(SourceLocation StartLoc, // We already checked that we are in a module purview in the parser. assert(!ModuleScopes.empty() && "in a module purview, but no module?"); Module *NamedMod = ModuleScopes.back().Module; - if (ModuleScopes.back().IsPartition) { - // We're importing a partition into a partition, find the name of the - // owning named module. - size_t P = NamedMod->Name.find_first_of(":"); - ModuleName = NamedMod->Name.substr(0, P + 1); - } else { - // We're importing a partition into the named module itself (either the - // interface or an implementation TU). - ModuleName = NamedMod->Name; - ModuleName += ":"; - } + // If we are importing into a partition, find the owning named module, + // 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); |