[clang] Implement lifetime analysis for lifetime_capture_by(X) (#115921)
[llvm-project.git] / clang / test / Modules / extensions.c
blob1858f02e681a2bda4ab948677fe863a6cbf9438e
1 // Test creation of modules that include extension blocks.
2 // RUN: rm -rf %t
3 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -ftest-module-file-extension=clang.testA:1:5:0:user_info_for_A -ftest-module-file-extension=clang.testB:2:3:0:user_info_for_B -fmodules-cache-path=%t -I %S/Inputs %s
5 // Make sure the extension blocks are actually there.
6 // RUN: llvm-bcanalyzer %t/ExtensionTestA.pcm | FileCheck -check-prefix=CHECK-BCANALYZER %s
7 // RUN: %clang_cc1 -module-file-info %t/ExtensionTestA.pcm | FileCheck -check-prefix=CHECK-INFO %s
9 // Make sure that the readers are able to check the metadata.
10 // RUN: rm -rf %t
11 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -ftest-module-file-extension=clang.testA:1:5:0:user_info_for_A -ftest-module-file-extension=clang.testB:2:3:0:user_info_for_B -fmodules-cache-path=%t -I %S/Inputs %s
12 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -ftest-module-file-extension=clang.testA:1:3:0:user_info_for_A -ftest-module-file-extension=clang.testB:3:2:0:user_info_for_B -fmodules-cache-path=%t -I %S/Inputs %s -verify
14 // Make sure that extension blocks can be part of the module hash.
15 // We test this in an obscure way, by making sure we don't get conflicts when
16 // using different "versions" of the extensions. Above, the "-verify" test
17 // checks that such conflicts produce errors.
18 // RUN: rm -rf %t
19 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -ftest-module-file-extension=clang.testA:1:5:1:user_info_for_A -ftest-module-file-extension=clang.testB:2:3:1:user_info_for_B -fmodules-cache-path=%t -I %S/Inputs %s
20 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -ftest-module-file-extension=clang.testA:1:3:1:user_info_for_A -ftest-module-file-extension=clang.testB:3:2:1:user_info_for_B -fmodules-cache-path=%t -I %S/Inputs %s
21 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -ftest-module-file-extension=clang.testA:2:5:0:user_info_for_A -ftest-module-file-extension=clang.testB:7:3:0:user_info_for_B -fmodules-cache-path=%t -I %S/Inputs %s
23 // Make sure we can read the message back.
24 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -ftest-module-file-extension=clang.testA:1:5:0:user_info_for_A -ftest-module-file-extension=clang.testB:2:3:0:user_info_for_B -fmodules-cache-path=%t -I %S/Inputs %s > %t.log 2>&1
25 // RUN: FileCheck -check-prefix=CHECK-MESSAGE %s < %t.log
27 // Make sure we diagnose duplicate module file extensions.
28 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fdisable-module-hash -ftest-module-file-extension=clang.testA:1:5:0:user_info_for_A -ftest-module-file-extension=clang.testA:1:5:0:user_info_for_A -fmodules-cache-path=%t -I %S/Inputs %s > %t.log 2>&1
29 // RUN: FileCheck -check-prefix=CHECK-DUPLICATE %s < %t.log
31 #include "ExtensionTestA.h"
32 // expected-error@-1{{test module file extension 'clang.testA' has different version (1.5) than expected (1.3)}}
33 // expected-error@-2{{test module file extension 'clang.testB' has different version (2.3) than expected (3.2)}}
35 // CHECK-BCANALYZER: {{Block ID.*EXTENSION_BLOCK}}
36 // CHECK-BCANALYZER: {{100.00.*EXTENSION_METADATA}}
38 // CHECK-INFO: Module file extension 'clang.testA' 1.5: user_info_for_A
39 // CHECK-INFO: Module file extension 'clang.testB' 2.3: user_info_for_B
41 // CHECK-MESSAGE: Read extension block message: Hello from clang.testA v1.5
42 // CHECK-MESSAGE: Read extension block message: Hello from clang.testB v2.3
44 // CHECK-DUPLICATE: warning: duplicate module file extension block name 'clang.testA'