[clang-tools-extra] Add refactoring tool to convert between ternary (?:) expressions and equivalent if/else statements (PR #166822)

via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 7 07:50:33 PST 2025


================
@@ -0,0 +1,39 @@
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_CONDITIONALTOIFCHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_CONDITIONALTOIFCHECK_H
+
+#include "../ClangTidyCheck.h"
+
+namespace clang::tidy::modernize {
+
+/// Convert between simple conditional (?:) expressions and equivalent if/else
+/// statements in safe, syntactically simple cases.
+///
+/// Direction is controlled by the option:
+///   - modernize-conditional-to-if.PreferredForm: "if" | "conditional"
+class ConditionalToIfCheck : public ClangTidyCheck {
----------------
EugeneZelenko wrote:

Please add link to documentation. See other checks as example.

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


More information about the cfe-commits mailing list