[PATCH] D118598: [C++20][Modules] Find the primary interface name for a module.
Iain Sandoe via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 16 04:35:07 PST 2022
iains updated this revision to Diff 409209.
iains added a comment.
rebased onto changes in parent patches.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118598/new/
https://reviews.llvm.org/D118598
Files:
clang/include/clang/Basic/Module.h
clang/lib/Sema/SemaModule.cpp
Index: clang/lib/Sema/SemaModule.cpp
===================================================================
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -375,17 +375,10 @@
// 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();
+ ModuleName += ":";
ModuleName += stringFromPath(Partition);
ModuleNameLoc = {PP.getIdentifierInfo(ModuleName), Partition[0].second};
Partition = ModuleIdPath(ModuleNameLoc);
Index: clang/include/clang/Basic/Module.h
===================================================================
--- clang/include/clang/Basic/Module.h
+++ clang/include/clang/Basic/Module.h
@@ -517,6 +517,15 @@
/// Is this a module partition.
bool isModulePartition() const { return Name.find(':') != std::string::npos; }
+ /// Get the primary module interface name from a partition.
+
+ std::string getPrimaryModuleInterfaceName() const {
+ std::string::size_type pos = Name.find(':');
+ if (pos == std::string::npos)
+ return Name;
+ return Name.substr(0, pos);
+ }
+
/// Retrieve the full name of this module, including the path from
/// its top-level module.
/// \param AllowStringLiterals If \c true, components that might not be
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118598.409209.patch
Type: text/x-patch
Size: 2021 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220216/007c4436/attachment.bin>
More information about the cfe-commits
mailing list