This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Fix a bug that indents else-comment-if incorrectly
ClosedPublic

Authored by owenpan on Jun 23 2021, 3:23 AM.

Details

Summary

If there is a comment between "else" and "if", the "if" statement including its body is indented incorrectly.

See https://bugs.llvm.org/show_bug.cgi?id=50809 for an example.

Diff Detail

Event Timeline

owenpan requested review of this revision.Jun 23 2021, 3:23 AM
owenpan created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptJun 23 2021, 3:23 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
This revision is now accepted and ready to land.Jun 23 2021, 4:10 AM
This revision was landed with ongoing or failed builds.Jun 23 2021, 5:00 AM
This revision was automatically updated to reflect the committed changes.

That was fast. I personally like it better to give others a chance to look at. ;)

@HazardyKnusperkek Its probably my "bad" I should said "LGTM but maybe wait for the others to comment", but I'm fundamentally ok I think with the change. (we'll just revert if it breaks stuff! ;-))

We are free to add review comments after the fact, @owenpan has been providing us with fixes and contributions to clang-format for a some time (years) so I pretty much trust them. I'm less sceptical in the review of those that contribute either on a regular basis (like yourself) or those who have done multiple features (like @owenpan). I did actually download the patch, apply it and run all the unit tests too, (because I was slightly questioning in my mind the use of "Previous" and if it could be null), but it all seemed to check out (and I tried some combinations to try and break it))

I don't think we need to wait multiple accepts (although between us I think we do this from time to time), I think the LLVM rules specify that if you have an accept then its ok, But I do feel its perfectly acceptable to review after the fact and expect the author to change it again.

I was the one that added you and @curdeius as reviewers (as I normally do out of respect for your efforts), but perhaps only we know that we are the ones doing the lion share of clang-format reviewing (others might not know that).

@HazardyKnusperkek Its probably my "bad" I should said "LGTM but maybe wait for the others to comment", but I'm fundamentally ok I think with the change. (we'll just revert if it breaks stuff! ;-))

We are free to add review comments after the fact, @owenpan has been providing us with fixes and contributions to clang-format for a some time (years) so I pretty much trust them. I'm less sceptical in the review of those that contribute either on a regular basis (like yourself) or those who have done multiple features (like @owenpan). I did actually download the patch, apply it and run all the unit tests too, (because I was slightly questioning in my mind the use of "Previous" and if it could be null), but it all seemed to check out (and I tried some combinations to try and break it))

I don't think we need to wait multiple accepts (although between us I think we do this from time to time), I think the LLVM rules specify that if you have an accept then its ok, But I do feel its perfectly acceptable to review after the fact and expect the author to change it again.

I was the one that added you and @curdeius as reviewers (as I normally do out of respect for your efforts), but perhaps only we know that we are the ones doing the lion share of clang-format reviewing (others might not know that).

No problem here. :) I think the change is small enough and the fix obvious. It was just a small comment.