| 1 |
// RUN: rm -rf %t |
| 2 |
// RUN: mkdir -p %t |
| 3 |
// RUN: split-file %s %t |
| 4 |
// RUN: cd %t |
| 5 |
// |
| 6 |
// RUN: %clang_cc1 -std=c++20 -xc++-user-header h1.h -emit-header-unit -o h1.pcm |
| 7 |
// RUN: %clang_cc1 -std=c++20 -xc++-user-header h2.h -emit-header-unit -o h2.pcm |
| 8 |
// RUN: %clang_cc1 -std=c++20 -xc++-user-header h3.h -emit-header-unit -o h3.pcm |
| 9 |
// RUN: %clang_cc1 -std=c++20 -xc++-user-header h4.h -emit-header-unit -o h4.pcm |
| 10 |
|
| 11 |
// RUN: %clang_cc1 -std=c++20 Xlate.cpp -o Xlate.pcm \ |
| 12 |
// RUN: -fmodule-file=h1.pcm -fmodule-file=h2.pcm -fmodule-file=h3.pcm \ |
| 13 |
// RUN: -fmodule-file=h4.pcm -fsyntax-only -Rmodule-include-translation -verify |
| 14 |
|
| 15 |
// Check that we do the intended translation and not more. |
| 16 |
// RUN: %clang_cc1 -std=c++20 Xlate.cpp \ |
| 17 |
// RUN: -fmodule-file=h1.pcm -fmodule-file=h2.pcm -fmodule-file=h3.pcm \ |
| 18 |
// RUN: -fmodule-file=h4.pcm -E -undef | FileCheck %s |
| 19 |
|
| 20 |
// We expect no diagnostics here, the used functions should all be available. |
| 21 |
// RUN: %clang_cc1 -std=c++20 Xlate.cpp \ |
| 22 |
// RUN: -fmodule-file=h1.pcm -fmodule-file=h2.pcm -fmodule-file=h3.pcm \ |
| 23 |
// RUN: -fmodule-file=h4.pcm -fsyntax-only |
| 24 |
|
| 25 |
// The content of the headers is not terribly important, we just want to check |
| 26 |
// whether they are textually included or include-translated. |
| 27 |
//--- h1.h |
| 28 |
#ifndef H1_GUARD |
| 29 |
#define H1_GUARD |
| 30 |
|
| 31 |
#define ONE 1 |
| 32 |
|
| 33 |
void foo(); |
| 34 |
|
| 35 |
#endif // H1_GUARD |
| 36 |
|
| 37 |
//--- h2.h |
| 38 |
#ifndef H2_GUARD |
| 39 |
#define H2_GUARD |
| 40 |
|
| 41 |
#define TWO 2 |
| 42 |
|
| 43 |
void bar(); |
| 44 |
|
| 45 |
#endif // H2_GUARD |
| 46 |
|
| 47 |
//--- h3.h |
| 48 |
#ifndef H3_GUARD |
| 49 |
#define H3_GUARD |
| 50 |
|
| 51 |
#define THREE 3 |
| 52 |
|
| 53 |
void baz(); |
| 54 |
|
| 55 |
#endif // H3_GUARD |
| 56 |
|
| 57 |
//--- h4.h |
| 58 |
#ifndef H4_GUARD |
| 59 |
#define H4_GUARD |
| 60 |
|
| 61 |
#define FOUR 4 |
| 62 |
|
| 63 |
void boo(); |
| 64 |
|
| 65 |
#endif // H4_GUARD |
| 66 |
|
| 67 |
//--- h5.h |
| 68 |
#ifndef H5_GUARD |
| 69 |
#define H5_GUARD |
| 70 |
|
| 71 |
#define FIVE 5 |
| 72 |
|
| 73 |
void five(); |
| 74 |
|
| 75 |
#endif // H4_GUARD |
| 76 |
|
| 77 |
//--- Xlate.cpp |
| 78 |
/* some comment ... |
| 79 |
... */ |
| 80 |
module /*nothing here*/; |
| 81 |
|
| 82 |
// This should be include-translated, when the header unit for h1 is available. |
| 83 |
// expected-warning@+1 {{the implementation of header units is in an experimental phase}} |
| 84 |
#include "h1.h" // expected-remark-re {{treating #include as an import of module '.{{/|\\\\?}}h1.h'}} |
| 85 |
// Import of a header unit is allowed, named modules are not. |
| 86 |
import "h2.h"; // expected-warning {{the implementation of header units is in an experimental phase}} |
| 87 |
// A regular, untranslated, header |
| 88 |
#include "h5.h" |
| 89 |
|
| 90 |
export module Xlate; |
| 91 |
|
| 92 |
// This is OK, the import immediately follows the module decl. |
| 93 |
import "h3.h"; // expected-warning {{the implementation of header units is in an experimental phase}} |
| 94 |
|
| 95 |
// This should *not* be include-translated, even if header unit for h4 is |
| 96 |
// available. |
| 97 |
#include "h4.h" |
| 98 |
|
| 99 |
export void charlie() { |
| 100 |
foo(); |
| 101 |
bar(); |
| 102 |
baz(); |
| 103 |
boo(); |
| 104 |
five(); |
| 105 |
} |
| 106 |
|
| 107 |
// CHECK: #pragma clang module import ".{{/|\\\\?}}h1.h" |
| 108 |
// CHECK: import ".{{/|\\\\?}}h2.h" |
| 109 |
// CHECK: import ".{{/|\\\\?}}h3.h" |
| 110 |
// CHECK-NOT: #pragma clang module import ".{{/|\\\\?}}h4.h" |