xref: /llvm-project/clang/test/ClangScanDeps/strip-codegen-args.m (revision c5a33befcc328339a84c35f6899ff3f3309399fc)
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:            ]
20// CHECK:            "name": "A"
21// CHECK:          }
22// CHECK-NOT:        "name": "A"
23// CHECK:        "translation-units"
24
25//--- cdb1.json.template
26[
27  {
28    "directory": "DIR",
29    "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",
30    "file": "DIR/t1.m"
31  },
32  {
33    "directory": "DIR",
34    "command": "clang -Imodules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -O2 -flto=thin -fautolink -fsyntax-only DIR/t2.m",
35    "file": "DIR/t2.m"
36  },
37  {
38    "directory": "DIR",
39    "command": "clang -Imodules/A -fmodules -fmodules-cache-path=DIR/module-cache -fimplicit-modules -O2 -flto=full -fsyntax-only DIR/t3.m",
40    "file": "DIR/t2.m"
41  }
42]
43
44//--- modules/A/module.modulemap
45
46module A {
47  umbrella header "A.h"
48}
49
50//--- modules/A/A.h
51
52typedef int A_t;
53
54//--- t1.m
55@import A;
56
57//--- t2.m
58@import A;
59
60//--- t3.m
61@import A;
62