Skip to content

Commit a3b5ce9

Browse files
authored
Fix clang 13 build (#8669)
Clang-13 advertises C++20 support with `__cplusplus >= 202002L`, but it does not have all the features of C++20. So instead use the C++20 individual feature testing macros to check for the various features: https://en.cppreference.com/cpp/feature_test which Clang-13 accurately reports. Authored on top of PR #8668, will rebase before landing, if/when #8668 is approved.
1 parent 7f44054 commit a3b5ce9

17 files changed

Lines changed: 53 additions & 34 deletions

src/analysis/lattice.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
#ifndef wasm_analysis_lattice_h
1818
#define wasm_analysis_lattice_h
1919

20-
#if __cplusplus >= 202002L
20+
#if __has_include(<concepts>)
2121
#include <concepts>
22-
#endif // __cplusplus >= 202002L
22+
#endif
2323

2424
namespace wasm::analysis {
2525

@@ -37,7 +37,7 @@ inline LatticeComparison reverseComparison(LatticeComparison comparison) {
3737
}
3838
}
3939

40-
#if __cplusplus >= 202002L
40+
#if defined(__cpp_lib_concepts)
4141

4242
template<typename L>
4343
concept Lattice = requires(const L& lattice,
@@ -78,12 +78,12 @@ concept FullLattice =
7878
{ lattice.meet(elem, constElem) } noexcept -> std::same_as<bool>;
7979
};
8080

81-
#else // __cplusplus >= 202002L
81+
#else // defined(__cpp_lib_concepts)
8282

8383
#define Lattice typename
8484
#define FullLattice typename
8585

86-
#endif // __cplusplus >= 202002L
86+
#endif // defined(__cpp_lib_concepts)
8787

8888
} // namespace wasm::analysis
8989

src/analysis/lattices/abstraction.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include "../lattice.h"
2323
#include "support/utilities.h"
2424

25-
#if __cplusplus >= 202002L
25+
#if defined(__cpp_lib_concepts)
2626
#include "analysis/lattices/bool.h"
2727
#endif
2828

@@ -218,7 +218,7 @@ template<typename Self, typename... Ls> struct Abstraction {
218218
}
219219
};
220220

221-
#if __cplusplus >= 202002L
221+
#if defined(__cpp_lib_concepts)
222222
static_assert(Lattice<Abstraction<Bool, Bool, Bool>>);
223223
#endif
224224

src/analysis/lattices/array.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ template<Lattice L, size_t N> struct Array {
5454
}
5555

5656
Element getTop() const noexcept
57-
#if __cplusplus >= 202002L
57+
#if defined(__cpp_lib_concepts)
5858
requires FullLattice<L>
5959
#endif
6060
{
@@ -101,7 +101,7 @@ template<Lattice L, size_t N> struct Array {
101101

102102
// Pairwise meet on the elements.
103103
bool meet(Element& meetee, const Element& meeter) const noexcept
104-
#if __cplusplus >= 202002L
104+
#if defined(__cpp_lib_concepts)
105105
requires FullLattice<L>
106106
#endif
107107
{
@@ -113,7 +113,7 @@ template<Lattice L, size_t N> struct Array {
113113
}
114114
};
115115

116-
#if __cplusplus >= 202002L
116+
#if defined(__cpp_lib_concepts)
117117
static_assert(FullLattice<Array<Bool, 1>>);
118118
static_assert(Lattice<Array<Flat<bool>, 1>>);
119119
#endif

src/analysis/lattices/bool.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,9 @@ struct Bool {
7575
}
7676
};
7777

78-
#if __cplusplus >= 202002L
78+
#if defined(__cpp_lib_concepts)
7979
static_assert(Lattice<Bool>);
80-
#endif // __cplusplus >= 202002L
80+
#endif // defined(__cpp_lib_concepts)
8181

8282
} // namespace wasm::analysis
8383

src/analysis/lattices/conetype.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ struct ConeType {
174174
}
175175
};
176176

177-
#if __cplusplus >= 202002L
177+
#if defined(__cpp_lib_concepts)
178178
static_assert(Lattice<ConeType>);
179179
static_assert(FullLattice<ConeType>);
180180
#endif

src/analysis/lattices/flat.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include <type_traits>
2222
#include <variant>
2323

24-
#if __cplusplus >= 202002L
24+
#if __has_include(<concepts>)
2525
#include <concepts>
2626
#endif
2727

@@ -30,7 +30,7 @@
3030

3131
namespace wasm::analysis {
3232

33-
#if __cplusplus >= 202002L
33+
#if defined(__cpp_lib_concepts)
3434

3535
template<typename T>
3636
concept Flattenable = std::copyable<T> && std::equality_comparable<T>;
@@ -118,7 +118,7 @@ struct Flat {
118118
}
119119
};
120120

121-
#if __cplusplus >= 202002L
121+
#if defined(__cpp_lib_concepts)
122122
static_assert(Lattice<Flat<int>>);
123123
#endif
124124

src/analysis/lattices/int.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ namespace wasm::analysis {
2626

2727
// The lattice of integers of the given type `T`, ordered by <. The min integer
2828
// is the bottom element and the max integer is the top element.
29-
#if __cplusplus >= 202002L
29+
#if defined(__cpp_lib_concepts)
3030
template<std::integral T>
3131
#else
3232
template<typename T>
@@ -59,12 +59,12 @@ using UInt32 = Integer<uint32_t>;
5959
using Int64 = Integer<int64_t>;
6060
using UInt64 = Integer<uint64_t>;
6161

62-
#if __cplusplus >= 202002L
62+
#if defined(__cpp_lib_concepts)
6363
static_assert(FullLattice<Int32>);
6464
static_assert(FullLattice<Int64>);
6565
static_assert(FullLattice<UInt32>);
6666
static_assert(FullLattice<UInt64>);
67-
#endif // __cplusplus >= 202002L
67+
#endif // defined(__cpp_lib_concepts)
6868

6969
} // namespace wasm::analysis
7070

src/analysis/lattices/inverted.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ template<FullLattice L> struct Inverted {
5252
// Deduction guide.
5353
template<typename L> Inverted(L&&) -> Inverted<L>;
5454

55-
#if __cplusplus >= 202002L
55+
#if defined(__cpp_lib_concepts)
5656
static_assert(Lattice<Inverted<Bool>>);
5757
#endif
5858

src/analysis/lattices/lift.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ template<Lattice L> struct Lift {
7777
// Deduction guide.
7878
template<typename L> Lift(L&&) -> Lift<L>;
7979

80-
#if __cplusplus >= 202002L
80+
#if defined(__cpp_lib_concepts)
8181
static_assert(Lattice<Lift<Bool>>);
8282
#endif
8383

src/analysis/lattices/shared.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,9 +121,9 @@ template<Lattice L> struct SharedPath {
121121
// Deduction guide.
122122
template<typename L> SharedPath(L&&) -> SharedPath<L>;
123123

124-
#if __cplusplus >= 202002L
124+
#if defined(__cpp_lib_concepts)
125125
static_assert(Lattice<SharedPath<Bool>>);
126-
#endif // __cplusplus >= 202002L
126+
#endif // defined(__cpp_lib_concepts)
127127

128128
} // namespace wasm::analysis
129129

0 commit comments

Comments
 (0)