[clang-format] Refine ObjC guesser to handle child lines of child lines
authorBen Hamilton <benhamilton@google.com>
Tue, 27 Mar 2018 15:01:21 +0000 (15:01 +0000)
committerBen Hamilton <benhamilton@google.com>
Tue, 27 Mar 2018 15:01:21 +0000 (15:01 +0000)
commitea7a27b847b8eca39e427b430381e6b2cbf349f3
treefd5c59dd2c0bc64eeec27861bbcff4acd865dcae
parentd54e7aa9e252a9d895c1250a0512e5323632efb8
[clang-format] Refine ObjC guesser to handle child lines of child lines

Summary:
This fixes an issue brought up by djasper@ in his review of D44790. We
handled top-level child lines, but if those child lines themselves
had child lines, we didn't handle them.

Rather than use recursion (which could blow out the stack), I use a
DenseSet to hold the set of lines we haven't yet checked (since order
doesn't matter), and update the set to add the children of each
line as we check it.

Test Plan: New tests added. Confirmed tests failed before fix
  and passed after fix.

Reviewers: djasper

Reviewed By: djasper

Subscribers: klimek, cfe-commits

Differential Revision: https://reviews.llvm.org/D44831

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