Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / clang / test / ClangScanDeps / modules-symlink-dir.c
blob810b88942d2aab8ad055e6b9fdbda207df50cd85
1 // Check that we canonicalize the module map path without changing the module
2 // directory, which would break header lookup.
4 // REQUIRES: shell
6 // RUN: rm -rf %t
7 // RUN: split-file %s %t
8 // RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.in > %t/cdb.json
9 // RUN: ln -s module %t/symlink-to-module
10 // RUN: ln -s ../actual.modulemap %t/module/module.modulemap
11 // RUN: ln -s A %t/module/F.framework/Versions/Current
12 // RUN: ln -s Versions/Current/Modules %t/module/F.framework/Modules
13 // RUN: ln -s Versions/Current/Headers %t/module/F.framework/Headers
15 // RUN: clang-scan-deps -compilation-database %t/cdb.json -j 1 \
16 // RUN: -format experimental-full -mode=preprocess-dependency-directives \
17 // RUN: -optimize-args -module-files-dir %t/build > %t/deps.json
19 // RUN: cat %t/deps.json | sed 's:\\\\\?:/:g' | FileCheck -DPREFIX=%/t %s
21 // Check the module commands actually build.
22 // RUN: %deps-to-rsp %t/deps.json --module-name=Mod > %t/Mod.rsp
23 // RUN: %deps-to-rsp %t/deps.json --module-name=F > %t/F.rsp
24 // RUN: %clang @%t/Mod.rsp
25 // RUN: %clang @%t/F.rsp
27 // CHECK: "modules": [
28 // CHECK: {
29 // CHECK: "clang-module-deps": [],
30 // CHECK: "clang-modulemap-file": "[[PREFIX]]/module/F.framework/Modules/module.modulemap"
31 // CHECK: "command-line": [
32 // CHECK-NOT: symlink-to-module
33 // CHECK: "[[PREFIX]]/module/F.framework/Modules/module.modulemap"
34 // CHECK-NOT: symlink-to-module
35 // CHECK: ]
36 // CHECK: "context-hash": "[[F_CONTEXT_HASH:[A-Z0-9]+]]"
37 // CHECK: "name": "F"
38 // CHECK-NEXT: }
39 // CHECK-NEXT: {
40 // CHECK: "clang-modulemap-file": "[[PREFIX]]/module/module.modulemap"
41 // CHECK: "command-line": [
42 // CHECK-NOT: symlink-to-module
43 // CHECK: "[[PREFIX]]/module/module.modulemap"
44 // CHECK-NOT: symlink-to-module
45 // CHECK: ]
46 // CHECK: "context-hash": "[[CONTEXT_HASH:[A-Z0-9]+]]"
47 // CHECK: "name": "Mod"
48 // CHECK-NEXT: }
49 // CHECK-NEXT: ]
50 // CHECK: "translation-units": [
51 // CHECK: "clang-module-deps": [
52 // CHECK: {
53 // CHECK: "context-hash": "[[CONTEXT_HASH]]"
54 // CHECK: "module-name": "Mod"
55 // CHECK: }
56 // CHECK-NEXT: ],
57 // CHECK: "command-line": [
58 // CHECK: "-fmodule-map-file=[[PREFIX]]/module/module.modulemap"
59 // CHECK: ]
60 // CHECK: "clang-module-deps": [
61 // CHECK: {
62 // CHECK: "context-hash": "[[CONTEXT_HASH]]"
63 // CHECK: "module-name": "Mod"
64 // CHECK: }
65 // CHECK-NEXT: ]
66 // CHECK: "command-line": [
67 // CHECK: "-fmodule-map-file=[[PREFIX]]/module/module.modulemap"
68 // CHECK: ]
69 // CHECK: "clang-module-deps": [
70 // CHECK: {
71 // CHECK: "context-hash": "[[F_CONTEXT_HASH]]"
72 // CHECK: "module-name": "F"
73 // CHECK: }
74 // CHECK-NEXT: ]
75 // CHECK: "command-line": [
76 // CHECK: "-fmodule-map-file=[[PREFIX]]/module/F.framework/Modules/module.modulemap"
77 // CHECK: ]
78 // CHECK: "clang-module-deps": [
79 // CHECK: {
80 // CHECK: "context-hash": "[[F_CONTEXT_HASH]]"
81 // CHECK: "module-name": "F"
82 // CHECK: }
83 // CHECK-NEXT: ]
84 // CHECK: "command-line": [
85 // CHECK: "-fmodule-map-file=[[PREFIX]]/module/F.framework/Modules/module.modulemap"
86 // CHECK: ]
88 //--- cdb.json.in
91 "directory": "DIR",
92 "command": "clang -fsyntax-only DIR/tu1.c -fmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache",
93 "file": "DIR/tu1.c"
96 "directory": "DIR",
97 "command": "clang -fsyntax-only DIR/tu2.c -fmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache",
98 "file": "DIR/tu2.c"
101 "directory": "DIR",
102 "command": "clang -fsyntax-only -F DIR/symlink-to-module DIR/tu3.c -fmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache",
103 "file": "DIR/tu3.c"
106 "directory": "DIR",
107 "command": "clang -fsyntax-only -F DIR/module DIR/tu3.c -fmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache",
108 "file": "DIR/tu3.c"
112 //--- actual.modulemap
113 module Mod { header "header.h" }
115 //--- module/header.h
117 //--- tu1.c
118 #include "symlink-to-module/header.h"
120 //--- tu2.c
121 #include "module/header.h"
123 //--- module/F.framework/Versions/A/Modules/module.modulemap
124 framework module F {
125 umbrella header "F.h"
128 //--- module/F.framework/Versions/A/Headers/F.h
130 //--- tu3.c
131 #include "F/F.h"