Page MenuHomePhabricator

[Format] Fix for bug 35641
ClosedPublic

Authored by kadircet on Feb 14 2018, 10:53 AM.

Details

Summary

Bug was caused due to comments at the start of scope. For a code like:

int func() { //
  int b;
  int c;
}

the comment at the first line gets IndentAndNestingLevel (1,1) whereas
the following declarations get only (0,1) which prevents them from insertion
of a new scope. So, I changed the AlignTokenSequence to look at previous
*non-comment* token when deciding whether to introduce a new scope into
stack or not.

Diff Detail

Repository
rL LLVM

Event Timeline

kadircet created this revision.Feb 14 2018, 10:53 AM
djasper accepted this revision.Feb 15 2018, 4:32 AM

Thanks for the fix.

unittests/Format/FormatTest.cpp
9453 ↗(On Diff #134264)

Make this "See llvm.org/PR35641".

9457 ↗(On Diff #134264)

Might be useful to use different types here to verify that alignment is actually happening, e.g. "int" and "unsigned".

This revision is now accepted and ready to land.Feb 15 2018, 4:32 AM
kadircet updated this revision to Diff 134414.EditedFeb 15 2018, 6:03 AM

Changed description of unit test to include direct link to bug.
Used different variable types to make sure alignment happens.

Btw, I cannot commit the change myself, don't have commit rights.

The diff looks wrong, the lib/Format/WhitespaceManager.cpp change gone missing.
You need to upload the diff to the git master/svn trunk/etc, *NOT* to the previous commit (previous diff).

kadircet updated this revision to Diff 134830.Feb 18 2018, 2:54 AM

Rebased and uploaded diff to the master. Sorry for the inconvenience.

Closed by commit rL338578: [Format] Fix for bug 35641 (authored by ibiryukov, committed by ). · Explain WhyAug 1 2018, 8:33 AM
This revision was automatically updated to reflect the committed changes.