iains updated this revision to Diff 409666.
iains marked an inline comment as done.
iains added a comment.

remove stray blank line


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
@@ -382,17 +382,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().str();
+    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,16 @@
   /// Is this a module partition.
   bool isModulePartition() const { return Name.find(':') != std::string::npos; 
}
 
+  /// Get the primary module interface name from a partition.
+  StringRef getPrimaryModuleInterfaceName() const {
+    if (Kind == ModulePartitionInterface ||
+        Kind == ModulePartitionImplementation) {
+      auto pos = Name.find(':');
+      return StringRef(Name.data(), pos);
+    }
+    return StringRef(Name);
+  }
+
   /// 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


Index: clang/lib/Sema/SemaModule.cpp
===================================================================
--- clang/lib/Sema/SemaModule.cpp
+++ clang/lib/Sema/SemaModule.cpp
@@ -382,17 +382,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().str();
+    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,16 @@
   /// Is this a module partition.
   bool isModulePartition() const { return Name.find(':') != std::string::npos; }
 
+  /// Get the primary module interface name from a partition.
+  StringRef getPrimaryModuleInterfaceName() const {
+    if (Kind == ModulePartitionInterface ||
+        Kind == ModulePartitionImplementation) {
+      auto pos = Name.find(':');
+      return StringRef(Name.data(), pos);
+    }
+    return StringRef(Name);
+  }
+
   /// 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
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to