File: pr62943.cppm

package info (click to toggle)
llvm-toolchain-19 1%3A19.1.7-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,998,520 kB
  • sloc: cpp: 6,951,680; ansic: 1,486,157; asm: 913,598; python: 232,024; f90: 80,126; objc: 75,281; lisp: 37,276; pascal: 16,990; sh: 10,009; ml: 5,058; perl: 4,724; awk: 3,523; makefile: 3,167; javascript: 2,504; xml: 892; fortran: 664; cs: 573
file content (111 lines) | stat: -rw-r--r-- 2,784 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: split-file %s %t
//
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-module-interface -o %t/a.pcm
// RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-module-interface -o %t/b.pcm
// RUN: %clang_cc1 -std=c++20 %t/c.cppm -emit-module-interface \
// RUN:     -fprebuilt-module-path=%t -o %t/c.pcm
// RUN: %clang_cc1 -std=c++20 %t/use.cpp -fprebuilt-module-path=%t \
// RUN:     -fsyntax-only -verify

// Test again with reduced BMI.
// RUN: rm -rf %t
// RUN: mkdir -p %t
// RUN: split-file %s %t
//
// RUN: %clang_cc1 -std=c++20 %t/a.cppm -emit-reduced-module-interface -o %t/a.pcm
// RUN: %clang_cc1 -std=c++20 %t/b.cppm -emit-reduced-module-interface -o %t/b.pcm
// RUN: %clang_cc1 -std=c++20 %t/c.cppm -emit-reduced-module-interface \
// RUN:     -fprebuilt-module-path=%t -o %t/c.pcm
// RUN: %clang_cc1 -std=c++20 %t/use.cpp -fprebuilt-module-path=%t \
// RUN:     -fsyntax-only -verify

//--- foo.h
#ifndef FOO_H
#define FOO_H

template<class _Tp>
concept __has_member_value_type = requires { typename _Tp::value_type; };

template<class _Tp>
concept __has_member_element_type = requires { typename _Tp::element_type; };

template <class _Tp>
inline constexpr bool is_object_v = __is_object(_Tp);

template<class> struct __cond_value_type {};

template<class _Tp>
requires is_object_v<_Tp>
struct __cond_value_type<_Tp> { using value_type = bool; };

template<class> struct indirectly_readable_traits {
    static constexpr int value = false;
};
#endif

//--- foo.member_value_type.h
#include "foo.h"
template<__has_member_value_type _Tp>
struct indirectly_readable_traits<_Tp> : __cond_value_type<typename _Tp::value_type> {
    static constexpr int value = false;
};

//--- foo.memeber_element_type.h
#include "foo.h"
template<__has_member_element_type _Tp>
struct indirectly_readable_traits<_Tp>  : __cond_value_type<typename _Tp::element_type>  {
    static constexpr int value = false;
};

template<__has_member_value_type _Tp>
  requires __has_member_element_type<_Tp>
struct indirectly_readable_traits<_Tp> {
    static constexpr int value = true;
};

//--- foo.a.h
#include "foo.h"
#include "foo.member_value_type.h"
#include "foo.memeber_element_type.h"
template <typename T>
using AType  = indirectly_readable_traits<T>;

//--- a.cppm
module;
#include "foo.a.h"
export module a;

export using ::AType;

//--- b.cppm
module;
#include "foo.h"
#include "foo.memeber_element_type.h"
export module b;

//--- c.cppm
export module c;

export import a;
export import b;

//--- use.cpp
// expected-no-diagnostics
import c;

template <typename T>
class U {
public:
    using value_type = T;
    using element_type = T;
};

template <typename T>
class V {
public:
};

static_assert(!AType<V<int*>>::value);
static_assert(AType<U<int**>>::value);