Issue |
154443
|
Summary |
git-clang-format misformats CGCoroutine.cpp, adding spurious indentation across a large block
|
Labels |
clang-format
|
Assignees |
|
Reporter |
snarkmaster
|
I wasn't able to quickly minify the repro, but it keeps coming up on the CI of https://github.com/llvm/llvm-project/pull/152623, so I wanted to make sure to report the formatter bug so that either:
- it can be fixed, preventing future confusion and red signals on PRs
- a maintainer can suggest a workaround I can add to the code to avoid tripping the misformat
These repro steps use a commit ID available as part of https://github.com/llvm/llvm-project/pull/152623.
- 0732693d81975d92399ec6b63823ac27c83ab9fb just happens to be my merge base from LLVM `main`, nothing special about this commit
- e6b636744ec11778685d9944fee48377774a28ec has my changes that trigger the misformat
Per the below repro instructions, it seems like there might be an issue with how `git-clang-format` invokes `clang-format`, rather than with the formatter itself. Also relevant (from the PR with the problem):
> @efriedma-quic:
> git-clang-format uses the "--lines" option to clang-format restrict formatting updates. If that isn't working correctly, please file a bug. You can ignore the bot after that.
```
cd llvm-project
# I'm using `clang-format` built from trunk via `ninja clang-format`
tail -n 2 .git/config
[clangFormat]
binary = /home/username/llvm-build-github/bin/clang-format
git checkout e6b636744ec11778685d9944fee48377774a28ec
# Working method -- but this is NOT what LLVM CI uses
git diff -U0 --no-color 0732693d8197 | python3 clang/tools/clang-format/clang-format-diff.py -i -p1
git diff
# No changes
# Broken method
clang/tools/clang-format/git-clang-format 0732693d8197
git diff
diff --git i/clang/lib/CodeGen/CGCoroutine.cpp w/clang/lib/CodeGen/CGCoroutine.cpp
index ab972dda1c7c..d47553d0b688 100644
--- i/clang/lib/CodeGen/CGCoroutine.cpp
+++ w/clang/lib/CodeGen/CGCoroutine.cpp
@@ -219,205 +219,207 @@ namespace {
LValue LV;
RValue RV;
};
-}
+ } // namespace
+
...
```
I am not including the entire large diff generated by` git-clang-format`. It can be found here: https://github.com/llvm/llvm-project/actions/runs/17076699075/job/48426056089?pr=152623
However, the core of the problem is a bunch of global-scope lines end up indented 2 spaces, incorrectly.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs