Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / ClangScanDeps / removed-args.c
blob9a4ef25838e4650a0177f717096da9a31b937485
1 // Some command-line arguments used for compiling translation units are not
2 // compatible with the semantics of modules or are likely to differ between
3 // identical modules discovered from different translation units. This test
4 // checks such arguments are removed from the command-lines: '-include',
5 // '-dwarf-debug-flag' and '-main-file-name'. Similarly, several arguments
6 // such as '-fmodules-cache-path=' are only relevant for implicit modules, and
7 // are removed to better-canonicalize the compilation.
9 // RUN: rm -rf %t && mkdir %t
10 // RUN: cp %S/Inputs/removed-args/* %t
11 // RUN: touch %t/build-session
13 // RUN: sed "s|DIR|%/t|g" %S/Inputs/removed-args/cdb.json.template > %t/cdb.json
14 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full > %t/result.json
15 // RUN: cat %t/result.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t
17 // CHECK: {
18 // CHECK-NEXT: "modules": [
19 // CHECK-NEXT: {
20 // CHECK-NEXT: "clang-module-deps": [],
21 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
22 // CHECK-NEXT: "command-line": [
23 // CHECK-NEXT: "-cc1"
24 // CHECK-NOT: "-fdebug-compilation-dir="
25 // CHECK-NOT: "-fcoverage-compilation-dir="
26 // CHECK-NOT: "-coverage-notes-file
27 // CHECK-NOT: "-coverage-data-file
28 // CHECK-NOT: "-dwarf-debug-flags"
29 // CHECK-NOT: "-main-file-name"
30 // CHECK-NOT: "-include"
31 // CHECK-NOT: "-fmodules-cache-path=
32 // CHECK-NOT: "-fmodules-validate-once-per-build-session"
33 // CHECK-NOT: "-fbuild-session-timestamp=
34 // CHECK-NOT: "-fmodules-prune-interval=
35 // CHECK-NOT: "-fmodules-prune-after=
36 // CHECK: ],
37 // CHECK-NEXT: "context-hash": "[[HASH_MOD_HEADER:.*]]",
38 // CHECK-NEXT: "file-deps": [
39 // CHECK-NEXT: "[[PREFIX]]/mod_header.h",
40 // CHECK-NEXT: "[[PREFIX]]/module.modulemap"
41 // CHECK-NEXT: ],
42 // CHECK-NEXT: "name": "ModHeader"
43 // CHECK-NEXT: },
44 // CHECK-NEXT: {
45 // CHECK-NEXT: "clang-module-deps": [],
46 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
47 // CHECK-NEXT: "command-line": [
48 // CHECK-NEXT: "-cc1"
49 // CHECK-NOT: "-fdebug-compilation-dir=
50 // CHECK-NOT: "-fcoverage-compilation-dir=
51 // CHECK-NOT: "-coverage-notes-file
52 // CHECK-NOT: "-coverage-data-file
53 // CHECK-NOT: "-dwarf-debug-flags"
54 // CHECK-NOT: "-main-file-name"
55 // CHECK-NOT: "-include"
56 // CHECK-NOT: "-fmodules-cache-path=
57 // CHECK-NOT: "-fmodules-validate-once-per-build-session"
58 // CHECK-NOT: "-fbuild-session-timestamp=
59 // CHECK-NOT: "-fmodules-prune-interval=
60 // CHECK-NOT: "-fmodules-prune-after=
61 // CHECK: ],
62 // CHECK-NEXT: "context-hash": "[[HASH_MOD_TU:.*]]",
63 // CHECK-NEXT: "file-deps": [
64 // CHECK-NEXT: "[[PREFIX]]/mod_tu.h",
65 // CHECK-NEXT: "[[PREFIX]]/module.modulemap"
66 // CHECK-NEXT: ],
67 // CHECK-NEXT: "name": "ModTU"
68 // CHECK-NEXT: }
69 // CHECK-NEXT: ],
70 // CHECK-NEXT: "translation-units": [
71 // CHECK-NEXT: {
72 // CHECK: "clang-context-hash": "[[HASH_TU:.*]]",
73 // CHECK-NEXT: "clang-module-deps": [
74 // CHECK-NEXT: {
75 // CHECK-NEXT: "context-hash": "[[HASH_MOD_HEADER]]",
76 // CHECK-NEXT: "module-name": "ModHeader"
77 // CHECK-NEXT: },
78 // CHECK-NEXT: {
79 // CHECK-NEXT: "context-hash": "[[HASH_MOD_TU]]",
80 // CHECK-NEXT: "module-name": "ModTU"
81 // CHECK-NEXT: }
82 // CHECK-NEXT: ]
83 // CHECK-NEXT: "command-line": [
84 // CHECK-NEXT: "-cc1",
85 // CHECK-NOT: "-fmodules-cache-path=
86 // CHECK-NOT: "-fmodules-validate-once-per-build-session"
87 // CHECK-NOT: "-fbuild-session-timestamp=
88 // CHECK-NOT: "-fbuild-session-file=
89 // CHECK-NOT: "-fmodules-prune-interval=
90 // CHECK-NOT: "-fmodules-prune-after=
91 // CHECK: ],