Fix some typos (#123506)
[llvm-project.git] / clang / test / ClangScanDeps / optimize-canonicalize-macros.m
blob46ae1c84ec7ba6fcb346e6c8d4ffd83b5ff63a2a
1 // This test verifies that command lines with equivalent -D and -U arguments
2 // are canonicalized to the same module variant.
4 // RUN: rm -rf %t
5 // RUN: split-file %s %t
6 // RUN: sed -e "s|DIR|%/t|g" %t/build/compile-commands.json.in > %t/build/compile-commands.json
7 // RUN: clang-scan-deps -compilation-database %t/build/compile-commands.json \
8 // RUN:   -j 1 -format experimental-full -optimize-args=canonicalize-macros > %t/deps.db
9 // RUN: cat %t/deps.db | FileCheck %s -DPREFIX=%/t
11 // Verify that there are only two variants and that the expected merges have
12 // happened.
14 // CHECK:      {
15 // CHECK-NEXT:   "modules": [
16 // CHECK-NEXT:     {
17 // CHECK-NEXT:       "clang-module-deps": [],
18 // CHECK-NEXT:       "clang-modulemap-file":
19 // CHECK-NEXT:       "command-line": [
20 // CHECK-NOT:          "J=1"
21 // CHECK-NOT:          "J"
22 // CHECK-NOT:          "K"
23 // CHECK:            ],
24 // CHECK-NEXT:       "context-hash": "{{.*}}",
25 // CHECK-NEXT:       "file-deps": [
26 // CHECK:            ],
27 // CHECK-NEXT:       "link-libraries": [],
28 // CHECK-NEXT:       "name": "A"
29 // CHECK-NEXT:     },
30 // CHECK-NEXT:     {
31 // CHECK-NEXT:       "clang-module-deps": [],
32 // CHECK-NEXT:       "clang-modulemap-file":
33 // CHECK-NEXT:       "command-line": [
34 // CHECK:              "Fඞ"
35 // CHECK:              0D9E
36 // CHECK:              "K"
37 // CHECK:              "K"
38 // CHECK:            ],
39 // CHECK-NEXT:       "context-hash": "{{.*}}",
40 // CHECK-NEXT:       "file-deps": [
41 // CHECK:            ],
42 // CHECK-NEXT:       "link-libraries": [],
43 // CHECK-NEXT:       "name": "A"
44 // CHECK-NEXT:     }
45 // CHECK-NEXT:   ],
46 // CHECK-NEXT:   "translation-units": [
47 // CHECK:        ]
48 // CHECK:      }
51 //--- build/compile-commands.json.in
55   "directory": "DIR",
56   "command": "clang -c DIR/tu0.m -DJ=1 -UJ -DJ=2 -DI -DK(x)=x -I modules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-module-maps",
57   "file": "DIR/tu0.m"
60   "directory": "DIR",
61   "command": "clang -c DIR/tu1.m -DK -DK(x)=x -DI -D \"J=2\" -I modules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-module-maps",
62   "file": "DIR/tu1.m"
65   "directory": "DIR",
66   "command": "clang -c DIR/tu2.m -I modules/A -DFඞ \"-DF\\\\u{0D9E}\" -DK -DK -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-module-maps",
67   "file": "DIR/tu2.m"
71 //--- modules/A/module.modulemap
73 module A {
74   umbrella header "A.h"
77 //--- modules/A/A.h
79 //--- tu0.m
81 #include <A.h>
83 //--- tu1.m
85 #include <A.h>
87 //--- tu2.m
89 #include <A.h>