| 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 |
// This tests that we have two scanning module variants. |
| 12 |
// RUN: find %t/module-cache -name "*.pcm" | wc -l | grep 2 |
| 13 |
|
| 14 |
// Verify that there are only two variants and that the expected merges have |
| 15 |
// happened. |
| 16 |
|
| 17 |
// CHECK: { |
| 18 |
// CHECK-NEXT: "modules": [ |
| 19 |
// CHECK-NEXT: { |
| 20 |
// CHECK-NEXT: "clang-module-deps": [], |
| 21 |
// CHECK-NEXT: "clang-modulemap-file": |
| 22 |
// CHECK-NEXT: "command-line": [ |
| 23 |
// CHECK-NOT: "J=1" |
| 24 |
// CHECK-NOT: "J" |
| 25 |
// CHECK-NOT: "K" |
| 26 |
// CHECK: ], |
| 27 |
// CHECK-NEXT: "context-hash": "{{.*}}", |
| 28 |
// CHECK-NEXT: "file-deps": [ |
| 29 |
// CHECK: ], |
| 30 |
// CHECK-NEXT: "link-libraries": [], |
| 31 |
// CHECK-NEXT: "name": "A" |
| 32 |
// CHECK-NEXT: }, |
| 33 |
// CHECK-NEXT: { |
| 34 |
// CHECK-NEXT: "clang-module-deps": [], |
| 35 |
// CHECK-NEXT: "clang-modulemap-file": |
| 36 |
// CHECK-NEXT: "command-line": [ |
| 37 |
// CHECK: "Fඞ" |
| 38 |
// CHECK: 0D9E |
| 39 |
// CHECK: "K" |
| 40 |
// CHECK: "K" |
| 41 |
// CHECK: ], |
| 42 |
// CHECK-NEXT: "context-hash": "{{.*}}", |
| 43 |
// CHECK-NEXT: "file-deps": [ |
| 44 |
// CHECK: ], |
| 45 |
// CHECK-NEXT: "link-libraries": [], |
| 46 |
// CHECK-NEXT: "name": "A" |
| 47 |
// CHECK-NEXT: } |
| 48 |
// CHECK-NEXT: ], |
| 49 |
// CHECK-NEXT: "translation-units": [ |
| 50 |
// CHECK: ] |
| 51 |
// CHECK: } |
| 52 |
|
| 53 |
|
| 54 |
//--- build/compile-commands.json.in |
| 55 |
|
| 56 |
[ |
| 57 |
{ |
| 58 |
"directory": "DIR", |
| 59 |
"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", |
| 60 |
"file": "DIR/tu0.m" |
| 61 |
}, |
| 62 |
{ |
| 63 |
"directory": "DIR", |
| 64 |
"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", |
| 65 |
"file": "DIR/tu1.m" |
| 66 |
}, |
| 67 |
{ |
| 68 |
"directory": "DIR", |
| 69 |
"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", |
| 70 |
"file": "DIR/tu2.m" |
| 71 |
} |
| 72 |
] |
| 73 |
|
| 74 |
//--- modules/A/module.modulemap |
| 75 |
|
| 76 |
module A { |
| 77 |
umbrella header "A.h" |
| 78 |
} |
| 79 |
|
| 80 |
//--- modules/A/A.h |
| 81 |
|
| 82 |
//--- tu0.m |
| 83 |
|
| 84 |
#include <A.h> |
| 85 |
|
| 86 |
//--- tu1.m |
| 87 |
|
| 88 |
#include <A.h> |
| 89 |
|
| 90 |
//--- tu2.m |
| 91 |
|
| 92 |
#include <A.h> |