[clang-format-diff] Fix missing formatting for zero length git diff lines
authorZequan Wu <zequanwu@google.com>
Wed, 6 Oct 2021 21:18:12 +0000 (14:18 -0700)
committerZequan Wu <zequanwu@google.com>
Fri, 8 Oct 2021 17:25:54 +0000 (10:25 -0700)
commitf93169226a298f8fb22d768671d5564030c0ffa9
treec978e94414a4e58240496e8f8c51df0b9ac545be
parentc960c8c33997af21492cf2d9a39c13ac78fe6c62
[clang-format-diff] Fix missing formatting for zero length git diff lines

If we only delete lines that are outer block statements (if, while, etc),
clang-format-diff.py can't format the statements inside the block statements.

An example to repro:
1. Delete the if statment at line 118 in llvm/lib/CodeGen/Analysis.cpp.
2. Run `git diff -U0 --no-color HEAD^ | clang/tools/clang-format/clang-format-diff.py -i -p1`

It fails to format the statement after if.

Differential Revision: https://reviews.llvm.org/D111273
clang/tools/clang-format/clang-format-diff.py
clang/tools/clang-format/git-clang-format