r324896 - [clang-format] Fix comment indentation in text protos
Krasimir Georgiev via cfe-commits
cfe-commits at lists.llvm.org
Mon Feb 12 07:49:09 PST 2018
Author: krasimir
Date: Mon Feb 12 07:49:09 2018
New Revision: 324896
URL: http://llvm.org/viewvc/llvm-project?rev=324896&view=rev
Log:
[clang-format] Fix comment indentation in text protos
Summary: This patch fixes a bug where the comment indent of comments in text protos gets messed up because by default paren states get created with AlignColons = true (which makes snese for ObjC).
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D43194
Modified:
cfe/trunk/lib/Format/ContinuationIndenter.cpp
cfe/trunk/unittests/Format/FormatTestTextProto.cpp
Modified: cfe/trunk/lib/Format/ContinuationIndenter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/ContinuationIndenter.cpp?rev=324896&r1=324895&r2=324896&view=diff
==============================================================================
--- cfe/trunk/lib/Format/ContinuationIndenter.cpp (original)
+++ cfe/trunk/lib/Format/ContinuationIndenter.cpp Mon Feb 12 07:49:09 2018
@@ -200,6 +200,7 @@ LineState ContinuationIndenter::getIniti
// global scope.
State.Stack.back().AvoidBinPacking = true;
State.Stack.back().BreakBeforeParameter = true;
+ State.Stack.back().AlignColons = false;
}
// The first token has already been indented and thus consumed.
Modified: cfe/trunk/unittests/Format/FormatTestTextProto.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestTextProto.cpp?rev=324896&r1=324895&r2=324896&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestTextProto.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestTextProto.cpp Mon Feb 12 07:49:09 2018
@@ -313,5 +313,17 @@ TEST_F(FormatTestTextProto, KeepsLongStr
" text: \"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaasaaaaaaaaaa\"\n"
"}");
}
+
+TEST_F(FormatTestTextProto, KeepsCommentsIndentedInList) {
+ verifyFormat("aaaaaaaaaa: 100\n"
+ "bbbbbbbbbbbbbbbbbbbbbbbbbbb: 200\n"
+ "# Single line comment for stuff here.\n"
+ "cccccccccccccccccccccccc: 3849\n"
+ "# Multiline comment for stuff here.\n"
+ "# Multiline comment for stuff here.\n"
+ "# Multiline comment for stuff here.\n"
+ "cccccccccccccccccccccccc: 3849");
+}
+
} // end namespace tooling
} // end namespace clang
More information about the cfe-commits
mailing list