]> granicus.if.org Git - clang/commit
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)
commitc3014c9312dc8eafe7e27a2d47457c62e8146de8
treebea77f396639df3f27ff5ee04fa62dbe7fbd1303
parent1f3bb7c5ab9839619e8e52ec7dd15edd37736835
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@285570 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTest.cpp