Skip over AnnotatedLines with >50 levels of nesting; don't format them.
authorDaniel Jasper <djasper@google.com>
Mon, 31 Oct 2016 13:23:00 +0000 (13:23 +0000)
committerDaniel Jasper <djasper@google.com>
Mon, 31 Oct 2016 13:23:00 +0000 (13:23 +0000)
commitfda47cd8739d6e195bc00b0f565a00f07573ad6d
tree7c516e0a08c4064d42b69b9b746de9abe7e72299
parenteb886635d9d5b81edadc61a3db38d119791d7c9c
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.

Patch by Sam McCall. Thank you.

llvm-svn: 285570
clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp