https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/137571
We can use "constexpt if" to combine the two variants of functions. >From 1f4e0a2f61f75c45aea2651dff2f08d1a60d4526 Mon Sep 17 00:00:00 2001 From: Kazu Hirata <k...@google.com> Date: Sun, 27 Apr 2025 19:44:12 -0700 Subject: [PATCH] [ASTMatchers] Simplify isDefaultedHelper (NFC) We can use "constexpt if" to combine the two variants of functions. --- clang/include/clang/ASTMatchers/ASTMatchersInternal.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h index 8290645768aa9..00a4fefeac8f8 100644 --- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h +++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h @@ -871,14 +871,11 @@ IteratorT matchesFirstInPointerRange(const MatcherT &Matcher, IteratorT Start, return End; } -template <typename T, std::enable_if_t<!std::is_base_of<FunctionDecl, T>::value> - * = nullptr> -inline bool isDefaultedHelper(const T *) { +template <typename T> inline bool isDefaultedHelper(const T *FD) { + if constexpr (std::is_base_of<FunctionDecl, T>::value) + return FD->isDefaulted(); return false; } -inline bool isDefaultedHelper(const FunctionDecl *FD) { - return FD->isDefaulted(); -} // Metafunction to determine if type T has a member called getDecl. template <typename T> _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits