This is an archive of the discontinued LLVM Phabricator instance.

[clang-format] Skip over AnnotatedLines with >50 levels of nesting.
ClosedPublic

Authored by sammccall on Oct 30 2016, 6:05 PM.

Details

Reviewers
djasper
Summary

Skip over AnnotatedLines with >50 levels of nesting; don't format them.

Reasoning:

  • ExpressionParser uses a lot of stack for these, bad in some environments.
  • Our formatting algorithm is N^3 and gets really slow.
  • The resulting formatting is unlikely to be any good.
  • This is probably generated code we're formatting by accident.

We treat these as unparseable, and signal incomplete formatting.
50 is an arbitrary number, I've only seen real problems from ~150 levels.

Event Timeline

sammccall updated this revision to Diff 76347.Oct 30 2016, 6:05 PM
sammccall retitled this revision from to [clang-format] Skip over AnnotatedLines with >50 levels of nesting..
sammccall updated this object.
sammccall added a reviewer: djasper.
sammccall added a subscriber: cfe-commits.
sammccall updated this revision to Diff 76348.Oct 30 2016, 6:07 PM

Fixing style.

djasper accepted this revision.Oct 31 2016, 2:02 AM
djasper edited edge metadata.

Looks good.

This revision is now accepted and ready to land.Oct 31 2016, 2:02 AM

Thanks Daniel.
I don't have commit access, could you land this?

djasper closed this revision.Oct 31 2016, 6:32 AM

Committed as r285570.