| 1 |
// RUN: rm -rf %t |
| 2 |
// RUN: split-file %s %t |
| 3 |
// RUN: sed -e "s|DIR|%/t|g" %t/cdb1.json.template > %t/cdb1.json |
| 4 |
|
| 5 |
// RUN: clang-scan-deps -compilation-database %t/cdb1.json -format experimental-full > %t/result1.txt |
| 6 |
// RUN: FileCheck %s -input-file %t/result1.txt |
| 7 |
|
| 8 |
// This tests that codegen option that do not affect the AST or generation of a |
| 9 |
// module are removed. It also tests that the optimization options that affect |
| 10 |
// the AST are not reset to -O0. |
| 11 |
|
| 12 |
// CHECK: "modules": [ |
| 13 |
// CHECK-NEXT: { |
| 14 |
// CHECK: "command-line": [ |
| 15 |
// CHECK-NOT: "-O0" |
| 16 |
// CHECK-NOT: "-flto" |
| 17 |
// CHECK-NOT: "-fno-autolink" |
| 18 |
// CHECK-NOT: "-mrelax-relocations=no" |
| 19 |
// CHECK-NOT: "-mspeculative-load-hardening" |
| 20 |
// CHECK: ] |
| 21 |
// CHECK: "name": "A" |
| 22 |
// CHECK: } |
| 23 |
// CHECK-NOT: "name": "A" |
| 24 |
// CHECK: "translation-units" |
| 25 |
|
| 26 |
//--- cdb1.json.template |
| 27 |
[ |
| 28 |
{ |
| 29 |
"directory": "DIR", |
| 30 |
"command": "clang -Imodules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -O2 -flto -fno-autolink -Xclang -mrelax-relocations=no -fsyntax-only DIR/t1.m", |
| 31 |
"file": "DIR/t1.m" |
| 32 |
}, |
| 33 |
{ |
| 34 |
"directory": "DIR", |
| 35 |
"command": "clang -Imodules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -O2 -flto=thin -fautolink -fsyntax-only DIR/t2.m", |
| 36 |
"file": "DIR/t2.m" |
| 37 |
}, |
| 38 |
{ |
| 39 |
"directory": "DIR", |
| 40 |
"command": "clang -Imodules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -O2 -flto=full -fsyntax-only DIR/t3.m", |
| 41 |
"file": "DIR/t2.m" |
| 42 |
} |
| 43 |
{ |
| 44 |
"directory": "DIR", |
| 45 |
"command": "clang -Imodules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -O2 -mspeculative-load-hardening -fsyntax-only DIR/t3.m", |
| 46 |
"file": "DIR/t3.m" |
| 47 |
} |
| 48 |
] |
| 49 |
|
| 50 |
//--- modules/A/module.modulemap |
| 51 |
|
| 52 |
module A { |
| 53 |
umbrella header "A.h" |
| 54 |
} |
| 55 |
|
| 56 |
//--- modules/A/A.h |
| 57 |
|
| 58 |
typedef int A_t; |
| 59 |
|
| 60 |
//--- t1.m |
| 61 |
@import A; |
| 62 |
|
| 63 |
//--- t2.m |
| 64 |
@import A; |
| 65 |
|
| 66 |
//--- t3.m |
| 67 |
@import A; |