Skip to content
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 is not idempotent / misaligns trailing comments #19699

Closed
llvmbot opened this issue Apr 3, 2014 · 3 comments
Closed

clang-format is not idempotent / misaligns trailing comments #19699

llvmbot opened this issue Apr 3, 2014 · 3 comments
Labels
bugzilla Issues migrated from bugzilla clang-format

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Apr 3, 2014

Bugzilla Link 19325
Resolution FIXED
Resolved on Apr 17, 2014 11:13
Version trunk
OS MacOS X
Reporter LLVM Bugzilla Contributor

Extended Description

Running clang-format should ideally idempotent, i.e. if I run it,
then run it again, the results of the first and second run should
be identical.

This is currently not the case in the following example:

-- 8< --
int test() {
int foobar = 0; /* comment /
int foo = 0; /
comment /
int bar = 0; /
this is a multiline comment
and the later vars are shorter /
int qux = 0; /
comment */
}
-- 8< --

After running clang-format --style=LLVM on this, you get this:
-- 8< --
int test() {
int foobar = 0; /* comment /
int foo = 0; /
comment /
int bar = 0; /
this is a multiline comment
and the later vars are shorter /
int qux = 0; /
comment */
}
-- 8< --

Each run, the line before variable qux gets a little bit less indented. After enough, the process finally stabilizes at this version:
-- 8< --
int test() {
int foobar = 0; /* comment /
int foo = 0; /
comment /
int bar = 0; /
this is a multiline comment
and the later vars are shorter /
int qux = 0; /
comment */
}
-- 8< --

I am using clang SVN revision 205521, llvm rev 205525, on Mac OS X 10.8.5.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Apr 3, 2014

I can reproduce the behavior. Alex, can you take a look?

@llvmbot
Copy link
Collaborator Author

llvmbot commented Apr 15, 2014

Yes, that's weird, will take a look at it today.

@llvmbot
Copy link
Collaborator Author

llvmbot commented Apr 17, 2014

Fixed in r206472.

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 9, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang-format
Projects
None yet
Development

No branches or pull requests

1 participant