From bb42bf1a8bfd18fa2beec7fcbcb73f738fb455ba Mon Sep 17 00:00:00 2001 From: Manuel Klimek Date: Thu, 10 Jan 2013 11:52:21 +0000 Subject: Fix layout of blocks inside statements. Previously, we would not indent: SOME_MACRO({ int i; }); correctly. This is fixed by adding the trailing }); to the unwrapped line starting with SOME_MACRO({, so the formatter can correctly match the braces and indent accordingly. Also fixes incorrect parsing of initializer lists, like: int a[] = { 1 }; git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172058 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/Format.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lib/Format/Format.cpp') diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index dfb43afafa..00a4b77980 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -279,7 +279,9 @@ private: if (Newline) { unsigned WhitespaceStartColumn = State.Column; - if (Previous.is(tok::l_brace)) { + if (Current.is(tok::r_brace)) { + State.Column = Line.Level * 2; + } else if (Previous.is(tok::l_brace)) { // FIXME: This does not work with nested static initializers. // Implement a better handling for static initializers and similar // constructs. -- cgit v1.2.3-18-g5258