Clang Project

clang_source_code/test/Modules/extensions.c
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
4
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
8
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
13
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
22
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
26
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
30
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)}}
34
35// CHECK-BCANALYZER: {{Block ID.*EXTENSION_BLOCK}}
36// CHECK-BCANALYZER: {{100.00.*EXTENSION_METADATA}}
37
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
40
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
43
44// CHECK-DUPLICATE: warning: duplicate module file extension block name 'clang.testA'
45