This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Fix regression about not aligning trailing comments in case they were previously aligned, but at different indent.
ClosedPublic

Authored by krasimir on Feb 1 2017, 2:09 AM.

Details

Summary

Comment reflower was adding untouchable tokens in case two consecutive comment lines are aligned in the source code. This disallows the whitespace manager to re-indent them later.

source:

int i = f(abc, // line 1
          d, // line 2
	     // line 3
	  b);

Since line 2 and line 3 are aligned, the reflower was marking line 3 as untouchable; however the three comment lines need to be re-aligned.
output before:

int i = f(abc, // line 1
          d,   // line 2
	     // line 3
	  b);

output after:

int i = f(abc, // line 1
          d,   // line 2
	       // line 3
	  b);

Event Timeline

krasimir created this revision.Feb 1 2017, 2:09 AM
krasimir edited the summary of this revision. (Show Details)Feb 1 2017, 2:13 AM
krasimir added a reviewer: djasper.
krasimir added subscribers: cfe-commits, sammccall.
djasper accepted this revision.Feb 1 2017, 2:16 AM

Looks good

This revision is now accepted and ready to land.Feb 1 2017, 2:16 AM
This revision was automatically updated to reflect the committed changes.