New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
clang-format adds incorrect indentation and trailing whitespace after 4b9764959dc4b8783e18747c1742ab164e4bc4ee #63170
Comments
@llvm/issue-subscribers-clang-format |
What was the latest version did you use to generate your $ clang-format-16.0.4 golden.h > foo.h
$ clang-format-4b97649 golden.h > bar.h
$ diff foo.h bar.h
$ And they are different from your |
BTW the first 100+ lines are the same: $ cmp golden.h foo.h
golden.h foo.h differ: char 3004, line 105 |
I used revision f8b2cbf, which is a bit newer than your patch, but we're having problems with earlier revisions as far back as ac0ea75, which is the first revision to hit our CI w/ your change. (https://ci.chromium.org/ui/p/fuchsia/builders/ci/clang_toolchain.ci.core.arm64-debug/b8779275268692394689/blamelist) After digging a bit more, it seems like the formatting may have just failed altogether and So i think you can reproduce our exact test by
And they should come out the same. Running that locally I'm seeing:
Which I think means we're on an error path(
We're not seeing that before your patch. I'm asking some of the folks involved in these tests + infra why we didn't see any error messages, which would have been helpful diagnosing this earlier. |
also, clang-format apparently exits w/ |
I have tested the above with 4b97649, ac0ea75, and f8b2cbf (both Debug and Release builds) and in every case g.h and b.h are the same.
Please attach golden.maybe.h if it's different than golden.h. I don't see this with either golden.h or bad.h. |
It has been this way since clang-format 4. |
So, I'm at a loss. Building at ToT reliably reproduces this for us, and our CI has been broken by this since it landed. I've managed to reduce the test case down to almost nothing and I can still repro this behavior at just about any revision since your patch landed.
Note there are two ' ' chars on the line after the ifdef. clearly clang-format should handle this w/o issue, and If I revert your patch locally this no longer happens ... |
I've supplied a test case in https://reviews.llvm.org/D152473 |
I can reproduce the regression with the above. Thanks! |
After https://reviews.llvm.org/D151954 we've noticed some issues w/ clang-format behavior, as outlined in #63170. Valid C/C++ files, that were previously accepted, are now rejected by clang-format, emitting the message: "The new replacement overlaps with an existing replacement." This reverts commit 4b97649 and d2627cf, which depends on it. Reviewed By: phosek Differential Revision: https://reviews.llvm.org/D152473
Fixed in 441108c. |
After https://reviews.llvm.org/D151954 we're seeing some significant regressions in the output of Clang-Format.
formating_output.zip
The code in this example is generated and formatted w/ Clang-Format and diffed against a golden file (
golden.h
). To be clear the golden and generated file are both formatted w/ Clang-Format prior to diffing to avoid needlessly detecting irrelevant changes. Our.clang-format
file can be found here: https://cs.opensource.google/fuchsia/fuchsia/+/main:.clang-formatAs can be seen in
bad.h
, includes are indented when they shouldn't be and there is whitespace added after lines in many cases. There are also a number of empty lines left in the file.To illustrate I'm incuding a snippet of the first 30 lines from
golden.h
andbad.h
:golden.h
bad.h
The text was updated successfully, but these errors were encountered: