This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Fix MatchingOpeningBlockLineIndex computation
ClosedPublic

Authored by Typz on Apr 26 2017, 1:46 AM.

Details

Summary

Computed line index must be relative to the current 'parent' node, and
thus use CurrentLines instead of Lines.

Without this, a child line's MatchingOpeningBlockLineIndex is out of
range of the parent's list of line, which can cause crash or unexpected
behavior if this field is used in childs.

Diff Detail

Repository
rL LLVM

Event Timeline

Typz created this revision.Apr 26 2017, 1:46 AM
krasimir edited edge metadata.May 5 2017, 1:40 AM

Thank you! A test would be nice.

lib/Format/UnwrappedLineParser.cpp
432 ↗(On Diff #96681)

Could you please reformat and use '//'-style comments?

Typz added a comment.EditedMay 16 2017, 6:44 AM

I tried to add some test, but could not find a simple way: I could not find any 'parser' tests from which to start, and I don't see with current master how this can be an issue (though it becomes an issue with some of other patches).

Any hint how to implement the test?

Typz updated this revision to Diff 99136.May 16 2017, 6:51 AM

Reformat and remove unneeded comment

Typz marked an inline comment as done.May 16 2017, 6:52 AM
krasimir accepted this revision.May 17 2017, 3:42 AM

I can't think of a test case either. Thanks!

This revision is now accepted and ready to land.May 17 2017, 3:42 AM
Typz added a comment.May 17 2017, 9:03 AM
This comment was removed by Typz.

Do you need me to commit this?

Typz added a comment.EditedMay 18 2017, 7:46 AM

Indeed, I don't have commit access. But I was wondering if I should not get it, to simplify landing the patches after review.
I read http://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access about this, but I am still wondering what is considered a "track record of submitting high quality patches"...

I have uploaded 9 patches for review at the moment, if that is track record enough I will request access; otherwise please submit already :-)
Thanks,

It should be enough for commit access. Mention your patches while requesting commit access. I'll submit this in the meantime.

This revision was automatically updated to reflect the committed changes.