[llvm] 3170599 - [Support] Simplify yamlizeMappingEnumInput (NFC) (#137537)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 27 12:34:36 PDT 2025
Author: Kazu Hirata
Date: 2025-04-27T12:34:33-07:00
New Revision: 3170599fd4de02b5417223ff0d16776d2fe6af69
URL: https://github.com/llvm/llvm-project/commit/3170599fd4de02b5417223ff0d16776d2fe6af69
DIFF: https://github.com/llvm/llvm-project/commit/3170599fd4de02b5417223ff0d16776d2fe6af69.diff
LOG: [Support] Simplify yamlizeMappingEnumInput (NFC) (#137537)
We can use "constexpr if" to combine the two variants of functions.
Added:
Modified:
llvm/include/llvm/Support/YAMLTraits.h
Removed:
################################################################################
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 <typename T, typename Context>
-std::enable_if_t<!has_MappingEnumInputTraits<T, Context>::value, bool>
-yamlizeMappingEnumInput(IO &io, T &Val) {
- return false;
-}
-
-template <typename T, typename Context>
-std::enable_if_t<has_MappingEnumInputTraits<T, Context>::value, bool>
-yamlizeMappingEnumInput(IO &io, T &Val) {
- if (io.outputting())
- return false;
+bool yamlizeMappingEnumInput(IO &io, T &Val) {
+ if constexpr (has_MappingEnumInputTraits<T, Context>::value) {
+ if (io.outputting())
+ return false;
- io.beginEnumScalar();
- MappingTraits<T>::enumInput(io, Val);
- bool Matched = !io.matchEnumFallback();
- io.endEnumScalar();
- return Matched;
+ io.beginEnumScalar();
+ MappingTraits<T>::enumInput(io, Val);
+ bool Matched = !io.matchEnumFallback();
+ io.endEnumScalar();
+ return Matched;
+ }
+ return false;
}
template <typename T, typename Context>
More information about the llvm-commits
mailing list