[clang] [ASTMatchers] Simplify isDefaultedHelper (NFC) (PR #137571)

via cfe-commits cfe-commits at lists.llvm.org
Sun Apr 27 19:52:56 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang

Author: Kazu Hirata (kazutakahirata)

<details>
<summary>Changes</summary>

We can use "constexpt if" to combine the two variants of functions.


---
Full diff: https://github.com/llvm/llvm-project/pull/137571.diff


1 Files Affected:

- (modified) clang/include/clang/ASTMatchers/ASTMatchersInternal.h (+3-6) 


``````````diff
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>

``````````

</details>


https://github.com/llvm/llvm-project/pull/137571


More information about the cfe-commits mailing list