1 // Some command-line arguments used for compiling translation units are not
2 // compatible with the semantics of modules or are likely to differ between
3 // identical modules discovered from different translation units. This test
4 // checks such arguments are removed from the command-lines: '-include',
5 // '-dwarf-debug-flag' and '-main-file-name'. Similarly, several arguments
6 // such as '-fmodules-cache-path=' are only relevant for implicit modules, and
7 // are removed to better-canonicalize the compilation.
9 // RUN: rm -rf %t && mkdir %t
10 // RUN: cp %S/Inputs/removed-args/* %t
11 // RUN: touch %t/build-session
13 // RUN: sed "s|DIR|%/t|g" %S/Inputs/removed-args/cdb.json.template > %t/cdb.json
14 // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full > %t/result.json
15 // RUN: cat %t/result.json | sed 's:\\\\\?:/:g' | FileCheck %s -DPREFIX=%/t
18 // CHECK-NEXT: "modules": [
20 // CHECK-NEXT: "clang-module-deps": [],
21 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
22 // CHECK-NEXT: "command-line": [
24 // CHECK-NOT: "-fdebug-compilation-dir="
25 // CHECK-NOT: "-fcoverage-compilation-dir="
26 // CHECK-NOT: "-dwarf-debug-flags"
27 // CHECK-NOT: "-main-file-name"
28 // CHECK-NOT: "-include"
29 // CHECK-NOT: "-fmodules-cache-path=
30 // CHECK-NOT: "-fmodules-validate-once-per-build-session"
31 // CHECK-NOT: "-fbuild-session-timestamp=
32 // CHECK-NOT: "-fmodules-prune-interval=
33 // CHECK-NOT: "-fmodules-prune-after=
35 // CHECK-NEXT: "context-hash": "[[HASH_MOD_HEADER:.*]]",
36 // CHECK-NEXT: "file-deps": [
37 // CHECK-NEXT: "[[PREFIX]]/mod_header.h",
38 // CHECK-NEXT: "[[PREFIX]]/module.modulemap"
40 // CHECK-NEXT: "name": "ModHeader"
43 // CHECK-NEXT: "clang-module-deps": [],
44 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
45 // CHECK-NEXT: "command-line": [
47 // CHECK-NOT: "-fdebug-compilation-dir=
48 // CHECK-NOT: "-fcoverage-compilation-dir=
49 // CHECK-NOT: "-dwarf-debug-flags"
50 // CHECK-NOT: "-main-file-name"
51 // CHECK-NOT: "-include"
52 // CHECK-NOT: "-fmodules-cache-path=
53 // CHECK-NOT: "-fmodules-validate-once-per-build-session"
54 // CHECK-NOT: "-fbuild-session-timestamp=
55 // CHECK-NOT: "-fmodules-prune-interval=
56 // CHECK-NOT: "-fmodules-prune-after=
58 // CHECK-NEXT: "context-hash": "[[HASH_MOD_TU:.*]]",
59 // CHECK-NEXT: "file-deps": [
60 // CHECK-NEXT: "[[PREFIX]]/mod_tu.h",
61 // CHECK-NEXT: "[[PREFIX]]/module.modulemap"
63 // CHECK-NEXT: "name": "ModTU"
66 // CHECK-NEXT: "translation-units": [
68 // CHECK: "clang-context-hash": "[[HASH_TU:.*]]",
69 // CHECK-NEXT: "clang-module-deps": [
71 // CHECK-NEXT: "context-hash": "[[HASH_MOD_HEADER]]",
72 // CHECK-NEXT: "module-name": "ModHeader"
75 // CHECK-NEXT: "context-hash": "[[HASH_MOD_TU]]",
76 // CHECK-NEXT: "module-name": "ModTU"
79 // CHECK-NEXT: "command-line": [
80 // CHECK-NEXT: "-cc1",
81 // CHECK-NOT: "-fmodules-cache-path=
82 // CHECK-NOT: "-fmodules-validate-once-per-build-session"
83 // CHECK-NOT: "-fbuild-session-timestamp=
84 // CHECK-NOT: "-fbuild-session-file=
85 // CHECK-NOT: "-fmodules-prune-interval=
86 // CHECK-NOT: "-fmodules-prune-after=