Skip to content

Commit 3170599

Browse files
[Support] Simplify yamlizeMappingEnumInput (NFC) (#137537)
We can use "constexpr if" to combine the two variants of functions.
1 parent 52fcb07 commit 3170599

File tree

1 file changed

+11
-15
lines changed

1 file changed

+11
-15
lines changed

llvm/include/llvm/Support/YAMLTraits.h

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1105,22 +1105,18 @@ yamlize(IO &io, T &Val, bool, Context &Ctx) {
11051105
}
11061106

11071107
template <typename T, typename Context>
1108-
std::enable_if_t<!has_MappingEnumInputTraits<T, Context>::value, bool>
1109-
yamlizeMappingEnumInput(IO &io, T &Val) {
1110-
return false;
1111-
}
1112-
1113-
template <typename T, typename Context>
1114-
std::enable_if_t<has_MappingEnumInputTraits<T, Context>::value, bool>
1115-
yamlizeMappingEnumInput(IO &io, T &Val) {
1116-
if (io.outputting())
1117-
return false;
1108+
bool yamlizeMappingEnumInput(IO &io, T &Val) {
1109+
if constexpr (has_MappingEnumInputTraits<T, Context>::value) {
1110+
if (io.outputting())
1111+
return false;
11181112

1119-
io.beginEnumScalar();
1120-
MappingTraits<T>::enumInput(io, Val);
1121-
bool Matched = !io.matchEnumFallback();
1122-
io.endEnumScalar();
1123-
return Matched;
1113+
io.beginEnumScalar();
1114+
MappingTraits<T>::enumInput(io, Val);
1115+
bool Matched = !io.matchEnumFallback();
1116+
io.endEnumScalar();
1117+
return Matched;
1118+
}
1119+
return false;
11241120
}
11251121

11261122
template <typename T, typename Context>

0 commit comments

Comments
 (0)