Keep track of indentation levels in static initializers for correct indentation with tabs.
Summary:
Store IndentationLevel in ParentState and use it instead of the
Line::Level when indening.
Also fixed incorrect indentation level calculation in formatFirstToken.
Reviewers: djasper
Reviewed By: djasper
CC: cfe-commits, klimek
Differential Revision: http://llvm-reviews.chandlerc.com/D1797
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192563 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index afe9c8b..5a8b5d6 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -5968,6 +5968,21 @@
Tab));
Tab.UseTab = FormatStyle::UT_ForIndentation;
+ verifyFormat("T t[] = {\n"
+ "\taaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
+ "\taaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
+ "\taaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
+ "\taaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
+ "\taaaaaaaaaaaaaaaaaaaaaaaaaaaaaa,\n"
+ "\taaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\n"
+ "};",
+ Tab);
+ verifyFormat("enum A {\n"
+ "\ta1,\n"
+ "\ta2,\n"
+ "\ta3\n"
+ "};",
+ Tab);
EXPECT_EQ("if (aaaaaaaa && // q\n"
" bb) // w\n"
"\t;",