File tree Expand file tree Collapse file tree 2 files changed +35
-3
lines changed
lib/Tooling/DependencyScanning Expand file tree Collapse file tree 2 files changed +35
-3
lines changed Original file line number Diff line number Diff line change @@ -342,6 +342,9 @@ class DependencyScanningAction : public tooling::ToolAction {
342
342
ScanInstance.getHeaderSearchOpts ().ModulesIncludeVFSUsage =
343
343
any (OptimizeArgs & ScanningOptimizations::VFS);
344
344
345
+ // FileMgr was created before option parsing; set its FileSystemOptions now.
346
+ FileMgr->getFileSystemOpts () = ScanInstance.getFileSystemOpts ();
347
+
345
348
ScanInstance.setFileManager (FileMgr);
346
349
// Support for virtual file system overlays.
347
350
FileMgr->setVirtualFileSystem (createVFSFromCompilerInvocation (
@@ -624,9 +627,8 @@ bool DependencyScanningWorker::computeDependencies(
624
627
ModifiedCommandLine ? *ModifiedCommandLine : CommandLine;
625
628
auto &FinalFS = ModifiedFS ? ModifiedFS : BaseFS;
626
629
627
- FileSystemOptions FSOpts;
628
- FSOpts.WorkingDir = WorkingDirectory.str ();
629
- auto FileMgr = llvm::makeIntrusiveRefCnt<FileManager>(FSOpts, FinalFS);
630
+ auto FileMgr =
631
+ llvm::makeIntrusiveRefCnt<FileManager>(FileSystemOptions{}, FinalFS);
630
632
631
633
std::vector<const char *> FinalCCommandLine (FinalCommandLine.size (), nullptr );
632
634
llvm::transform (FinalCommandLine, FinalCCommandLine.begin (),
Original file line number Diff line number Diff line change
1
+ // Test that -working-directory works even when it differs from the working
2
+ // directory of the filesystem.
3
+
4
+ // RUN: rm -rf %t
5
+ // RUN: mkdir -p %t/other
6
+ // RUN: split-file %s %t
7
+ // RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
8
+
9
+ // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \
10
+ // RUN: > %t/deps.json
11
+
12
+ // RUN: cat %t/deps.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t
13
+
14
+ // CHECK: "file-deps": [
15
+ // CHECK-NEXT: "[[PREFIX]]/cwd/t.c"
16
+ // CHECK-NEXT: "[[PREFIX]]/cwd/relative/h1.h"
17
+ // CHECK-NEXT: ]
18
+ // CHECK-NEXT: "input-file": "[[PREFIX]]/cwd/t.c"
19
+
20
+ //--- cdb.json.template
21
+ [{
22
+ "directory" : "DIR /other ",
23
+ " command ": " clang - c t .c - I relative - working - directory DIR /cwd ",
24
+ " file ": " DIR /cwd /t .c "
25
+ }]
26
+
27
+ //--- cwd/relative/h1.h
28
+
29
+ //--- cwd/t.c
30
+ #include "h1.h"
You can’t perform that action at this time.
0 commit comments