Calculate and store ColumnWidth instead of CodePointCount in FormatTokens.
Summary:
This fixes various issues with mixed tabs and spaces handling, e.g.
when realigning block comments.
Reviewers: klimek, djasper
Reviewed By: djasper
CC: cfe-commits
Differential Revision: http://llvm-reviews.chandlerc.com/D1608
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@190395 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp
index ef7d63c..8ae956e 100644
--- a/unittests/Format/FormatTest.cpp
+++ b/unittests/Format/FormatTest.cpp
@@ -5738,33 +5738,48 @@
// FIXME: To correctly count mixed whitespace we need to
// also correctly count mixed whitespace in front of the comment.
- // Tab.TabWidth = 8;
- // Tab.IndentWidth = 8;
- // EXPECT_EQ("/*\n"
- // "\t a\t\tcomment\n"
- // "\t in multiple lines\n"
- // " */",
- // format(" /*\t \t \n"
- // " \t \t a\t\tcomment\t \t\n"
- // " \t \t in multiple lines\t\n"
- // " \t */",
- // Tab));
- // Tab.UseTab = false;
- // EXPECT_EQ("/*\n"
- // " a\t\tcomment\n"
- // " in multiple lines\n"
- // " */",
- // format(" /*\t \t \n"
- // " \t \t a\t\tcomment\t \t\n"
- // " \t \t in multiple lines\t\n"
- // " \t */",
- // Tab));
- // EXPECT_EQ("/* some\n"
- // " comment */",
- // format(" \t \t /* some\n"
- // " \t \t comment */",
- // Tab));
+ Tab.TabWidth = 8;
+ Tab.IndentWidth = 8;
+ EXPECT_EQ("/*\n"
+ "\t a\t\tcomment\n"
+ "\t in multiple lines\n"
+ " */",
+ format(" /*\t \t \n"
+ " \t \t a\t\tcomment\t \t\n"
+ " \t \t in multiple lines\t\n"
+ " \t */",
+ Tab));
+ Tab.UseTab = false;
+ EXPECT_EQ("/*\n"
+ " a\t\tcomment\n"
+ " in multiple lines\n"
+ " */",
+ format(" /*\t \t \n"
+ " \t \t a\t\tcomment\t \t\n"
+ " \t \t in multiple lines\t\n"
+ " \t */",
+ Tab));
+ EXPECT_EQ("/* some\n"
+ " comment */",
+ format(" \t \t /* some\n"
+ " \t \t comment */",
+ Tab));
+ EXPECT_EQ("int a; /* some\n"
+ " comment */",
+ format(" \t \t int a; /* some\n"
+ " \t \t comment */",
+ Tab));
+ EXPECT_EQ("int a; /* some\n"
+ "comment */",
+ format(" \t \t int\ta; /* some\n"
+ " \t \t comment */",
+ Tab));
+ EXPECT_EQ("f(\"\t\t\"); /* some\n"
+ " comment */",
+ format(" \t \t f(\"\t\t\"); /* some\n"
+ " \t \t comment */",
+ Tab));
EXPECT_EQ("{\n"
" /*\n"
" * Comment\n"