Debian Codegraph @

clang/test/ClangScanDeps/optimize-canonicalize-macros.m

raw
1 // This test verifies that command lines with equivalent -D and -U arguments
2 // are canonicalized to the same module variant.
3
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
10
11 // Verify that there are only two variants and that the expected merges have
12 // happened.
13
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: }
49
50
51 //--- build/compile-commands.json.in
52
53 [
54 {
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"
58 },
59 {
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"
63 },
64 {
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"
68 }
69 ]
70
71 //--- modules/A/module.modulemap
72
73 module A {
74 umbrella header "A.h"
75 }
76
77 //--- modules/A/A.h
78
79 //--- tu0.m
80
81 #include <A.h>
82
83 //--- tu1.m
84
85 #include <A.h>
86
87 //--- tu2.m
88
89 #include <A.h>