[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Modules / auto-import-unavailable.cpp
bloba35695d42a2b001fb69911f98eeadc8c43186169
1 // RUN: rm -rf %t
2 // RUN: not %clang_cc1 -x c++ -Rmodule-build -DMISSING_HEADER -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/auto-import-unavailable %s 2>&1 | FileCheck %s --check-prefix=MISSING-HEADER
3 // RUN: %clang_cc1 -x c++ -Rmodule-build -DNONREQUIRED_MISSING_HEADER -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/auto-import-unavailable %s 2>&1 | FileCheck %s --check-prefix=NONREQUIRED-MISSING-HEADER
4 // RUN: not %clang_cc1 -x c++ -Rmodule-build -DMISSING_REQUIREMENT -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs/auto-import-unavailable %s 2>&1 | FileCheck %s --check-prefix=MISSING-REQUIREMENT
6 #ifdef MISSING_HEADER
8 // Even if the header we ask for is not missing, if the top-level module
9 // containing it has a missing header, then the whole top-level is
10 // unavailable and we issue an error.
12 // MISSING-HEADER: module.modulemap:2:27: error: header 'missing_header/missing.h' not found
13 // MISSING-HEADER-DAG: auto-import-unavailable.cpp:[[@LINE+1]]:10: note: submodule of top-level module 'missing_header' implicitly imported here
14 #include "missing_header/not_missing.h"
16 // We should not attempt to build the module.
17 // MISSING-HEADER-NOT: remark: building module
19 #endif // #ifdef MISSING_HEADER
22 #ifdef NONREQUIRED_MISSING_HEADER
24 // However, if the missing header is dominated by an unsatisfied
25 // `requires`, then that is acceptable.
26 // This also tests that an unsatisfied `requires` elsewhere in the
27 // top-level module doesn't affect an available module.
29 // NONREQUIRED-MISSING-HEADER: auto-import-unavailable.cpp:[[@LINE+2]]:10: remark: building module 'nonrequired_missing_header'
30 // NONREQUIRED-MISSING-HEADER: auto-import-unavailable.cpp:[[@LINE+1]]:10: remark: finished building module 'nonrequired_missing_header'
31 #include "nonrequired_missing_header/not_missing.h"
33 #endif // #ifdef NONREQUIRED_MISSING_HEADER
36 #ifdef MISSING_REQUIREMENT
38 // If the header is unavailable due to a missing requirement, an error
39 // should be emitted if a user tries to include it.
41 // MISSING-REQUIREMENT:module.modulemap:16:8: error: module 'missing_requirement' requires feature 'nonexistent_feature'
42 // MISSING-REQUIREMENT: auto-import-unavailable.cpp:[[@LINE+1]]:10: note: submodule of top-level module 'missing_requirement' implicitly imported here
43 #include "missing_requirement.h"
45 // MISSING-REQUIREMENT-NOT: remark: building module
47 #endif // #ifdef MISSING_REQUIREMENT