From 0d9560c049be66945d9adb548ab378e9b3c3df7c Mon Sep 17 00:00:00 2001 From: Dana Jansens Date: Fri, 11 Sep 2026 19:51:41 +0000 Subject: [PATCH] Disable readability-redundant-nested-if in clang tidy (#7776) This is a style choice we often agree with, and call out in code review. But there are many cases where we do want to split apart nested ifs, such as when working with LLVM apis like `dyn_cast`: ``` if (auto* thing = dyn_cast(other)) { if (thing->foo()) { ... } } ``` Or we may have TODOs or other comments in the scope of the outer if, which the tidy check ignores. Since this doesn't lead to bugs, we disable the check and leave this to reviews and authors for their discretion. --- .clang-tidy | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.clang-tidy b/.clang-tidy index 96d81e23bdce..6a63f91db254 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -118,6 +118,12 @@ Checks: # Warns on `= {}` which is also used to indicate which fields do not need to # be explicitly initialized in aggregate initialization. - '-readability-redundant-member-init' + # We generally do want to collapse if statements, and ask for it in review. + # But this check ignores when ifs are nested to place comments above/below + # the nested if block. And when the outer if block is also initializing a + # variable. There are more than a handful of cases where we want to do this, + # especially working with LLVM apis like dyn_cast. + - '-readability-redundant-nested-if' # Broken, wants to remove parens from `*(p + 1)` and `("Foo" + s).str()`. # TODO: Re-enable once https://github.com/llvm/llvm-project/issues/192435 and # related bugs are fixed.