98 lines · cpp
1// RUN: rm -rf %t2// RUN: mkdir -p %t3// RUN: split-file %s %t4// RUN: cd %t5//6// RUN: %clang_cc1 -fmodule-name=A -fno-cxx-modules -emit-module -fmodules -xc++ A.cppmap -o A.pcm7// RUN: %clang_cc1 -fmodule-name=B -fno-cxx-modules -emit-module -fmodules -xc++ B.cppmap -o B.pcm -fmodule-file=A.pcm8// RUN: %clang_cc1 -fmodule-name=C -fno-cxx-modules -emit-module -fmodules -xc++ C.cppmap -o C.pcm -fmodule-file=A.pcm9// RUN: %clang_cc1 -fmodule-name=D -fno-cxx-modules -emit-module -fmodules -xc++ D.cppmap -o D.pcm -fmodule-file=A.pcm10// RUN: %clang_cc1 -fmodule-name=E -fno-cxx-modules -emit-module -fmodules -xc++ E.cppmap -o E.pcm -fmodule-file=D.pcm -fmodule-file=B.pcm -fmodule-file=C.pcm11// RUN: %clang_cc1 -fno-cxx-modules -fmodules -fmodule-file=B.pcm -fmodule-file=E.pcm -emit-llvm -o /dev/null S.cpp12 13//--- A.h14namespace std {15 16template <class T> void zz(T);17 18template <class> struct vec {19 struct w {};20 struct xx {};21 22 vec(vec &) { init(); }23 constexpr vec &operator=(const vec &);24 template <class U> constexpr void pb(U);25 constexpr void init();26 27 w s;28};29 30template <class T> constexpr void vec<T>::init() {31 xx yy;32 zz(yy);33}34 35template <class T> constexpr vec<T> &vec<T>::operator=(const vec &) {36 pb(s);37 return *this;38}39 40template <class T> template <class U> constexpr void vec<T>::pb(U) { init(); }41} // namespace std42 43//--- A.cppmap44module "A" {45 header "A.h"46}47 48//--- X.h49#pragma clang module import A50 51namespace project {52 class thing : std::vec<thing> {};53} // namespace project54 55//--- B.h56#include "X.h"57 58//--- B.cppmap59module "B" {60 header "B.h"61}62 63//--- C.h64#include "X.h"65 66//--- C.cppmap67module "C" {68 header "C.h"69}70 71//--- D.h72#include "X.h"73 74//--- D.cppmap75module "D" {76 header "D.h"77}78 79//--- Y.h80#include "X.h"81struct other {82 other() : data(data) {}83 std::vec<project::thing> data;84};85 86//--- E.h87#include "Y.h"88 89//--- E.cppmap90module "E" {91 header "E.h"92}93 94//--- S.cpp95#pragma clang module import A96#pragma clang module import E97void func(std::vec<project::thing> *a, std::vec<project::thing> *b) { *a = *b; }98