Skip to content

Commit 6be68b9

Browse files
[CAS][DepScan] Fix depscan by module name using CAS
Fix clang module depscan by module name. The file system in the SourceManager is already set during initialization with an in-memory overlay on top of the DependencyScanningCASFileSystem. Do not overwrite it back to the underlying filesystem that will fail the look up for the fake module. (cherry picked from commit 4b015ce)
1 parent c739dd8 commit 6be68b9

File tree

2 files changed

+90
-6
lines changed

2 files changed

+90
-6
lines changed

clang/lib/Tooling/DependencyScanning/DependencyScanningWorker.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -401,12 +401,6 @@ class DependencyScanningAction : public tooling::ToolAction {
401401
}
402402
// CAS Implementation.
403403
if (DepCASFS) {
404-
// Support for virtual file system overlays on top of the caching
405-
// filesystem.
406-
FileMgr->setVirtualFileSystem(createVFSFromCompilerInvocation(
407-
ScanInstance.getInvocation(), ScanInstance.getDiagnostics(),
408-
DepCASFS));
409-
410404
llvm::IntrusiveRefCntPtr<DependencyScanningCASFilesystem> LocalDepCASFS =
411405
DepCASFS;
412406
ScanInstance.getPreprocessorOpts().DependencyDirectivesForFile =
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
// UNSUPPORTED: target=powerpc64-ibm-aix{{.*}}
2+
// REQUIRES: ondisk_cas
3+
4+
// RUN: rm -rf %t
5+
// RUN: split-file %s %t
6+
7+
//--- module.modulemap
8+
module root { header "root.h" }
9+
module direct { header "direct.h" }
10+
module transitive { header "transitive.h" }
11+
//--- root.h
12+
#include "direct.h"
13+
#include "root/textual.h"
14+
//--- direct.h
15+
#include "transitive.h"
16+
//--- transitive.h
17+
// empty
18+
19+
//--- root/textual.h
20+
// This is here to verify that the "root" directory doesn't clash with name of
21+
// the "root" module.
22+
23+
//--- cdb.json.template
24+
[{
25+
"file": "",
26+
"directory": "DIR",
27+
"command": "clang -fmodules -fmodules-cache-path=DIR/cache -I DIR -x c"
28+
}]
29+
30+
// RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
31+
// RUN: clang-scan-deps -compilation-database %t/cdb.json \
32+
// RUN: -cas-path %t/cas -action-cache-path %t/cache \
33+
// RUN: -format experimental-full -module-name=root > %t/result.json
34+
// RUN: cat %t/result.json | sed 's:\\\\\?:/:g' | FileCheck -DPREFIX=%/t %s
35+
36+
// CHECK: {
37+
// CHECK-NEXT: "modules": [
38+
// CHECK-NEXT: {
39+
// CHECK-NEXT: "casfs-root-id": "[[LEFT_ROOT_ID:llvmcas://[[:xdigit:]]+]]"
40+
// CHECK-NEXT: "clang-module-deps": [
41+
// CHECK-NEXT: {
42+
// CHECK-NEXT: "context-hash": "{{.*}}",
43+
// CHECK-NEXT: "module-name": "transitive"
44+
// CHECK-NEXT: }
45+
// CHECK-NEXT: ],
46+
// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
47+
// CHECK-NEXT: "command-line": [
48+
// CHECK: ],
49+
// CHECK-NEXT: "context-hash": "{{.*}}",
50+
// CHECK-NEXT: "file-deps": [
51+
// CHECK-NEXT: "[[PREFIX]]/direct.h"
52+
// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
53+
// CHECK-NEXT: ],
54+
// CHECK-NEXT: "name": "direct"
55+
// CHECK-NEXT: },
56+
// CHECK-NEXT: {
57+
// CHECK-NEXT: "casfs-root-id": "[[LEFT_ROOT_ID:llvmcas://[[:xdigit:]]+]]"
58+
// CHECK-NEXT: "clang-module-deps": [
59+
// CHECK-NEXT: {
60+
// CHECK-NEXT: "context-hash": "{{.*}}",
61+
// CHECK-NEXT: "module-name": "direct"
62+
// CHECK-NEXT: }
63+
// CHECK-NEXT: ],
64+
// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
65+
// CHECK-NEXT: "command-line": [
66+
// CHECK: ],
67+
// CHECK-NEXT: "context-hash": "{{.*}}",
68+
// CHECK-NEXT: "file-deps": [
69+
// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
70+
// CHECK-NEXT: "[[PREFIX]]/root.h"
71+
// CHECK-NEXT: "[[PREFIX]]/root/textual.h"
72+
// CHECK-NEXT: ],
73+
// CHECK-NEXT: "name": "root"
74+
// CHECK-NEXT: },
75+
// CHECK-NEXT: {
76+
// CHECK-NEXT: "casfs-root-id": "[[LEFT_ROOT_ID:llvmcas://[[:xdigit:]]+]]"
77+
// CHECK-NEXT: "clang-module-deps": [],
78+
// CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
79+
// CHECK-NEXT: "command-line": [
80+
// CHECK: ],
81+
// CHECK-NEXT: "context-hash": "{{.*}}",
82+
// CHECK-NEXT: "file-deps": [
83+
// CHECK-NEXT: "[[PREFIX]]/module.modulemap"
84+
// CHECK-NEXT: "[[PREFIX]]/transitive.h"
85+
// CHECK-NEXT: ],
86+
// CHECK-NEXT: "name": "transitive"
87+
// CHECK-NEXT: }
88+
// CHECK-NEXT: ],
89+
// CHECK-NEXT: "translation-units": []
90+
// CHECK-NEXT: }

0 commit comments

Comments
 (0)