aboutsummaryrefslogtreecommitdiff
path: root/lib/Format/UnwrappedLineParser.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2012-12-17 11:29:41 +0000
committerDaniel Jasper <djasper@google.com>2012-12-17 11:29:41 +0000
commit05b1ac8791ee89fdf0b275631ab8118febc7c33d (patch)
tree0932ed10ab7b43606b21e78a7ee848fb9b5d8c98 /lib/Format/UnwrappedLineParser.cpp
parent728e2127e858611750d560ee7692c322a8570faa (diff)
Fix several formatting problems.
More specifically: - Improve formatting of static initializers. - Fix formatting of lines comments in enums. - Fix formmating of trailing line comments. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170316 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/UnwrappedLineParser.cpp')
-rw-r--r--lib/Format/UnwrappedLineParser.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp
index 8545f336b8..7e91cb4351 100644
--- a/lib/Format/UnwrappedLineParser.cpp
+++ b/lib/Format/UnwrappedLineParser.cpp
@@ -43,7 +43,8 @@ bool UnwrappedLineParser::parseLevel() {
parsePPDirective();
break;
case tok::comment:
- parseComment();
+ nextToken();
+ addUnwrappedLine();
break;
case tok::l_brace:
Error |= parseBlock();
@@ -90,22 +91,16 @@ void UnwrappedLineParser::parsePPDirective() {
}
}
-void UnwrappedLineParser::parseComment() {
- while (!eof()) {
- nextToken();
- if (FormatTok.NewlinesBefore > 0) {
- addUnwrappedLine();
- return;
- }
- }
-}
-
-void UnwrappedLineParser::parseStatement() {
+void UnwrappedLineParser::parseComments() {
// Consume leading line comments, e.g. for branches without compounds.
while (FormatTok.Tok.is(tok::comment)) {
nextToken();
addUnwrappedLine();
}
+}
+
+void UnwrappedLineParser::parseStatement() {
+ parseComments();
switch (FormatTok.Tok.getKind()) {
case tok::kw_namespace:
@@ -164,6 +159,12 @@ void UnwrappedLineParser::parseStatement() {
return;
}
break;
+ case tok::equal:
+ nextToken();
+ // Skip initializers as they will be formatted by a later step.
+ if (FormatTok.Tok.is(tok::l_brace))
+ nextToken();
+ break;
default:
nextToken();
break;
@@ -325,6 +326,7 @@ void UnwrappedLineParser::parseEnum() {
nextToken();
addUnwrappedLine();
++Line.Level;
+ parseComments();
break;
case tok::l_paren:
parseParens();
@@ -332,6 +334,7 @@ void UnwrappedLineParser::parseEnum() {
case tok::comma:
nextToken();
addUnwrappedLine();
+ parseComments();
break;
case tok::r_brace:
if (HasContents)