Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / ClangScanDeps / modules-context-hash-ignore-macros.c
blob9f7a62fb9eb74bdedea0c6a6a9ed6d71f8920b27
1 // Ensure '-DFOO -fmodules-ignore-macro=FOO' and '' both produce the same
2 // canonical module build command.
4 // RUN: rm -rf %t
5 // RUN: split-file %s %t
6 // RUN: sed "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
8 // RUN: clang-scan-deps -compilation-database %t/cdb.json -j 1 \
9 // RUN: -format experimental-full > %t/deps.json
10 // RUN: cat %t/deps.json | sed 's:\\\\\?:/:g' | FileCheck -DPREFIX=%/t %s
12 // CHECK: {
13 // CHECK-NEXT: "modules": [
14 // CHECK: {
15 // CHECK: "command-line": [
16 // CHECK-NOT: "FOO"
17 // CHECK-NOT: "-fmodules-ignore-macro
18 // CHECK: ]
19 // CHECK: "context-hash": "[[HASH_NO_FOO:.*]]"
20 // CHECK: "name": "Mod"
21 // CHECK-NEXT: }
22 // CHECK-NEXT: {
23 // CHECK: "command-line": [
24 // CHECK: "-D"
25 // CHECK-NEXT: "FOO"
26 // CHECK: ]
27 // CHECK: "context-hash": "[[HASH_FOO:.*]]"
28 // CHECK: "name": "Mod"
29 // CHECK-NEXT: }
30 // CHECK-NEXT: ]
31 // CHECK-NEXT: "translation-units": [
32 // CHECK-NEXT: {
33 // CHECK: "clang-module-deps": [
34 // CHECK-NEXT: {
35 // CHECK-NEXT: "context-hash": "[[HASH_NO_FOO]]"
36 // CHECK-NEXT: "module-name": "Mod"
37 // CHECK-NEXT: }
38 // CHECK-NEXT: ]
39 // CHECK-NEXT: "command-line": [
40 // CHECK-NOT: "-DFOO"
41 // CHECK-NOT: "FOO"
42 // CHECK: ]
43 // CHECK: "input-file": "{{.*}}tu1.c"
44 // CHECK-NEXT: }
45 // CHECK: {
46 // CHECK: "clang-module-deps": [
47 // CHECK-NEXT: {
48 // CHECK-NEXT: "context-hash": "[[HASH_FOO]]"
49 // CHECK-NEXT: "module-name": "Mod"
50 // CHECK-NEXT: }
51 // CHECK-NEXT: ]
52 // CHECK-NEXT: "command-line": [
53 // CHECK: "-D"
54 // CHECK-NEXT: "FOO"
55 // CHECK: ]
56 // CHECK: "input-file": "{{.*}}tu2.c"
57 // CHECK-NEXT: }
58 // CHECK: {
59 // CHECK: "clang-module-deps": [
60 // CHECK-NEXT: {
61 // CHECK-NEXT: "context-hash": "[[HASH_NO_FOO]]"
62 // CHECK-NEXT: "module-name": "Mod"
63 // CHECK-NEXT: }
64 // CHECK-NEXT: ]
65 // CHECK-NEXT: "command-line": [
66 // CHECK: "-fmodules-ignore-macro=FOO"
67 // CHECK: "-D"
68 // CHECK-NEXT: "FOO"
69 // CHECK: ]
70 // CHECK: "input-file": "{{.*}}tu3.c"
72 //--- cdb.json.template
75 "directory": "DIR",
76 "command": "clang -fsyntax-only DIR/tu1.c -fmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache",
77 "file": "DIR/tu1.c"
80 "directory": "DIR",
81 "command": "clang -DFOO -fsyntax-only DIR/tu2.c -fmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache",
82 "file": "DIR/tu2.c"
85 "directory": "DIR",
86 "command": "clang -DFOO -fmodules-ignore-macro=FOO -fsyntax-only DIR/tu3.c -fmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache",
87 "file": "DIR/tu3.c"
91 //--- module.modulemap
92 module Mod { header "Mod.h" }
94 //--- Mod.h
96 //--- tu1.c
97 #include "Mod.h"
99 //--- tu2.c
100 #include "Mod.h"
102 //--- tu3.c
103 #include "Mod.h"