[clang] [ASTMatchers] Simplify isDefaultedHelper (NFC) (PR #137571)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 27 21:11:48 PDT 2025
https://github.com/kazutakahirata updated https://github.com/llvm/llvm-project/pull/137571
>From 1f4e0a2f61f75c45aea2651dff2f08d1a60d4526 Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 27 Apr 2025 19:44:12 -0700
Subject: [PATCH 1/2] [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>
>From ee48b912d698b18f028a6ea709b9e7ba17b436bf Mon Sep 17 00:00:00 2001
From: Kazu Hirata <kazu at google.com>
Date: Sun, 27 Apr 2025 21:11:41 -0700
Subject: [PATCH 2/2] Update
clang/include/clang/ASTMatchers/ASTMatchersInternal.h
Co-authored-by: Jakub Kuderski <kubakuderski at gmail.com>
---
clang/include/clang/ASTMatchers/ASTMatchersInternal.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
index 00a4fefeac8f8..71dfc49b7fcca 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -872,7 +872,7 @@ IteratorT matchesFirstInPointerRange(const MatcherT &Matcher, IteratorT Start,
}
template <typename T> inline bool isDefaultedHelper(const T *FD) {
- if constexpr (std::is_base_of<FunctionDecl, T>::value)
+ if constexpr (std::is_base_of_v<FunctionDecl, T>)
return FD->isDefaulted();
return false;
}
More information about the cfe-commits
mailing list