summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTest.cpp
diff options
context:
space:
mode:
authorPaul Hoad <mydeveloperday@gmail.com>2019-09-12 10:07:14 +0000
committerPaul Hoad <mydeveloperday@gmail.com>2019-09-12 10:07:14 +0000
commit3867a2d51076494a19c02a2d5c4e4167bd6cbe0e (patch)
tree3fab02b769d07df0c08176b4c6831a46bb868703 /clang/unittests/Format/FormatTest.cpp
parentf1286621eb9672c07a67075624f97310eadd2632 (diff)
downloadbcm5719-llvm-3867a2d51076494a19c02a2d5c4e4167bd6cbe0e.tar.gz
bcm5719-llvm-3867a2d51076494a19c02a2d5c4e4167bd6cbe0e.zip
[clang-format] Add new style option IndentGotoLabels
Summary: This option determines whether goto labels are indented according to scope. Setting this option to false causes goto labels to be flushed to the left. This is mostly copied from [[ http://lists.llvm.org/pipermail/cfe-dev/2015-September/045014.html | this patch ]] submitted by Christian Neukirchen that didn't make its way into trunk. ``` true: false: int f() { vs. int f() { if (foo()) { if (foo()) { label1: label1: bar(); bar(); } } label2: label2: return 1; return 1; } } ``` Reviewers: klimek, MyDeveloperDay Reviewed By: MyDeveloperDay Subscribers: cfe-commits Tags: #clang, #clang-tools-extra Patch by: tetsuo-cpp Differential Revision: https://reviews.llvm.org/D67037 llvm-svn: 371719
Diffstat (limited to 'clang/unittests/Format/FormatTest.cpp')
-rw-r--r--clang/unittests/Format/FormatTest.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 7869cc568ae..f1a1160fa14 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -1408,6 +1408,30 @@ TEST_F(FormatTest, FormatsLabels) {
"test_label:;\n"
" int i = 0;\n"
"}");
+ FormatStyle Style = getLLVMStyle();
+ Style.IndentGotoLabels = false;
+ verifyFormat("void f() {\n"
+ " some_code();\n"
+ "test_label:\n"
+ " some_other_code();\n"
+ " {\n"
+ " some_more_code();\n"
+ "another_label:\n"
+ " some_more_code();\n"
+ " }\n"
+ "}",
+ Style);
+ verifyFormat("{\n"
+ " some_code();\n"
+ "test_label:\n"
+ " some_other_code();\n"
+ "}",
+ Style);
+ verifyFormat("{\n"
+ " some_code();\n"
+ "test_label:;\n"
+ " int i = 0;\n"
+ "}");
}
//===----------------------------------------------------------------------===//
@@ -11779,6 +11803,7 @@ TEST_F(FormatTest, ParsesConfigurationBools) {
CHECK_PARSE_BOOL_FIELD(DerivePointerAlignment, "DerivePointerBinding");
CHECK_PARSE_BOOL(DisableFormat);
CHECK_PARSE_BOOL(IndentCaseLabels);
+ CHECK_PARSE_BOOL(IndentGotoLabels);
CHECK_PARSE_BOOL(IndentWrappedFunctionNames);
CHECK_PARSE_BOOL(KeepEmptyLinesAtTheStartOfBlocks);
CHECK_PARSE_BOOL(ObjCSpaceAfterProperty);
OpenPOWER on IntegriCloud