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