[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Modules / submodule-visibility-pch.c
blob648f756fb971337e11ca2aa710e172a28947d1e1
1 // Verify that the use of a PCH does not accidentally make modules from the PCH
2 // visible to submodules when using -fmodules-local-submodule-visibility
3 // and -fmodule-name to trigger a textual include.
5 // RUN: rm -rf %t
6 // RUN: split-file %s %t
8 // First check that it works with a header
10 // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache \
11 // RUN: -fmodules-local-submodule-visibility -fimplicit-module-maps \
12 // RUN: -fmodule-name=Mod \
13 // RUN: %t/tu.c -include %t/prefix.h -I %t -verify
15 // Now with a PCH
17 // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache \
18 // RUN: -fmodules-local-submodule-visibility -fimplicit-module-maps \
19 // RUN: -x c-header %t/prefix.h -emit-pch -o %t/prefix.pch -I %t
21 // RUN: %clang_cc1 -fmodules -fmodules-cache-path=%t/cache \
22 // RUN: -fmodules-local-submodule-visibility -fimplicit-module-maps \
23 // RUN: -fmodule-name=Mod \
24 // RUN: %t/tu.c -include-pch %t/prefix.pch -I %t -verify
26 //--- module.modulemap
27 module ModViaPCH { header "ModViaPCH.h" }
28 module ModViaInclude { header "ModViaInclude.h" }
29 module Mod { header "Mod.h" }
30 module SomeOtherMod { header "SomeOtherMod.h" }
32 //--- ModViaPCH.h
33 #define ModViaPCH 1
35 //--- ModViaInclude.h
36 #define ModViaInclude 2
38 //--- SomeOtherMod.h
39 // empty
41 //--- Mod.h
42 #include "SomeOtherMod.h"
43 #ifdef ModViaPCH
44 #error "Visibility violation ModViaPCH"
45 #endif
46 #ifdef ModViaInclude
47 #error "Visibility violation ModViaInclude"
48 #endif
50 //--- prefix.h
51 #include "ModViaPCH.h"
53 //--- tu.c
54 #include "ModViaInclude.h"
55 #include "Mod.h"
56 // expected-no-diagnostics