111 lines · cpp
1// RUN: rm -rf %t2// RUN: mkdir -p %t3// RUN: split-file %s %t4// RUN: cd %t5//6// RUN: %clang_cc1 -std=c++20 -xc++-user-header h1.h -emit-header-unit -o h1.pcm7// RUN: %clang_cc1 -std=c++20 -xc++-user-header h2.h -emit-header-unit -o h2.pcm8// RUN: %clang_cc1 -std=c++20 -xc++-user-header h3.h -emit-header-unit -o h3.pcm9// RUN: %clang_cc1 -std=c++20 -xc++-user-header h4.h -emit-header-unit -o h4.pcm10 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 -verify14 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 %s19 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-only24 25// The content of the headers is not terribly important, we just want to check26// whether they are textually included or include-translated.27//--- h1.h28#ifndef H1_GUARD29#define H1_GUARD30 31#define ONE 132 33void foo();34 35#endif // H1_GUARD36 37//--- h2.h38#ifndef H2_GUARD39#define H2_GUARD40 41#define TWO 242 43void bar();44 45#endif // H2_GUARD46 47//--- h3.h48#ifndef H3_GUARD49#define H3_GUARD50 51#define THREE 352 53void baz();54 55#endif // H3_GUARD56 57//--- h4.h58#ifndef H4_GUARD59#define H4_GUARD60 61#define FOUR 462 63void boo();64 65#endif // H4_GUARD66 67//--- h5.h68#ifndef H5_GUARD69#define H5_GUARD70 71#define FIVE 572 73void five();74 75#endif // H4_GUARD76 77//--- Xlate.cpp78/* some comment ...79 ... */80module /*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.86import "h2.h"; // expected-warning {{the implementation of header units is in an experimental phase}}87// A regular, untranslated, header88#include "h5.h"89 90export module Xlate;91 92// This is OK, the import immediately follows the module decl.93import "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 is96// available.97#include "h4.h"98 99export 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"111