https://github.com/mikomikotaishi created 
https://github.com/llvm/llvm-project/pull/187657

This PR removes module partitions that don't belong to the current file's 
module from the list of suggested module imports in the code completion, so 
that it contains only primary modules or partitions directly relevant to the 
declared primary module.

>From ad59215c925dfb48cc65849ee844d478e9ab76f1 Mon Sep 17 00:00:00 2001
From: Bryan Chen <[email protected]>
Date: Fri, 20 Mar 2026 03:56:15 -0400
Subject: [PATCH] Remove unrelated module partitions from suggestion list

---
 clang/lib/Sema/SemaCodeComplete.cpp | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/clang/lib/Sema/SemaCodeComplete.cpp 
b/clang/lib/Sema/SemaCodeComplete.cpp
index 98d78d2a461f1..d2f5cea069ceb 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -4602,7 +4602,15 @@ void 
SemaCodeCompletion::CodeCompleteModuleImport(SourceLocation ImportLoc,
     // Enumerate all top-level modules.
     SmallVector<Module *, 8> Modules;
     SemaRef.PP.getHeaderSearchInfo().collectAllModules(Modules);
+    Module *CurrentModule = SemaRef.getCurrentModule();
     for (unsigned I = 0, N = Modules.size(); I != N; ++I) {
+      // Skip module partitions that don't belong to the current file's 
declared module
+      if (Modules[I]->isModulePartition()) {
+        if (!CurrentModule ||
+            Modules[I]->getPrimaryModuleInterfaceName() !=
+                CurrentModule->getPrimaryModuleInterfaceName())
+          continue;
+      }
       Builder.AddTypedTextChunk(
           Builder.getAllocator().CopyString(Modules[I]->Name));
       Results.AddResult(Result(

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to