summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Format/Format.cpp4
-rw-r--r--clang/unittests/Format/FormatTest.cpp13
2 files changed, 15 insertions, 2 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index e9a02a00a43..6bfd9cb5cec 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -372,6 +372,8 @@ std::string ParseErrorCategory::message(int EV) const {
}
static FormatStyle expandPresets(const FormatStyle &Style) {
+ if (Style.BreakBeforeBraces == FormatStyle::BS_Custom)
+ return Style;
FormatStyle Expanded = Style;
Expanded.BraceWrapping = {false, false, false, false, false, false,
false, false, false, false, false};
@@ -442,6 +444,8 @@ FormatStyle getLLVMStyle() {
LLVMStyle.BreakBeforeBinaryOperators = FormatStyle::BOS_None;
LLVMStyle.BreakBeforeTernaryOperators = true;
LLVMStyle.BreakBeforeBraces = FormatStyle::BS_Attach;
+ LLVMStyle.BraceWrapping = {false, false, false, false, false, false,
+ false, false, false, false, false};
LLVMStyle.BreakConstructorInitializersBeforeComma = false;
LLVMStyle.ColumnLimit = 80;
LLVMStyle.CommentPragmas = "^ IWYU pragma:";
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index ff9d2d473ff..00f87ba9515 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -2332,8 +2332,8 @@ TEST_F(FormatTest, IncompleteTryCatchBlocks) {
TEST_F(FormatTest, FormatTryCatchBraceStyles) {
FormatStyle Style = getLLVMStyle();
- for (auto BraceStyle :
- {FormatStyle::BS_Attach, FormatStyle::BS_Mozilla, FormatStyle::BS_WebKit}) {
+ for (auto BraceStyle : {FormatStyle::BS_Attach, FormatStyle::BS_Mozilla,
+ FormatStyle::BS_WebKit}) {
Style.BreakBeforeBraces = BraceStyle;
verifyFormat("try {\n"
" // something\n"
@@ -2384,6 +2384,15 @@ TEST_F(FormatTest, FormatTryCatchBraceStyles) {
" // something\n"
" }",
Style);
+ Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+ Style.BraceWrapping.BeforeCatch = true;
+ verifyFormat("try {\n"
+ " // something\n"
+ "}\n"
+ "catch (...) {\n"
+ " // something\n"
+ "}",
+ Style);
}
TEST_F(FormatTest, FormatObjCTryCatch) {
OpenPOWER on IntegriCloud