[llvm] 8c73fee - [PassSupport] Simplify callDefaultCtor (NFC) (#137504)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Apr 27 08:52:54 PDT 2025
Author: Kazu Hirata
Date: 2025-04-27T08:52:51-07:00
New Revision: 8c73fee407291b1d769b6f22ba5c0d3d9eac5a0b
URL: https://github.com/llvm/llvm-project/commit/8c73fee407291b1d769b6f22ba5c0d3d9eac5a0b
DIFF: https://github.com/llvm/llvm-project/commit/8c73fee407291b1d769b6f22ba5c0d3d9eac5a0b.diff
LOG: [PassSupport] Simplify callDefaultCtor (NFC) (#137504)
We can use "constexpr if" to combine the two variants of functions.
Added:
Modified:
llvm/include/llvm/PassSupport.h
Removed:
################################################################################
diff --git a/llvm/include/llvm/PassSupport.h b/llvm/include/llvm/PassSupport.h
index 2806d9b52b0b9..b0897a6be37d1 100644
--- a/llvm/include/llvm/PassSupport.h
+++ b/llvm/include/llvm/PassSupport.h
@@ -64,20 +64,13 @@ class Pass;
INITIALIZE_PASS_WITH_OPTIONS_BEGIN(PassName, Arg, Name, Cfg, Analysis) \
INITIALIZE_PASS_END(PassName, Arg, Name, Cfg, Analysis)
-template <
- class PassName,
- std::enable_if_t<std::is_default_constructible<PassName>{}, bool> = true>
-Pass *callDefaultCtor() {
- return new PassName();
-}
-
-template <
- class PassName,
- std::enable_if_t<!std::is_default_constructible<PassName>{}, bool> = true>
-Pass *callDefaultCtor() {
- // Some codegen passes should only be testable via
- // `llc -{start|stop}-{before|after}=<passname>`, not via `opt -<passname>`.
- report_fatal_error("target-specific codegen-only pass");
+template <class PassName> Pass *callDefaultCtor() {
+ if constexpr (std::is_default_constructible_v<PassName>)
+ return new PassName();
+ else
+ // Some codegen passes should only be testable via
+ // `llc -{start|stop}-{before|after}=<passname>`, not via `opt -<passname>`.
+ report_fatal_error("target-specific codegen-only pass");
}
//===---------------------------------------------------------------------------
More information about the llvm-commits
mailing list