xref: /llvm-project/clang/test/ClangScanDeps/response-file-clang-cl.c (revision 90e33e20a594b8a404af1df93b629137cb605a21)
1*90e33e20SAlexandre Ganea // Check that the scanner can adjust arguments by reading .rsp files in advance.
2*90e33e20SAlexandre Ganea 
3*90e33e20SAlexandre Ganea // RUN: rm -rf %t
4*90e33e20SAlexandre Ganea // RUN: split-file %s %t
5*90e33e20SAlexandre Ganea 
6*90e33e20SAlexandre Ganea // First run the tests with a .cdb
7*90e33e20SAlexandre Ganea // RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
8*90e33e20SAlexandre Ganea // RUN: sed -e "s|DIR|%/t|g" %t/args_nested.template > %t/args_nested.rsp
9*90e33e20SAlexandre Ganea 
10*90e33e20SAlexandre Ganea // RUN: cp %t/args_compilation.rsp %t/args.rsp
11*90e33e20SAlexandre Ganea // RUN: clang-scan-deps --compilation-database %t/cdb.json > %t/deps.json
12*90e33e20SAlexandre Ganea // RUN: cat %t/deps.json | sed 's:\\\\\?:/:g' | FileCheck -DPREFIX=%/t %s
13*90e33e20SAlexandre Ganea 
14*90e33e20SAlexandre Ganea // RUN: cp %t/args_preprocess.rsp %t/args.rsp
15*90e33e20SAlexandre Ganea // RUN: clang-scan-deps --compilation-database %t/cdb.json > %t/deps.json
16*90e33e20SAlexandre Ganea // RUN: cat %t/deps.json | sed 's:\\\\\?:/:g' | FileCheck -DPREFIX=%/t %s
17*90e33e20SAlexandre Ganea 
18*90e33e20SAlexandre Ganea 
19*90e33e20SAlexandre Ganea // Now run the tests again with a in-place compilation database
20*90e33e20SAlexandre Ganea // RUN: cd %t
21*90e33e20SAlexandre Ganea 
22*90e33e20SAlexandre Ganea // RUN: cp args_compilation.rsp args.rsp
23*90e33e20SAlexandre Ganea // RUN: clang-scan-deps -o deps.json -- %clang_cl @args.rsp
24*90e33e20SAlexandre Ganea // RUN: cat deps.json | sed 's:\\\\\?:/:g' | FileCheck -DPREFIX=%/t %s
25*90e33e20SAlexandre Ganea 
26*90e33e20SAlexandre Ganea // RUN: cp args_preprocess.rsp args.rsp
27*90e33e20SAlexandre Ganea // RUN: clang-scan-deps -o deps.json -- %clang_cl @args.rsp
28*90e33e20SAlexandre Ganea // RUN: cat deps.json | sed 's:\\\\\?:/:g' | FileCheck -DPREFIX=%/t %s
29*90e33e20SAlexandre Ganea 
30*90e33e20SAlexandre Ganea // Here we ensure that we got a qualified .obj with its full path, since that's what we're passing with /Fo
31*90e33e20SAlexandre Ganea // CHECK: [[PREFIX]]/tu.obj:
32*90e33e20SAlexandre Ganea 
33*90e33e20SAlexandre Ganea //--- cdb.json.template
34*90e33e20SAlexandre Ganea [{
35*90e33e20SAlexandre Ganea   "file": "DIR/tu.cpp",
36*90e33e20SAlexandre Ganea   "directory": "DIR",
37*90e33e20SAlexandre Ganea   "command": "clang-cl @DIR/args.rsp"
38*90e33e20SAlexandre Ganea }]
39*90e33e20SAlexandre Ganea 
40*90e33e20SAlexandre Ganea //--- args_compilation.rsp
41*90e33e20SAlexandre Ganea @args_nested.rsp
42*90e33e20SAlexandre Ganea /c
43*90e33e20SAlexandre Ganea 
44*90e33e20SAlexandre Ganea //--- args_preprocess.rsp
45*90e33e20SAlexandre Ganea @args_nested.rsp
46*90e33e20SAlexandre Ganea /E
47*90e33e20SAlexandre Ganea 
48*90e33e20SAlexandre Ganea //--- args_nested.template
49*90e33e20SAlexandre Ganea /I include
50*90e33e20SAlexandre Ganea tu.cpp
51*90e33e20SAlexandre Ganea /FoDIR/tu.obj
52*90e33e20SAlexandre Ganea 
53*90e33e20SAlexandre Ganea //--- include/header.h
54*90e33e20SAlexandre Ganea 
55*90e33e20SAlexandre Ganea //--- tu.cpp
56*90e33e20SAlexandre Ganea #include "header.h"
57