This is something that clang-format-diff and clang-tidy-diff do to varying degrees of success. Via https://www.reddit.com/r/cpp/comments/pnli5r/cc_precommit_hooks_for_static_analyzers_and/