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: "-coverage-notes-file
27 // CHECK-NOT: "-coverage-data-file
28 // CHECK-NOT: "-dwarf-debug-flags"
29 // CHECK-NOT: "-main-file-name"
30 // CHECK-NOT: "-include"
31 // CHECK-NOT: "-fmodules-cache-path=
32 // CHECK-NOT: "-fmodules-validate-once-per-build-session"
33 // CHECK-NOT: "-fbuild-session-timestamp=
34 // CHECK-NOT: "-fmodules-prune-interval=
35 // CHECK-NOT: "-fmodules-prune-after=
37 // CHECK-NEXT: "context-hash": "[[HASH_MOD_HEADER:.*]]",
38 // CHECK-NEXT: "file-deps": [
39 // CHECK-NEXT: "[[PREFIX]]/mod_header.h",
40 // CHECK-NEXT: "[[PREFIX]]/module.modulemap"
42 // CHECK-NEXT: "name": "ModHeader"
45 // CHECK-NEXT: "clang-module-deps": [],
46 // CHECK-NEXT: "clang-modulemap-file": "[[PREFIX]]/module.modulemap",
47 // CHECK-NEXT: "command-line": [
49 // CHECK-NOT: "-fdebug-compilation-dir=
50 // CHECK-NOT: "-fcoverage-compilation-dir=
51 // CHECK-NOT: "-coverage-notes-file
52 // CHECK-NOT: "-coverage-data-file
53 // CHECK-NOT: "-dwarf-debug-flags"
54 // CHECK-NOT: "-main-file-name"
55 // CHECK-NOT: "-include"
56 // CHECK-NOT: "-fmodules-cache-path=
57 // CHECK-NOT: "-fmodules-validate-once-per-build-session"
58 // CHECK-NOT: "-fbuild-session-timestamp=
59 // CHECK-NOT: "-fmodules-prune-interval=
60 // CHECK-NOT: "-fmodules-prune-after=
62 // CHECK-NEXT: "context-hash": "[[HASH_MOD_TU:.*]]",
63 // CHECK-NEXT: "file-deps": [
64 // CHECK-NEXT: "[[PREFIX]]/mod_tu.h",
65 // CHECK-NEXT: "[[PREFIX]]/module.modulemap"
67 // CHECK-NEXT: "name": "ModTU"
70 // CHECK-NEXT: "translation-units": [
72 // CHECK: "clang-context-hash": "[[HASH_TU:.*]]",
73 // CHECK-NEXT: "clang-module-deps": [
75 // CHECK-NEXT: "context-hash": "[[HASH_MOD_HEADER]]",
76 // CHECK-NEXT: "module-name": "ModHeader"
79 // CHECK-NEXT: "context-hash": "[[HASH_MOD_TU]]",
80 // CHECK-NEXT: "module-name": "ModTU"
83 // CHECK-NEXT: "command-line": [
84 // CHECK-NEXT: "-cc1",
85 // CHECK-NOT: "-fmodules-cache-path=
86 // CHECK-NOT: "-fmodules-validate-once-per-build-session"
87 // CHECK-NOT: "-fbuild-session-timestamp=
88 // CHECK-NOT: "-fbuild-session-file=
89 // CHECK-NOT: "-fmodules-prune-interval=
90 // CHECK-NOT: "-fmodules-prune-after=