[all-commits] [llvm/llvm-project] f93169: [clang-format-diff] Fix missing formatting for zer...

ZequanWu via All-commits all-commits at lists.llvm.org
Fri Oct 8 10:26:09 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: f93169226a298f8fb22d768671d5564030c0ffa9
      https://github.com/llvm/llvm-project/commit/f93169226a298f8fb22d768671d5564030c0ffa9
  Author: Zequan Wu <zequanwu at google.com>
  Date:   2021-10-08 (Fri, 08 Oct 2021)

  Changed paths:
    M clang/tools/clang-format/clang-format-diff.py
    M clang/tools/clang-format/git-clang-format

  Log Message:
  -----------
  [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




More information about the All-commits mailing list