krasimir created this revision. Herald added subscribers: cfe-commits, klimek.
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). Repository: rC Clang https://reviews.llvm.org/D43194 Files: lib/Format/ContinuationIndenter.cpp unittests/Format/FormatTestTextProto.cpp Index: unittests/Format/FormatTestTextProto.cpp =================================================================== --- unittests/Format/FormatTestTextProto.cpp +++ unittests/Format/FormatTestTextProto.cpp @@ -313,5 +313,17 @@ " 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 Index: lib/Format/ContinuationIndenter.cpp =================================================================== --- lib/Format/ContinuationIndenter.cpp +++ lib/Format/ContinuationIndenter.cpp @@ -200,6 +200,7 @@ // 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.
Index: unittests/Format/FormatTestTextProto.cpp =================================================================== --- unittests/Format/FormatTestTextProto.cpp +++ unittests/Format/FormatTestTextProto.cpp @@ -313,5 +313,17 @@ " 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 Index: lib/Format/ContinuationIndenter.cpp =================================================================== --- lib/Format/ContinuationIndenter.cpp +++ lib/Format/ContinuationIndenter.cpp @@ -200,6 +200,7 @@ // 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.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits