1// Reduced from https://github.com/llvm/llvm-project/issues/93859 2// 3// RUN: rm -rf %t 4// RUN: mkdir -p %t 5// RUN: split-file %s %t 6// 7// RUN: %clang_cc1 -std=c++20 %t/reduced_std.cppm -emit-reduced-module-interface -o %t/reduced_std.pcm 8// RUN: %clang_cc1 -std=c++20 %t/Misc.cppm -emit-reduced-module-interface -o %t/Misc.pcm \ 9// RUN: -fprebuilt-module-path=%t 10// RUN: %clang_cc1 -std=c++20 %t/Instance.cppm -emit-reduced-module-interface -o %t/Instance.pcm \ 11// RUN: -fprebuilt-module-path=%t 12// RUN: %clang_cc1 -std=c++20 %t/Device.cppm -emit-reduced-module-interface -o %t/Device.pcm \ 13// RUN: -fprebuilt-module-path=%t 14// RUN: %clang_cc1 -std=c++20 %t/Overlay.cppm -emit-reduced-module-interface -o %t/Overlay.pcm \ 15// RUN: -fprebuilt-module-path=%t 16// RUN: %clang_cc1 -std=c++20 %t/App.cppm -emit-module-interface -o /dev/null \ 17// RUN: -fexperimental-modules-reduced-bmi -fmodule-output=%t/App.pcm \ 18// RUN: -fprebuilt-module-path=%t 19// RUN: %clang_cc1 -std=c++20 %t/test.cc -fsyntax-only -verify \ 20// RUN: -fprebuilt-module-path=%t 21 22//--- header.h 23namespace std { 24 25template <class _T1, class _T2> 26struct pair 27{ 28 _T1 first; 29 _T2 second; 30 31 constexpr pair() 32 : first(), second() {} 33 34 constexpr pair(_T1 const& __t1, _T2 const& __t2) 35 : first(__t1), second(__t2) {} 36}; 37 38template <class _T1, class _T2> 39pair(_T1, _T2) -> pair<_T1, _T2>; 40 41template <class _Tp> 42class __tree_const_iterator { 43public: 44 template <class> 45 friend class __tree; 46}; 47 48template <class _Tp> 49class __tree { 50public: 51 typedef _Tp value_type; 52 typedef __tree_const_iterator<value_type> const_iterator; 53 54 template <class, class, class, class> 55 friend class map; 56}; 57 58template <class _Key> 59class set { 60public: 61 typedef __tree<_Key> __base; 62 63 typedef typename __base::const_iterator iterator; 64 65 set() {} 66 67 pair<iterator, bool> 68 insert(const _Key& __v); 69}; 70 71template <class _InputIterator, class _OutputIterator> 72inline constexpr _OutputIterator 73copy(_InputIterator __first, _InputIterator __last, _OutputIterator __result) { 74 return pair{__first, __last}.second; 75} 76 77} 78 79//--- reduced_std.cppm 80module; 81#include "header.h" 82export module reduced_std; 83 84export namespace std { 85 using std::set; 86 using std::copy; 87} 88 89//--- Misc.cppm 90export module Misc; 91import reduced_std; 92 93export void check_result(int res) { 94 std::set<char> extensions; 95 extensions.insert('f'); 96} 97 98//--- Instance.cppm 99export module Instance; 100import reduced_std; 101 102export class Instance { 103public: 104 Instance() { 105 std::set<const char*> extensions; 106 extensions.insert("foo"); 107 } 108}; 109 110//--- Device.cppm 111export module Device; 112import reduced_std; 113import Instance; 114import Misc; 115 116std::set<int> wtf_set; 117 118//--- Overlay.cppm 119export module Overlay; 120 121import reduced_std; 122import Device; 123 124void overlay_vector_use() { 125 std::set<int> nums; 126 nums.insert(1); 127} 128 129//--- App.cppm 130module; 131#include "header.h" 132export module App; 133import Overlay; 134 135std::set<float> fs; 136 137//--- test.cc 138// expected-no-diagnostics 139import reduced_std; 140import App; 141 142void render() { 143 unsigned *oidxs = nullptr; 144 unsigned idxs[] = {0, 1, 2, 0, 2, 3}; 145 std::copy(idxs, idxs + 6, oidxs); 146} 147