This is an archive of the discontinued LLVM Phabricator instance.

Implements a way to retrieve information about whether some lines were not formatted due to syntax errors.
ClosedPublic

Authored by klimek on May 6 2015, 9:09 AM.

Details

Reviewers
djasper

Diff Detail

Event Timeline

klimek updated this revision to Diff 25055.May 6 2015, 9:09 AM
klimek retitled this revision from to Implements a way to retrieve information about whether some lines were not formatted due to syntax errors..
klimek updated this object.
klimek edited the test plan for this revision. (Show Details)
klimek added a reviewer: djasper.
klimek added a subscriber: Unknown Object (MLST).
djasper added inline comments.May 6 2015, 10:20 AM
include/clang/Format/Format.h
550

I would not call this "skipped lines" as that might lead to confusion. Especially, if you format:

"int a; f (;"

the "line" will not be skipped entirely. And at some stage we actually might decide that we can't fix everything in an unwrapped line, but might still be able to do something.

I think the one bit we are trying to get out here is something like "FoundUnrecoverableError".

lib/Format/UnwrappedLineFormatter.cpp
481

Don't use else after return.

lib/Format/UnwrappedLineFormatter.h
73

I don't see the point in renaming this, but ok.

76

I think this is a bit of an anti-pattern:

  • You are passing in a lot of values, most of them 1:1 from local variables.
  • We can't come up with a better name than that of the only function calling this.
  • This function can only ever be usefully called from the other formatLine function.

All of these hint at this not being a useful separation.

If you want to decrease indentation and want to use early exits, I think a local lambda might be the better choice here. If you are solely trying to make this function shorter, I don't think it is worth it.

unittests/Format/FormatTest.cpp
70

I don't think it makes sense to allow for combinations of style and ExpectSkippedLines. Skipped lines should be independent of the style. Lets instead introduce a separate function. Maybe veryFormatWithError or something?

91

I don't think it makes sense to test this. No crash tests are rare and whether we also discover an unrecoverable syntax error or not isn't really of interest.

klimek updated this revision to Diff 25152.May 7 2015, 3:49 AM

Replaced SkippedLines with IncomleteFormat.
Undid refactoring. Will do larger refactoring in subsequent change.

Updating D9532: Implements a way to retrieve information about whether some lines were

not formatted due to syntax errors.

djasper accepted this revision.May 7 2015, 5:13 AM
djasper edited edge metadata.

Looks good.

lib/Format/UnwrappedLineFormatter.cpp
479

No braces.

unittests/Format/FormatTest.cpp
25–27

IFA?

40

I suspect that this looks a bit complicated in the test output when it actually triggers. Might be better to pull out the comparison into a local variable.

This revision is now accepted and ready to land.May 7 2015, 5:13 AM
klimek added inline comments.May 7 2015, 5:28 AM
lib/Format/UnwrappedLineFormatter.cpp
479

Done.

unittests/Format/FormatTest.cpp
25–27

Done.

40

Done.

klimek closed this revision.May 7 2015, 5:30 AM