Skip to content

Commit 8c73fee

Browse files
[PassSupport] Simplify callDefaultCtor (NFC) (llvm#137504)
We can use "constexpr if" to combine the two variants of functions.
1 parent 49eb7d0 commit 8c73fee

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

llvm/include/llvm/PassSupport.h

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,20 +64,13 @@ class Pass;
6464
INITIALIZE_PASS_WITH_OPTIONS_BEGIN(PassName, Arg, Name, Cfg, Analysis) \
6565
INITIALIZE_PASS_END(PassName, Arg, Name, Cfg, Analysis)
6666

67-
template <
68-
class PassName,
69-
std::enable_if_t<std::is_default_constructible<PassName>{}, bool> = true>
70-
Pass *callDefaultCtor() {
71-
return new PassName();
72-
}
73-
74-
template <
75-
class PassName,
76-
std::enable_if_t<!std::is_default_constructible<PassName>{}, bool> = true>
77-
Pass *callDefaultCtor() {
78-
// Some codegen passes should only be testable via
79-
// `llc -{start|stop}-{before|after}=<passname>`, not via `opt -<passname>`.
80-
report_fatal_error("target-specific codegen-only pass");
67+
template <class PassName> Pass *callDefaultCtor() {
68+
if constexpr (std::is_default_constructible_v<PassName>)
69+
return new PassName();
70+
else
71+
// Some codegen passes should only be testable via
72+
// `llc -{start|stop}-{before|after}=<passname>`, not via `opt -<passname>`.
73+
report_fatal_error("target-specific codegen-only pass");
8174
}
8275

8376
//===---------------------------------------------------------------------------

0 commit comments

Comments
 (0)