xref: /llvm-project/clang/test/ClangScanDeps/modules-symlink.c (revision 64e4d03c681a1c43ec22aee9ce32b784ed5aee9c)
18cc2a137SJan Svoboda // RUN: rm -rf %t
28cc2a137SJan Svoboda // RUN: split-file %s %t
3760e6922SSteven Wan // Unsupported on AIX because we don't support the requisite "__clangast"
4760e6922SSteven Wan // section in XCOFF yet.
5*64e4d03cSPaul Robinson // UNSUPPORTED: system-windows, target={{.*}}-aix{{.*}}
68cc2a137SJan Svoboda 
78cc2a137SJan Svoboda //--- cdb_pch.json
88cc2a137SJan Svoboda [
98cc2a137SJan Svoboda   {
108cc2a137SJan Svoboda     "directory": "DIR",
118cc2a137SJan Svoboda     "command": "clang -x c-header DIR/pch.h -fmodules -gmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -o DIR/pch.h.gch",
128cc2a137SJan Svoboda     "file": "DIR/pch.h"
138cc2a137SJan Svoboda   }
148cc2a137SJan Svoboda ]
158cc2a137SJan Svoboda 
168cc2a137SJan Svoboda //--- cdb_tu.json
178cc2a137SJan Svoboda [
188cc2a137SJan Svoboda   {
198cc2a137SJan Svoboda     "directory": "DIR",
208cc2a137SJan Svoboda     "command": "clang -c DIR/tu.c -fmodules -gmodules -fimplicit-module-maps -fmodules-cache-path=DIR/cache -include DIR/pch.h -o DIR/tu.o",
218cc2a137SJan Svoboda     "file": "DIR/tu.c"
228cc2a137SJan Svoboda   }
238cc2a137SJan Svoboda ]
248cc2a137SJan Svoboda 
258cc2a137SJan Svoboda //--- module.modulemap
268cc2a137SJan Svoboda module mod { header "symlink.h" }
278cc2a137SJan Svoboda 
288cc2a137SJan Svoboda //--- pch.h
298cc2a137SJan Svoboda #include "symlink.h"
308cc2a137SJan Svoboda 
318cc2a137SJan Svoboda //--- original.h
328cc2a137SJan Svoboda // Comment that will be stripped by the minimizer.
338cc2a137SJan Svoboda #define MACRO 1
348cc2a137SJan Svoboda 
358cc2a137SJan Svoboda //--- tu.c
368cc2a137SJan Svoboda #include "original.h"
378cc2a137SJan Svoboda static int foo = MACRO; // Macro usage that will trigger
388cc2a137SJan Svoboda                         // input file consistency checks.
398cc2a137SJan Svoboda 
408cc2a137SJan Svoboda // RUN: ln -s %t/original.h %t/symlink.h
418cc2a137SJan Svoboda 
428cc2a137SJan Svoboda // RUN: sed -e "s|DIR|%/t|g" %t/cdb_pch.json > %t/cdb.json
438cc2a137SJan Svoboda // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \
4471e32d5cSJan Svoboda // RUN:   -module-files-dir %t/build > %t/result_pch.json
458cc2a137SJan Svoboda //
4626053ce0SJan Svoboda // RUN: %deps-to-rsp %t/result_pch.json --module-name=mod > %t/mod.cc1.rsp
4726053ce0SJan Svoboda // RUN: %deps-to-rsp %t/result_pch.json --tu-index=0 > %t/pch.rsp
488cc2a137SJan Svoboda //
498cc2a137SJan Svoboda // RUN: %clang @%t/mod.cc1.rsp
5019017c24SJan Svoboda // RUN: %clang @%t/pch.rsp
518cc2a137SJan Svoboda 
528cc2a137SJan Svoboda // RUN: sed -e "s|DIR|%/t|g" %t/cdb_tu.json > %t/cdb.json
538cc2a137SJan Svoboda // RUN: clang-scan-deps -compilation-database %t/cdb.json -format experimental-full \
5471e32d5cSJan Svoboda // RUN:   -module-files-dir %t/build > %t/result_tu.json
55