[llvm-branch-commits] [clang] 640ad76 - [clang-scan-deps] Support clang-cl

Sylvain Audi via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Mon Dec 14 09:11:52 PST 2020


Author: Sylvain Audi
Date: 2020-12-14T12:06:05-05:00
New Revision: 640ad769110f76d3391667249478ece88c835529

URL: https://github.com/llvm/llvm-project/commit/640ad769110f76d3391667249478ece88c835529
DIFF: https://github.com/llvm/llvm-project/commit/640ad769110f76d3391667249478ece88c835529.diff

LOG: [clang-scan-deps] Support clang-cl

clang-scan-deps contains some command line parsing and modifications.
This patch adds support for clang-cl command options.

Differential Revision: https://reviews.llvm.org/D92191

Added: 
    clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl.json
    clang/test/ClangScanDeps/Inputs/regular_cdb_clangcl.json

Modified: 
    clang/test/ClangScanDeps/Inputs/has_include_if_elif.json
    clang/test/ClangScanDeps/Inputs/header_stat_before_open_cdb.json
    clang/test/ClangScanDeps/Inputs/headerwithdirname.json
    clang/test/ClangScanDeps/Inputs/headerwithdirnamefollowedbyinclude.json
    clang/test/ClangScanDeps/Inputs/no-werror.json
    clang/test/ClangScanDeps/Inputs/static-analyzer-cdb.json
    clang/test/ClangScanDeps/Inputs/strip_diag_serialize.json
    clang/test/ClangScanDeps/Inputs/target-filename-cdb.json
    clang/test/ClangScanDeps/Inputs/vfsoverlay_cdb.json
    clang/test/ClangScanDeps/error.cpp
    clang/test/ClangScanDeps/has_include_if_elif.cpp
    clang/test/ClangScanDeps/header_stat_before_open.m
    clang/test/ClangScanDeps/headerwithdirname.cpp
    clang/test/ClangScanDeps/headerwithdirnamefollowedbyinclude.cpp
    clang/test/ClangScanDeps/modules-full.cpp
    clang/test/ClangScanDeps/modules.cpp
    clang/test/ClangScanDeps/no-werror.cpp
    clang/test/ClangScanDeps/regular_cdb.cpp
    clang/test/ClangScanDeps/static-analyzer.c
    clang/test/ClangScanDeps/strip_diag_serialize.cpp
    clang/test/ClangScanDeps/target-filename.cpp
    clang/test/ClangScanDeps/vfsoverlay.cpp
    clang/tools/clang-scan-deps/ClangScanDeps.cpp

Removed: 
    


################################################################################
diff  --git a/clang/test/ClangScanDeps/Inputs/has_include_if_elif.json b/clang/test/ClangScanDeps/Inputs/has_include_if_elif.json
index 36ca006b0329..6959ce8986c9 100644
--- a/clang/test/ClangScanDeps/Inputs/has_include_if_elif.json
+++ b/clang/test/ClangScanDeps/Inputs/has_include_if_elif.json
@@ -3,5 +3,10 @@
   "directory": "DIR",
   "command": "clang -E DIR/has_include_if_elif2.cpp -IInputs",
   "file": "DIR/has_include_if_elif2.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang-cl /E DIR/has_include_if_elif2_clangcl.cpp /IInputs",
+  "file": "DIR/has_include_if_elif2_clangcl.cpp"
 }
 ]

diff  --git a/clang/test/ClangScanDeps/Inputs/header_stat_before_open_cdb.json b/clang/test/ClangScanDeps/Inputs/header_stat_before_open_cdb.json
index c5f027e9fd28..797966c5684a 100644
--- a/clang/test/ClangScanDeps/Inputs/header_stat_before_open_cdb.json
+++ b/clang/test/ClangScanDeps/Inputs/header_stat_before_open_cdb.json
@@ -3,5 +3,10 @@
   "directory": "DIR",
   "command": "clang -E DIR/header_stat_before_open_input.m -iframework Inputs/frameworks",
   "file": "DIR/header_stat_before_open_input.m"
+},
+{
+  "directory": "DIR",
+  "command": "clang-cl /E DIR/header_stat_before_open_input_clangcl.m -Xclang -iframework -Xclang Inputs/frameworks",
+  "file": "DIR/header_stat_before_open_input_clangcl.m"
 }
 ]

diff  --git a/clang/test/ClangScanDeps/Inputs/headerwithdirname.json b/clang/test/ClangScanDeps/Inputs/headerwithdirname.json
index 2ae561935bec..980fb3d34426 100644
--- a/clang/test/ClangScanDeps/Inputs/headerwithdirname.json
+++ b/clang/test/ClangScanDeps/Inputs/headerwithdirname.json
@@ -3,5 +3,10 @@
       "directory": "DIR",
       "command": "clang -c -IDIR -IDIR/foodir -IInputs DIR/headerwithdirname_input.cpp",
       "file": "DIR/headerwithdirname_input.cpp"
+    },
+    {
+      "directory": "DIR",
+      "command": "clang-cl /c /IDIR /IDIR/foodir -IInputs DIR/headerwithdirname_input_clangcl.cpp",
+      "file": "DIR/headerwithdirname_input_clangcl.cpp"
     }
 ]

diff  --git a/clang/test/ClangScanDeps/Inputs/headerwithdirnamefollowedbyinclude.json b/clang/test/ClangScanDeps/Inputs/headerwithdirnamefollowedbyinclude.json
index de7759d0b110..a69637358a13 100644
--- a/clang/test/ClangScanDeps/Inputs/headerwithdirnamefollowedbyinclude.json
+++ b/clang/test/ClangScanDeps/Inputs/headerwithdirnamefollowedbyinclude.json
@@ -3,5 +3,10 @@
       "directory": "DIR",
       "command": "clang -c -IDIR -IInputs DIR/headerwithdirname_input.cpp",
       "file": "DIR/headerwithdirname_input.cpp"
+    },
+    {
+      "directory": "DIR",
+      "command": "clang-cl /c /IDIR /IInputs DIR/headerwithdirname_input_clangcl.cpp",
+      "file": "DIR/headerwithdirname_input_clangcl.cpp"
     }
 ]

diff  --git a/clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl.json b/clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl.json
new file mode 100644
index 000000000000..1d46af13c384
--- /dev/null
+++ b/clang/test/ClangScanDeps/Inputs/modules_cdb_clangcl.json
@@ -0,0 +1,22 @@
+[
+{
+  "directory": "DIR",
+  "command": "clang-cl /E DIR/modules_cdb_input2.cpp /IInputs /D INCLUDE_HEADER2 /clang:-MD /clang:-MF /clang:DIR/modules_cdb2_clangcl.d /clang:-fmodules /clang:-fcxx-modules /clang:-fmodules-cache-path=DIR/module-cache_clangcl /clang:-fimplicit-modules /clang:-fimplicit-module-maps",
+  "file": "DIR/modules_cdb_input2.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang-cl /E DIR/modules_cdb_input.cpp /IInputs /clang:-fmodules /clang:-fcxx-modules /clang:-fmodules-cache-path=DIR/module-cache_clangcl /clang:-fimplicit-modules /clang:-fimplicit-module-maps",
+  "file": "DIR/modules_cdb_input.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang-cl /E DIR/modules_cdb_input.cpp /IInputs /clang:-fmodules /clang:-fcxx-modules /clang:-fmodules-cache-path=DIR/module-cache_clangcl /clang:-fimplicit-modules /clang:-fimplicit-module-maps -o a.o",
+  "file": "DIR/modules_cdb_input.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang-cl /E DIR/modules_cdb_input.cpp /IInputs /clang:-fmodules /clang:-fcxx-modules /clang:-fmodules-cache-path=DIR/module-cache_clangcl /clang:-fimplicit-modules /clang:-fimplicit-module-maps -o b.o",
+  "file": "DIR/modules_cdb_input.cpp"
+}
+]

diff  --git a/clang/test/ClangScanDeps/Inputs/no-werror.json b/clang/test/ClangScanDeps/Inputs/no-werror.json
index 2d1f46cf3af2..1e1f68892e08 100644
--- a/clang/test/ClangScanDeps/Inputs/no-werror.json
+++ b/clang/test/ClangScanDeps/Inputs/no-werror.json
@@ -3,5 +3,10 @@
   "directory": "DIR",
   "command": "clang -E DIR/no-werror_input.cpp -IInputs -std=c++17 -Weverything -Werror",
   "file": "DIR/no-werror.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang-cl /E DIR/no-werror_input_clangcl.cpp /IInputs /std:c++17 -Weverything -Werror",
+  "file": "DIR/no-werror_clangcl.cpp"
 }
 ]

diff  --git a/clang/test/ClangScanDeps/Inputs/regular_cdb_clangcl.json b/clang/test/ClangScanDeps/Inputs/regular_cdb_clangcl.json
new file mode 100644
index 000000000000..93ce93d3be6f
--- /dev/null
+++ b/clang/test/ClangScanDeps/Inputs/regular_cdb_clangcl.json
@@ -0,0 +1,17 @@
+[
+{
+  "directory": "DIR",
+  "command": "clang --driver-mode=cl /E DIR/regular_cdb_input2.cpp /IInputs /D INCLUDE_HEADER2 /clang:-MD /clang:-MF /clang:DIR/regular_cdb2_clangcl.d",
+  "file": "DIR/regular_cdb_input2.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang-cl /E DIR/regular_cdb_input.cpp /IInputs",
+  "file": "DIR/regular_cdb_input.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang-cl /E DIR/regular_cdb_input.cpp /IInputs /Foadena.o",
+  "file": "DIR/regular_cdb_input.cpp"
+}
+]

diff  --git a/clang/test/ClangScanDeps/Inputs/static-analyzer-cdb.json b/clang/test/ClangScanDeps/Inputs/static-analyzer-cdb.json
index a466d87afaa4..6f1e882993b5 100644
--- a/clang/test/ClangScanDeps/Inputs/static-analyzer-cdb.json
+++ b/clang/test/ClangScanDeps/Inputs/static-analyzer-cdb.json
@@ -1,7 +1,12 @@
 [
 {
   "directory": "DIR",
-  "command": "clang --analyze DIR/static-analyzer.c",
-  "file": "DIR/static-analyzer.c"
+  "command": "clang --analyze DIR/static-analyzer_clang.c",
+  "file": "DIR/static-analyzer_clang.c"
+},
+{
+  "directory": "DIR",
+  "command": "clang-cl --analyze DIR/static-analyzer_clangcl.c",
+  "file": "DIR/static-analyzer_clangcl.c"
 }
 ]

diff  --git a/clang/test/ClangScanDeps/Inputs/strip_diag_serialize.json b/clang/test/ClangScanDeps/Inputs/strip_diag_serialize.json
index a774d95a3b02..1e40403502eb 100644
--- a/clang/test/ClangScanDeps/Inputs/strip_diag_serialize.json
+++ b/clang/test/ClangScanDeps/Inputs/strip_diag_serialize.json
@@ -3,5 +3,10 @@
   "directory": "DIR",
   "command": "clang -E -fsyntax-only DIR/strip_diag_serialize_input.cpp --serialize-diagnostics /does/not/exist",
   "file": "DIR/strip_diag_serialize_input.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang-cl /E DIR/strip_diag_serialize_input_clangcl.cpp --serialize-diagnostics A:/does/not/exist",
+  "file": "DIR/strip_diag_serialize_input_clangcl.cpp"
 }
 ]

diff  --git a/clang/test/ClangScanDeps/Inputs/target-filename-cdb.json b/clang/test/ClangScanDeps/Inputs/target-filename-cdb.json
index af2e43e4e171..f7dfdc9c510f 100644
--- a/clang/test/ClangScanDeps/Inputs/target-filename-cdb.json
+++ b/clang/test/ClangScanDeps/Inputs/target-filename-cdb.json
@@ -18,5 +18,50 @@
   "directory": "DIR",
   "command": "clang -E DIR/target-filename_input.cpp -o first.o -o last.o",
   "file": "DIR/target-filename_input.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang-cl /E DIR/target-filename_input.cpp",
+  "file": "DIR/target-filename_input.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang-cl /E DIR/target-filename_input.cpp -o clangcl-a.o",
+  "file": "DIR/target-filename_input.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang-cl /E DIR/target-filename_input.cpp -oclangcl-b.o",
+  "file": "DIR/target-filename_input.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang-cl /E DIR/target-filename_input.cpp /o clangcl-c.o",
+  "file": "DIR/target-filename_input.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang-cl /E DIR/target-filename_input.cpp /oclangcl-d.o",
+  "file": "DIR/target-filename_input.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang-cl /E DIR/target-filename_input.cpp /Foclangcl-e.o",
+  "file": "DIR/target-filename_input.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang-cl /E DIR/target-filename_input.cpp -o clangcl-firstf.o -o clangcl-lastf.o",
+  "file": "DIR/target-filename_input.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang-cl /E DIR/target-filename_input.cpp /oclangcl-firstg.o /Foclangcl-lastg.o",
+  "file": "DIR/target-filename_input.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang-cl /E DIR/target-filename_input.cpp /Foclangcl-firsth.o -o clangcl-midh.o /oclangcl-lasth.o",
+  "file": "DIR/target-filename_input.cpp"
 }
 ]

diff  --git a/clang/test/ClangScanDeps/Inputs/vfsoverlay_cdb.json b/clang/test/ClangScanDeps/Inputs/vfsoverlay_cdb.json
index 779203bac674..db43d87039af 100644
--- a/clang/test/ClangScanDeps/Inputs/vfsoverlay_cdb.json
+++ b/clang/test/ClangScanDeps/Inputs/vfsoverlay_cdb.json
@@ -3,5 +3,10 @@
   "directory": "DIR",
   "command": "clang -E DIR/vfsoverlay_input.cpp -IInputs -ivfsoverlay DIR/vfsoverlay.yaml",
   "file": "DIR/vfsoverlay_input.cpp"
+},
+{
+  "directory": "DIR",
+  "command": "clang-cl /E DIR/vfsoverlay_input_clangcl.cpp /IInputs -Xclang -ivfsoverlay -Xclang DIR/vfsoverlay.yaml",
+  "file": "DIR/vfsoverlay_input_clangcl.cpp"
 }
 ]

diff  --git a/clang/test/ClangScanDeps/error.cpp b/clang/test/ClangScanDeps/error.cpp
index e4e052527890..e18bf302af26 100644
--- a/clang/test/ClangScanDeps/error.cpp
+++ b/clang/test/ClangScanDeps/error.cpp
@@ -3,11 +3,16 @@
 // RUN: mkdir -p %t.dir
 // RUN: cp %s %t.dir/regular_cdb_input.cpp
 // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/regular_cdb.json > %t.cdb
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/regular_cdb_clangcl.json > %t_clangcl.cdb
 //
 // RUN: not clang-scan-deps -compilation-database %t.cdb -j 1 2>%t.dir/errs
 // RUN: echo EOF >> %t.dir/errs
 // RUN: FileCheck %s --input-file %t.dir/errs
 
+// RUN: not clang-scan-deps -compilation-database %t_clangcl.cdb -j 1 2>%t.dir/errs_clangcl
+// RUN: echo EOF >> %t.dir/errs_clangcl
+// RUN: FileCheck %s --input-file %t.dir/errs_clangcl
+
 #include "missing.h"
 
 // CHECK: Error while scanning dependencies

diff  --git a/clang/test/ClangScanDeps/has_include_if_elif.cpp b/clang/test/ClangScanDeps/has_include_if_elif.cpp
index dd56ecac69db..17eda40c1662 100644
--- a/clang/test/ClangScanDeps/has_include_if_elif.cpp
+++ b/clang/test/ClangScanDeps/has_include_if_elif.cpp
@@ -2,6 +2,7 @@
 // RUN: rm -rf %t.cdb
 // RUN: mkdir -p %t.dir
 // RUN: cp %s %t.dir/has_include_if_elif2.cpp
+// RUN: cp %s %t.dir/has_include_if_elif2_clangcl.cpp
 // RUN: mkdir %t.dir/Inputs
 // RUN: cp %S/Inputs/header.h %t.dir/Inputs/header.h
 // RUN: cp %S/Inputs/header.h %t.dir/Inputs/header2.h
@@ -36,3 +37,9 @@
 // CHECK-NEXT: Inputs{{/|\\}}header2.h
 // CHECK-NEXT: Inputs{{/|\\}}header3.h
 // CHECK-NEXT: Inputs{{/|\\}}header4.h
+
+// CHECK: has_include_if_elif2_clangcl.cpp
+// CHECK-NEXT: Inputs{{/|\\}}header.h
+// CHECK-NEXT: Inputs{{/|\\}}header2.h
+// CHECK-NEXT: Inputs{{/|\\}}header3.h
+// CHECK-NEXT: Inputs{{/|\\}}header4.h

diff  --git a/clang/test/ClangScanDeps/header_stat_before_open.m b/clang/test/ClangScanDeps/header_stat_before_open.m
index f9f7d240f2c1..ce6f58f434ae 100644
--- a/clang/test/ClangScanDeps/header_stat_before_open.m
+++ b/clang/test/ClangScanDeps/header_stat_before_open.m
@@ -2,6 +2,7 @@
 // RUN: rm -rf %t.cdb
 // RUN: mkdir -p %t.dir
 // RUN: cp %s %t.dir/header_stat_before_open_input.m
+// RUN: cp %s %t.dir/header_stat_before_open_input_clangcl.m
 // RUN: mkdir %t.dir/Inputs
 // RUN: cp -R %S/Inputs/frameworks %t.dir/Inputs/frameworks
 // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/header_stat_before_open_cdb.json > %t.cdb
@@ -16,3 +17,8 @@
 // CHECK-NEXT: header_stat_before_open_input.m
 // CHECK-NEXT: Inputs{{/|\\}}frameworks{{/|\\}}Framework.framework{{/|\\}}Headers{{/|\\}}Framework.h
 // CHECK-NEXT: Inputs{{/|\\}}frameworks{{/|\\}}Framework.framework{{/|\\}}PrivateHeaders{{/|\\}}PrivateHeader.h
+
+// CHECK: header_stat_before_open_input_clangcl.o
+// CHECK-NEXT: header_stat_before_open_input_clangcl.m
+// CHECK-NEXT: Inputs{{/|\\}}frameworks{{/|\\}}Framework.framework{{/|\\}}Headers{{/|\\}}Framework.h
+// CHECK-NEXT: Inputs{{/|\\}}frameworks{{/|\\}}Framework.framework{{/|\\}}PrivateHeaders{{/|\\}}PrivateHeader.h

diff  --git a/clang/test/ClangScanDeps/headerwithdirname.cpp b/clang/test/ClangScanDeps/headerwithdirname.cpp
index b0f60333aa4c..b6c7f796e90e 100644
--- a/clang/test/ClangScanDeps/headerwithdirname.cpp
+++ b/clang/test/ClangScanDeps/headerwithdirname.cpp
@@ -4,6 +4,7 @@
 // RUN: mkdir -p %t.dir
 // RUN: mkdir -p %t.dir/foodir
 // RUN: cp %s %t.dir/headerwithdirname_input.cpp
+// RUN: cp %s %t.dir/headerwithdirname_input_clangcl.cpp
 // RUN: mkdir %t.dir/Inputs
 // RUN: cp %S/Inputs/foodir %t.dir/Inputs/foodir
 // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/headerwithdirname.json > %t.cdb
@@ -15,3 +16,7 @@
 // CHECK: headerwithdirname_input.o
 // CHECK-NEXT: headerwithdirname_input.cpp
 // CHECK-NEXT: Inputs{{/|\\}}foodir
+
+// CHECK: headerwithdirname_input_clangcl.o
+// CHECK-NEXT: headerwithdirname_input_clangcl.cpp
+// CHECK-NEXT: Inputs{{/|\\}}foodir

diff  --git a/clang/test/ClangScanDeps/headerwithdirnamefollowedbyinclude.cpp b/clang/test/ClangScanDeps/headerwithdirnamefollowedbyinclude.cpp
index e8e8a69e82e2..1f9133dc74e8 100644
--- a/clang/test/ClangScanDeps/headerwithdirnamefollowedbyinclude.cpp
+++ b/clang/test/ClangScanDeps/headerwithdirnamefollowedbyinclude.cpp
@@ -7,6 +7,7 @@
 
 // RUN: cp %S/Inputs/header.h %t.dir/foodir/foodirheader.h
 // RUN: cp %s %t.dir/headerwithdirname_input.cpp
+// RUN: cp %s %t.dir/headerwithdirname_input_clangcl.cpp
 // RUN: mkdir %t.dir/Inputs
 // RUN: cp %S/Inputs/foodir %t.dir/Inputs/foodir
 // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/headerwithdirnamefollowedbyinclude.json > %t.cdb
@@ -19,3 +20,7 @@
 // CHECK: headerwithdirname_input.o
 // CHECK-NEXT: headerwithdirname_input.cpp
 // CHECK-NEXT: Inputs{{/|\\}}foodir
+
+// CHECK: headerwithdirname_input_clangcl.o
+// CHECK-NEXT: headerwithdirname_input_clangcl.cpp
+// CHECK-NEXT: Inputs{{/|\\}}foodir

diff  --git a/clang/test/ClangScanDeps/modules-full.cpp b/clang/test/ClangScanDeps/modules-full.cpp
index 1e6a740c2739..db2549670392 100644
--- a/clang/test/ClangScanDeps/modules-full.cpp
+++ b/clang/test/ClangScanDeps/modules-full.cpp
@@ -8,12 +8,18 @@
 // RUN: cp %S/Inputs/header2.h %t.dir/Inputs/header2.h
 // RUN: cp %S/Inputs/module.modulemap %t.dir/Inputs/module.modulemap
 // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/modules_cdb.json > %t.cdb
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/modules_cdb_clangcl.json > %t_clangcl.cdb
 //
 // RUN: echo %t.dir > %t.result
 // RUN: clang-scan-deps -compilation-database %t.cdb -j 4 -full-command-line \
 // RUN:   -mode preprocess-minimized-sources -format experimental-full >> %t.result
 // RUN: cat %t.result | sed 's/\\/\//g' | FileCheck --check-prefixes=CHECK %s
 
+// RUN: echo %t.dir > %t_clangcl.result
+// RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 4 -full-command-line \
+// RUN:   -mode preprocess-minimized-sources -format experimental-full >> %t_clangcl.result
+// RUN: cat %t_clangcl.result | sed 's/\\/\//g' | FileCheck --check-prefixes=CHECK %s
+
 // FIXME: Backslash issues.
 // XFAIL: system-windows
 
@@ -33,7 +39,7 @@
 // CHECK-NEXT:       "command-line": [
 // CHECK-NEXT:         "-fno-implicit-modules",
 // CHECK-NEXT:         "-fno-implicit-module-maps",
-// CHECK-NEXT:         "-fmodule-file=[[PREFIX]]/module-cache/[[CONTEXT_HASH_H1]]/header2-{{[A-Z0-9]+}}.pcm",
+// CHECK-NEXT:         "-fmodule-file=[[PREFIX]]/module-cache{{(_clangcl)?}}/[[CONTEXT_HASH_H1]]/header2-{{[A-Z0-9]+}}.pcm",
 // CHECK-NEXT:         "-fmodule-map-file=[[PREFIX]]/Inputs/module.modulemap"
 // CHECK-NEXT:       ],
 // CHECK-NEXT:       "context-hash": "[[CONTEXT_HASH_H1]]",
@@ -84,7 +90,7 @@
 // CHECK-NEXT:       "command-line": [
 // CHECK-NEXT:         "-fno-implicit-modules",
 // CHECK-NEXT:         "-fno-implicit-module-maps",
-// CHECK-NEXT:         "-fmodule-file=[[PREFIX]]/module-cache/[[CONTEXT_HASH_H2]]/header1-{{[A-Z0-9]+}}.pcm",
+// CHECK-NEXT:         "-fmodule-file=[[PREFIX]]/module-cache{{(_clangcl)?}}/[[CONTEXT_HASH_H2]]/header1-{{[A-Z0-9]+}}.pcm",
 // CHECK-NEXT:         "-fmodule-map-file=[[PREFIX]]/Inputs/module.modulemap"
 // CHECK-NEXT:       ],
 // CHECK-NEXT:       "file-deps": [
@@ -103,7 +109,7 @@
 // CHECK-NEXT:       "command-line": [
 // CHECK-NEXT:         "-fno-implicit-modules",
 // CHECK-NEXT:         "-fno-implicit-module-maps",
-// CHECK-NEXT:         "-fmodule-file=[[PREFIX]]/module-cache/[[CONTEXT_HASH_H2]]/header1-{{[A-Z0-9]+}}.pcm",
+// CHECK-NEXT:         "-fmodule-file=[[PREFIX]]/module-cache{{(_clangcl)?}}/[[CONTEXT_HASH_H2]]/header1-{{[A-Z0-9]+}}.pcm",
 // CHECK-NEXT:         "-fmodule-map-file=[[PREFIX]]/Inputs/module.modulemap"
 // CHECK-NEXT:       ],
 // CHECK-NEXT:       "file-deps": [
@@ -122,7 +128,7 @@
 // CHECK-NEXT:       "command-line": [
 // CHECK-NEXT:         "-fno-implicit-modules",
 // CHECK-NEXT:         "-fno-implicit-module-maps",
-// CHECK-NEXT:         "-fmodule-file=[[PREFIX]]/module-cache/[[CONTEXT_HASH_H2]]/header1-{{[A-Z0-9]+}}.pcm",
+// CHECK-NEXT:         "-fmodule-file=[[PREFIX]]/module-cache{{(_clangcl)?}}/[[CONTEXT_HASH_H2]]/header1-{{[A-Z0-9]+}}.pcm",
 // CHECK-NEXT:         "-fmodule-map-file=[[PREFIX]]/Inputs/module.modulemap"
 // CHECK-NEXT:       ],
 // CHECK-NEXT:       "file-deps": [
@@ -141,9 +147,9 @@
 // CHECK-NEXT:       "command-line": [
 // CHECK-NEXT:         "-fno-implicit-modules",
 // CHECK-NEXT:         "-fno-implicit-module-maps",
-// CHECK-NEXT:         "-fmodule-file=[[PREFIX]]/module-cache/[[CONTEXT_HASH_H1]]/header2-{{[A-Z0-9]+}}.pcm",
+// CHECK-NEXT:         "-fmodule-file=[[PREFIX]]/module-cache{{(_clangcl)?}}/[[CONTEXT_HASH_H1]]/header2-{{[A-Z0-9]+}}.pcm",
 // CHECK-NEXT:         "-fmodule-map-file=[[PREFIX]]/Inputs/module.modulemap",
-// CHECK-NEXT:         "-fmodule-file=[[PREFIX]]/module-cache/[[CONTEXT_HASH_H1]]/header1-{{[A-Z0-9]+}}.pcm",
+// CHECK-NEXT:         "-fmodule-file=[[PREFIX]]/module-cache{{(_clangcl)?}}/[[CONTEXT_HASH_H1]]/header1-{{[A-Z0-9]+}}.pcm",
 // CHECK-NEXT:         "-fmodule-map-file=[[PREFIX]]/Inputs/module.modulemap"
 // CHECK-NEXT:       ],
 // CHECK-NEXT:       "file-deps": [

diff  --git a/clang/test/ClangScanDeps/modules.cpp b/clang/test/ClangScanDeps/modules.cpp
index 599fcd1b4353..f0d97dc0c5c2 100644
--- a/clang/test/ClangScanDeps/modules.cpp
+++ b/clang/test/ClangScanDeps/modules.cpp
@@ -1,6 +1,8 @@
 // RUN: rm -rf %t.dir
 // RUN: rm -rf %t.cdb
+// RUN: rm -rf %t_clangcl.cdb
 // RUN: rm -rf %t.module-cache
+// RUN: rm -rf %t.module-cache_clangcl
 // RUN: mkdir -p %t.dir
 // RUN: cp %s %t.dir/modules_cdb_input.cpp
 // RUN: cp %s %t.dir/modules_cdb_input2.cpp
@@ -9,9 +11,12 @@
 // RUN: cp %S/Inputs/header2.h %t.dir/Inputs/header2.h
 // RUN: cp %S/Inputs/module.modulemap %t.dir/Inputs/module.modulemap
 // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/modules_cdb.json > %t.cdb
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/modules_cdb_clangcl.json > %t_clangcl.cdb
 //
 // RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -mode preprocess-minimized-sources | \
 // RUN:   FileCheck --check-prefixes=CHECK1,CHECK2,CHECK2NO %s
+// RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 1 -mode preprocess-minimized-sources | \
+// RUN:   FileCheck --check-prefixes=CHECK1,CHECK2,CHECK2NO %s
 //
 // The output order is non-deterministic when using more than one thread,
 // so check the output using two runs. Note that the 'NOT' check is not used
@@ -20,12 +25,20 @@
 //
 // RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess-minimized-sources | \
 // RUN:   FileCheck --check-prefix=CHECK1 %s
+// RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 2 -mode preprocess-minimized-sources | \
+// RUN:   FileCheck --check-prefix=CHECK1 %s
 // RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess | \
 // RUN:   FileCheck --check-prefix=CHECK1 %s
+// RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 2 -mode preprocess | \
+// RUN:   FileCheck --check-prefix=CHECK1 %s
 // RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess-minimized-sources | \
 // RUN:   FileCheck --check-prefix=CHECK2 %s
+// RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 2 -mode preprocess-minimized-sources | \
+// RUN:   FileCheck --check-prefix=CHECK2 %s
 // RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess | \
 // RUN:   FileCheck --check-prefix=CHECK2 %s
+// RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 2 -mode preprocess | \
+// RUN:   FileCheck --check-prefix=CHECK2 %s
 
 #include "header.h"
 

diff  --git a/clang/test/ClangScanDeps/no-werror.cpp b/clang/test/ClangScanDeps/no-werror.cpp
index 95407c51b3cc..11f1b718dac5 100644
--- a/clang/test/ClangScanDeps/no-werror.cpp
+++ b/clang/test/ClangScanDeps/no-werror.cpp
@@ -2,6 +2,7 @@
 // RUN: rm -rf %t.cdb
 // RUN: mkdir -p %t.dir
 // RUN: cp %s %t.dir/no-werror_input.cpp
+// RUN: cp %s %t.dir/no-werror_input_clangcl.cpp
 // RUN: mkdir %t.dir/Inputs
 // RUN: cp %S/Inputs/sys-header.h %t.dir/Inputs/sys-header.h
 // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/no-werror.json > %t.cdb
@@ -14,3 +15,6 @@
 
 // CHECK: no-werror_input.cpp
 // CHECK-NEXT: Inputs{{/|\\}}sys-header.h
+
+// CHECK: no-werror_input_clangcl.cpp
+// CHECK-NEXT: Inputs{{/|\\}}sys-header.h

diff  --git a/clang/test/ClangScanDeps/regular_cdb.cpp b/clang/test/ClangScanDeps/regular_cdb.cpp
index 8fb94350e4c2..d7ba2519067e 100644
--- a/clang/test/ClangScanDeps/regular_cdb.cpp
+++ b/clang/test/ClangScanDeps/regular_cdb.cpp
@@ -1,5 +1,6 @@
 // RUN: rm -rf %t.dir
 // RUN: rm -rf %t.cdb
+// RUN: rm -rf %t_clangcl.cdb
 // RUN: mkdir -p %t.dir
 // RUN: cp %s %t.dir/regular_cdb_input.cpp
 // RUN: cp %s %t.dir/regular_cdb_input2.cpp
@@ -7,17 +8,28 @@
 // RUN: cp %S/Inputs/header.h %t.dir/Inputs/header.h
 // RUN: cp %S/Inputs/header2.h %t.dir/Inputs/header2.h
 // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/regular_cdb.json > %t.cdb
+// RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/regular_cdb_clangcl.json > %t_clangcl.cdb
 //
 // RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -mode preprocess-minimized-sources | \
 // RUN:   FileCheck --check-prefixes=CHECK1,CHECK2,CHECK2NO,CHECK3 %s
+// RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 1 -mode preprocess-minimized-sources | \
+// RUN:   FileCheck --check-prefixes=CHECK1,CHECK2,CHECK2NO,CHECK3 %s
+
 // RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -mode preprocess | \
 // RUN:   FileCheck --check-prefixes=CHECK1,CHECK2,CHECK2NO,CHECK3 %s
+// RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 1 -mode preprocess | \
+// RUN:   FileCheck --check-prefixes=CHECK1,CHECK2,CHECK2NO,CHECK3 %s
+
 // RUN: clang-scan-deps -compilation-database %t.cdb -j 1 -mode preprocess-minimized-sources \
 // RUN:   -skip-excluded-pp-ranges=0 | FileCheck --check-prefixes=CHECK1,CHECK2,CHECK2NO,CHECK3 %s
+// RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 1 -mode preprocess-minimized-sources \
+// RUN:   -skip-excluded-pp-ranges=0 | FileCheck --check-prefixes=CHECK1,CHECK2,CHECK2NO,CHECK3 %s
 //
 // Make sure we didn't produce any dependency files!
 // RUN: not cat %t.dir/regular_cdb.d
+// RUN: not cat %t.dir/regular_cdb_clangcl.d
 // RUN: not cat %t.dir/regular_cdb2.d
+// RUN: not cat %t.dir/regular_cdb2_clangcl.d
 //
 // The output order is non-deterministic when using more than one thread,
 // so check the output using two runs. Note that the 'NOT' check is not used
@@ -26,12 +38,23 @@
 //
 // RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess-minimized-sources | \
 // RUN:   FileCheck --check-prefix=CHECK1 %s
+// RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 2 -mode preprocess-minimized-sources | \
+// RUN:   FileCheck --check-prefix=CHECK1 %s
+
 // RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess | \
 // RUN:   FileCheck --check-prefix=CHECK1 %s
+// RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 2 -mode preprocess | \
+// RUN:   FileCheck --check-prefix=CHECK1 %s
+
 // RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess-minimized-sources | \
 // RUN:   FileCheck --check-prefix=CHECK2 %s
+// RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 2 -mode preprocess-minimized-sources | \
+// RUN:   FileCheck --check-prefix=CHECK2 %s
+
 // RUN: clang-scan-deps -compilation-database %t.cdb -j 2 -mode preprocess | \
 // RUN:   FileCheck --check-prefix=CHECK2 %s
+// RUN: clang-scan-deps -compilation-database %t_clangcl.cdb -j 2 -mode preprocess | \
+// RUN:   FileCheck --check-prefix=CHECK2 %s
 
 #include "header.h"
 

diff  --git a/clang/test/ClangScanDeps/static-analyzer.c b/clang/test/ClangScanDeps/static-analyzer.c
index c4af9b076bb2..053e4573d056 100644
--- a/clang/test/ClangScanDeps/static-analyzer.c
+++ b/clang/test/ClangScanDeps/static-analyzer.c
@@ -1,7 +1,8 @@
 // RUN: rm -rf %t.dir
 // RUN: rm -rf %t-cdb.json
 // RUN: mkdir -p %t.dir
-// RUN: cp %s %t.dir/static-analyzer.c
+// RUN: cp %s %t.dir/static-analyzer_clang.c
+// RUN: cp %s %t.dir/static-analyzer_clangcl.c
 // RUN: mkdir %t.dir/Inputs
 // RUN: cp %S/Inputs/header.h %t.dir/Inputs/analyze_header_input.h
 // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/static-analyzer-cdb.json > %t-cdb.json
@@ -12,5 +13,9 @@
 #include "Inputs/analyze_header_input.h"
 #endif
 
-// CHECK: analyze_header_input.h
+// CHECK: static-analyzer_clang.c
+// CHECK-NEXT: analyze_header_input.h
+
+// CHECK: static-analyzer_clangcl.c
+// CHECK-NEXT: analyze_header_input.h
 

diff  --git a/clang/test/ClangScanDeps/strip_diag_serialize.cpp b/clang/test/ClangScanDeps/strip_diag_serialize.cpp
index ec62e7513481..d9f758882027 100644
--- a/clang/test/ClangScanDeps/strip_diag_serialize.cpp
+++ b/clang/test/ClangScanDeps/strip_diag_serialize.cpp
@@ -2,10 +2,12 @@
 // RUN: rm -rf %t.cdb
 // RUN: mkdir -p %t.dir
 // RUN: cp %s %t.dir/strip_diag_serialize_input.cpp
+// RUN: cp %s %t.dir/strip_diag_serialize_input_clangcl.cpp
 // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/strip_diag_serialize.json > %t.cdb
 //
-// RUN: clang-scan-deps -compilation-database %t.cdb 2>&1 | FileCheck %s
+// RUN: clang-scan-deps -compilation-database %t.cdb -j 1 2>&1 | FileCheck %s
 // CHECK-NOT: unable to open file
 // CHECK: strip_diag_serialize_input.cpp
+// CHECK: strip_diag_serialize_input_clangcl.cpp
 
 #warning "diagnostic"

diff  --git a/clang/test/ClangScanDeps/target-filename.cpp b/clang/test/ClangScanDeps/target-filename.cpp
index c47166b21e4e..02084ee9b372 100644
--- a/clang/test/ClangScanDeps/target-filename.cpp
+++ b/clang/test/ClangScanDeps/target-filename.cpp
@@ -18,3 +18,30 @@
 
 // CHECK-NEXT: last.o:
 // CHECK-NEXT: target-filename_input.cpp
+
+// CHECK: target-filename_input.o:
+// CHECK-NEXT: target-filename_input.cpp
+
+// CHECK-NEXT: clangcl-a.o:
+// CHECK-NEXT: target-filename_input.cpp
+
+// CHECK-NEXT: clangcl-b.o:
+// CHECK-NEXT: target-filename_input.cpp
+
+// CHECK-NEXT: clangcl-c.o:
+// CHECK-NEXT: target-filename_input.cpp
+
+// CHECK-NEXT: clangcl-d.o:
+// CHECK-NEXT: target-filename_input.cpp
+
+// CHECK-NEXT: clangcl-e.o:
+// CHECK-NEXT: target-filename_input.cpp
+
+// CHECK-NEXT: clangcl-lastf.o:
+// CHECK-NEXT: target-filename_input.cpp
+
+// CHECK-NEXT: clangcl-lastg.o:
+// CHECK-NEXT: target-filename_input.cpp
+
+// CHECK-NEXT: clangcl-lasth.o:
+// CHECK-NEXT: target-filename_input.cpp

diff  --git a/clang/test/ClangScanDeps/vfsoverlay.cpp b/clang/test/ClangScanDeps/vfsoverlay.cpp
index 517738943ab5..b3a2b23daad7 100644
--- a/clang/test/ClangScanDeps/vfsoverlay.cpp
+++ b/clang/test/ClangScanDeps/vfsoverlay.cpp
@@ -2,6 +2,7 @@
 // RUN: rm -rf %t.cdb
 // RUN: mkdir -p %t.dir
 // RUN: cp %s %t.dir/vfsoverlay_input.cpp
+// RUN: cp %s %t.dir/vfsoverlay_input_clangcl.cpp
 // RUN: sed -e "s|DIR|%/t.dir|g" %S/Inputs/vfsoverlay.yaml > %t.dir/vfsoverlay.yaml
 // RUN: mkdir %t.dir/Inputs
 // RUN: cp %S/Inputs/header.h %t.dir/Inputs/header.h
@@ -15,3 +16,7 @@
 // CHECK: vfsoverlay_input.o
 // CHECK-NEXT: vfsoverlay_input.cpp
 // CHECK-NEXT: Inputs{{/|\\}}header.h
+
+// CHECK: vfsoverlay_input_clangcl.o
+// CHECK-NEXT: vfsoverlay_input_clangcl.cpp
+// CHECK-NEXT: Inputs{{/|\\}}header.h

diff  --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
index 1bb65ef12d6b..9e52f84615b9 100644
--- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -12,6 +12,8 @@
 #include "clang/Tooling/DependencyScanning/DependencyScanningTool.h"
 #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
 #include "clang/Tooling/JSONCompilationDatabase.h"
+#include "llvm/ADT/STLExtras.h"
+#include "llvm/ADT/Twine.h"
 #include "llvm/Support/CommandLine.h"
 #include "llvm/Support/FileUtilities.h"
 #include "llvm/Support/InitLLVM.h"
@@ -49,7 +51,8 @@ class ResourceDirectoryCache {
   /// option and cache the results for reuse. \returns resource directory path
   /// associated with the given invocation command or empty string if the
   /// compiler path is NOT an absolute path.
-  StringRef findResourceDir(const tooling::CommandLineArguments &Args) {
+  StringRef findResourceDir(const tooling::CommandLineArguments &Args,
+                            bool ClangCLMode) {
     if (Args.size() < 1)
       return "";
 
@@ -65,8 +68,12 @@ class ResourceDirectoryCache {
     if (CachedResourceDir != Cache.end())
       return CachedResourceDir->second;
 
-    std::vector<StringRef> PrintResourceDirArgs{ClangBinaryName,
-                                                "-print-resource-dir"};
+    std::vector<StringRef> PrintResourceDirArgs{ClangBinaryName};
+    if (ClangCLMode)
+      PrintResourceDirArgs.push_back("/clang:-print-resource-dir");
+    else
+      PrintResourceDirArgs.push_back("-print-resource-dir");
+
     llvm::SmallString<64> OutputFile, ErrorFile;
     llvm::sys::fs::createTemporaryFile("print-resource-dir-output",
                                        "" /*no-suffix*/, OutputFile);
@@ -421,23 +428,52 @@ int main(int argc, const char **argv) {
         bool HasMQ = false;
         bool HasMD = false;
         bool HasResourceDir = false;
+        bool ClangCLMode = false;
+
         // We need to find the last -o value.
         if (!Args.empty()) {
+          ClangCLMode =
+              llvm::sys::path::stem(Args[0]).contains_lower("clang-cl") ||
+              llvm::is_contained(Args, "--driver-mode=cl");
+
           std::size_t Idx = Args.size() - 1;
           for (auto It = Args.rbegin(); It != Args.rend(); ++It) {
             StringRef Arg = Args[Idx];
-            if (LastO.empty()) {
-              if (Arg == "-o" && It != Args.rbegin())
-                LastO = Args[Idx + 1];
-              else if (Arg.startswith("-o"))
-                LastO = Arg.drop_front(2).str();
+            if (ClangCLMode) {
+              if (LastO.empty()) {
+                // With clang-cl, the output obj file can be specified with
+                // "/opath", "/o path", "/Fopath", and the dash counterparts.
+                // Also, clang-cl adds ".obj" extension if none is found.
+                if ((Arg == "-o" || Arg == "/o") && It != Args.rbegin())
+                  LastO = Args[Idx + 1];
+                else if (Arg.startswith("/Fo") || Arg.startswith("-Fo"))
+                  LastO = Arg.drop_front(3).str();
+                else if (Arg.startswith("/o") || Arg.startswith("-o"))
+                  LastO = Arg.drop_front(2).str();
+
+                if (!LastO.empty() && !llvm::sys::path::has_extension(LastO))
+                  LastO.append(".obj");
+              }
+              if (Arg == "/clang:-MT")
+                HasMT = true;
+              if (Arg == "/clang:-MQ")
+                HasMQ = true;
+              if (Arg == "/clang:-MD")
+                HasMD = true;
+            } else {
+              if (LastO.empty()) {
+                if (Arg == "-o" && It != Args.rbegin())
+                  LastO = Args[Idx + 1];
+                else if (Arg.startswith("-o"))
+                  LastO = Arg.drop_front(2).str();
+              }
+              if (Arg == "-MT")
+                HasMT = true;
+              if (Arg == "-MQ")
+                HasMQ = true;
+              if (Arg == "-MD")
+                HasMD = true;
             }
-            if (Arg == "-MT")
-              HasMT = true;
-            if (Arg == "-MQ")
-              HasMQ = true;
-            if (Arg == "-MD")
-              HasMD = true;
             if (Arg == "-resource-dir")
               HasResourceDir = true;
             --Idx;
@@ -446,21 +482,36 @@ int main(int argc, const char **argv) {
         // If there's no -MT/-MQ Driver would add -MT with the value of the last
         // -o option.
         tooling::CommandLineArguments AdjustedArgs = Args;
+
         AdjustedArgs.push_back("-o");
+#ifdef _WIN32
+        AdjustedArgs.push_back("nul");
+#else
         AdjustedArgs.push_back("/dev/null");
+#endif
+
         if (!HasMT && !HasMQ) {
-          AdjustedArgs.push_back("-M");
-          AdjustedArgs.push_back("-MT");
           // We're interested in source dependencies of an object file.
+          std::string FileNameArg;
           if (!HasMD) {
             // FIXME: We are missing the directory unless the -o value is an
             // absolute path.
-            AdjustedArgs.push_back(!LastO.empty() ? LastO
-                                                  : getObjFilePath(FileName));
+            FileNameArg = !LastO.empty() ? LastO : getObjFilePath(FileName);
           } else {
-            AdjustedArgs.push_back(std::string(FileName));
+            FileNameArg = std::string(FileName);
+          }
+
+          if (ClangCLMode) {
+            AdjustedArgs.push_back("/clang:-M");
+            AdjustedArgs.push_back("/clang:-MT");
+            AdjustedArgs.push_back(Twine("/clang:", FileNameArg).str());
+          } else {
+            AdjustedArgs.push_back("-M");
+            AdjustedArgs.push_back("-MT");
+            AdjustedArgs.push_back(std::move(FileNameArg));
           }
         }
+
         AdjustedArgs.push_back("-Xclang");
         AdjustedArgs.push_back("-Eonly");
         AdjustedArgs.push_back("-Xclang");
@@ -469,7 +520,7 @@ int main(int argc, const char **argv) {
 
         if (!HasResourceDir) {
           StringRef ResourceDir =
-              ResourceDirCache.findResourceDir(Args);
+              ResourceDirCache.findResourceDir(Args, ClangCLMode);
           if (!ResourceDir.empty()) {
             AdjustedArgs.push_back("-resource-dir");
             AdjustedArgs.push_back(std::string(ResourceDir));


        


More information about the llvm-branch-commits mailing list