Skip to content

Conversation

@qiongsiwu
Copy link
Contributor

This PR adds some test coverage for StableDirs during by-name lookups.

@llvmbot llvmbot added the clang Clang issues not falling into any other category label Nov 14, 2025
@llvmbot
Copy link
Member

llvmbot commented Nov 14, 2025

@llvm/pr-subscribers-clang

Author: Qiongsi Wu (qiongsiwu)

Changes

This PR adds some test coverage for StableDirs during by-name lookups.


Full diff: https://github.com/llvm/llvm-project/pull/168143.diff

1 Files Affected:

  • (modified) clang/test/ClangScanDeps/modules-full-by-mult-mod-names.c (+25-2)
diff --git a/clang/test/ClangScanDeps/modules-full-by-mult-mod-names.c b/clang/test/ClangScanDeps/modules-full-by-mult-mod-names.c
index 030f7f3427810..e4248e226b7d3 100644
--- a/clang/test/ClangScanDeps/modules-full-by-mult-mod-names.c
+++ b/clang/test/ClangScanDeps/modules-full-by-mult-mod-names.c
@@ -22,20 +22,43 @@ module root1 { header "root1.h"}
 // This is here to verify that the "root" directory doesn't clash with name of
 // the "root" module.
 
+// Verify the stable dir path.
+//--- Sysroot/usr/include/SysA/module.modulemap
+module SysA {
+  header "SysA.h"
+}
+
+//--- Sysroot/usr/include/SysA/SysA.h
+int SysVal = 42;
+
 //--- cdb.json.template
 [{
   "file": "",
   "directory": "DIR",
-  "command": "clang -fmodules -fmodules-cache-path=DIR/cache -I DIR -x c"
+  "command": "clang -fmodules -fmodules-cache-path=DIR/cache -I DIR -isysroot DIR/Sysroot -IDIR/Sysroot/usr/include -x c"
 }]
 
 // RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
-// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full -module-names=root,root1,direct > %t/result.json
+// RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full -module-names=SysA,root,root1,direct > %t/result.json
 // RUN: cat %t/result.json | sed 's:\\\\\?:/:g' | FileCheck -DPREFIX=%/t %s
 
 // CHECK:      {
 // CHECK-NEXT:   "modules": [
 // CHECK-NEXT:     {
+// CHECK-NEXT:       "is-in-stable-directories": true,
+// CHECK-NEXT:       "clang-module-deps": [],
+// CHECK-NEXT:       "clang-modulemap-file": "[[PREFIX]]/Sysroot/usr/include/SysA/module.modulemap",
+// CHECK-NEXT:       "command-line": [
+// CHECK:            ],
+// CHECK-NEXT:       "context-hash": "{{.*}}",
+// CHECK-NEXT:       "file-deps": [
+// CHECK-NEXT:         "[[PREFIX]]/Sysroot/usr/include/SysA/module.modulemap",
+// CHECK-NEXT:         "[[PREFIX]]/Sysroot/usr/include/SysA/SysA.h"
+// CHECK-NEXT:       ],
+// CHECK-NEXT:       "link-libraries": [],
+// CHECK-NEXT:       "name": "SysA"
+// CHECK-NEXT:     },
+// CHECK-NEXT:     {
 // CHECK-NEXT:       "clang-module-deps": [
 // CHECK-NEXT:         {
 // CHECK-NEXT:           "context-hash": "{{.*}}",

@qiongsiwu qiongsiwu merged commit 3f61402 into llvm:main Nov 18, 2025
10 checks passed
qiongsiwu added a commit to qiongsiwu/llvm-project that referenced this pull request Nov 19, 2025
…y-Name Lookups (llvm#168143)

This PR adds some test coverage for `StableDirs` during by-name lookups.

(cherry picked from commit 3f61402)
qiongsiwu added a commit to swiftlang/llvm-project that referenced this pull request Nov 20, 2025
…e Lookups (#11861)

This PR cherry-picks two tests added to upstream and next to check for stable directory and CAS setup for by-name dependency queries.

* [clang][DependencyScanning] Add Test Coverage of `StabeDirs` during By-Name Lookups (llvm#168143)

This PR adds some test coverage for `StableDirs` during by-name lookups.

(cherry picked from commit 3f61402)

* [clang][DependencyScanning] Fix `StableDir` and `DependencyActionController` Setup for By-Name Lookups (#11822)

llvm#164345 merge conflict resolution with `next` introduced two issues.

1. It did not correctly pick up the logic to set `StableDir` for `CompilerInstanceWithContext`.
2. It did not correctly setup the action controller for CAS.

This PR fixes both issues.

(cherry picked from commit 31fe4fc)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clang Clang issues not falling into any other category

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants