[clang-tools-extra] [clang-tidy] Add `readability-redundant-nested-if` check (PR #181558)

Daniil Dudkin via cfe-commits cfe-commits at lists.llvm.org
Tue May 12 17:15:42 PDT 2026


unterumarmung wrote:

I tried running this check with fix-its on the LLVM codebase, including LLVM, MLIR, Flang, Clang, and libc++. The commit below shows the result of applying the fix-its:

[https://github.com/llvm/llvm-project/commit/6a97f45aafd95856a7ed5b402e6d960d6a1c780f](https://github.com/llvm/llvm-project/commit/6a97f45aafd95856a7ed5b402e6d960d6a1c780f)

The project builds successfully after applying them. The tests also run fine, although I had some failures due to linking errors. I think those are caused by my configuration rather than by the fixes themselves.

Here is the command I used:

```bash
cmake -S llvm -B build-wide-tidy -G Ninja \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_C_COMPILER=/opt/homebrew/opt/llvm/bin/clang \
  -DCMAKE_CXX_COMPILER=/opt/homebrew/opt/llvm/bin/clang++ \
  -DCMAKE_OSX_SYSROOT=/Library/Developer/CommandLineTools/SDKs/MacOSX26.sdk \
  -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
  -DCMAKE_DISABLE_PRECOMPILE_HEADERS=ON \
  -DLLVM_ENABLE_PROJECTS='clang;clang-tools-extra;flang;mlir' \
  -DLLVM_ENABLE_RUNTIMES='libcxx;libcxxabi;libunwind' \
  -DLLVM_TARGETS_TO_BUILD=Native \
  -DLLVM_ENABLE_ASSERTIONS=ON \
  -DLLVM_ENABLE_BACKTRACES=OFF \
  -DLLVM_ENABLE_ZLIB=OFF \
  -DLLVM_ENABLE_LIBXML2=OFF
```

I have not analyzed the diagnostics themselves yet. Some of them are not reflected in the fix-its because fix-its are suppressed when comments between `if` statements cannot be transferred easily.

I also forgot that, by default, `run-clang-tidy.py` does not apply fix-its to headers. Could you please remind me how to enable that? I’ll try to rerun it, since headers should contain more edge cases involving templates.

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


More information about the cfe-commits mailing list