From c6bd40dd02be0c7aaf19f3512725d3403b1b1d58 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sun, 27 Apr 2025 10:45:02 -0700 Subject: [PATCH] [Support] Simplify yamlizeMappingEnumInput (NFC) We can use "constexpt if" to combine the two variants of functions. --- llvm/include/llvm/Support/YAMLTraits.h | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/llvm/include/llvm/Support/YAMLTraits.h b/llvm/include/llvm/Support/YAMLTraits.h index e707a445012b5..21829b906967e 100644 --- a/llvm/include/llvm/Support/YAMLTraits.h +++ b/llvm/include/llvm/Support/YAMLTraits.h @@ -1105,22 +1105,18 @@ yamlize(IO &io, T &Val, bool, Context &Ctx) { } template -std::enable_if_t::value, bool> -yamlizeMappingEnumInput(IO &io, T &Val) { - return false; -} - -template -std::enable_if_t::value, bool> -yamlizeMappingEnumInput(IO &io, T &Val) { - if (io.outputting()) - return false; +bool yamlizeMappingEnumInput(IO &io, T &Val) { + if constexpr (has_MappingEnumInputTraits::value) { + if (io.outputting()) + return false; - io.beginEnumScalar(); - MappingTraits::enumInput(io, Val); - bool Matched = !io.matchEnumFallback(); - io.endEnumScalar(); - return Matched; + io.beginEnumScalar(); + MappingTraits::enumInput(io, Val); + bool Matched = !io.matchEnumFallback(); + io.endEnumScalar(); + return Matched; + } + return false; } template