Index: clang/lib/Format/UnwrappedLineParser.cpp =================================================================== --- clang/lib/Format/UnwrappedLineParser.cpp +++ clang/lib/Format/UnwrappedLineParser.cpp @@ -1282,10 +1282,10 @@ if (FormatTok->Tok.is(tok::string_literal)) { nextToken(); if (FormatTok->Tok.is(tok::l_brace)) { + if (Style.BraceWrapping.AfterExternBlock) { + addUnwrappedLine(); + } if (!Style.IndentExternBlock) { - if (Style.BraceWrapping.AfterExternBlock) { - addUnwrappedLine(); - } unsigned AddLevels = Style.BraceWrapping.AfterExternBlock ? 1u : 0u; parseBlock(/*MustBeDeclaration=*/true, AddLevels); } else { Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -3811,6 +3811,26 @@ "int foo16();\n" "}", Style); + + Style.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock; + Style.BreakBeforeBraces = FormatStyle::BS_Custom; + Style.BraceWrapping.AfterExternBlock = true; + Style.IndentExternBlock = FormatStyle::IEBS_NoIndent; + verifyFormat("extern \"C\"\n{ /*13*/\n}", Style); + verifyFormat("extern \"C\"\n{\n" + "int foo14();\n" + "}", + Style); + + Style.IndentExternBlock = FormatStyle::IEBS_AfterExternBlock; + Style.BreakBeforeBraces = FormatStyle::BS_Custom; + Style.BraceWrapping.AfterExternBlock = true; + Style.IndentExternBlock = FormatStyle::IEBS_Indent; + verifyFormat("extern \"C\"\n{ /*13*/\n}", Style); + verifyFormat("extern \"C\"\n{\n" + " int foo14();\n" + "}", + Style); } TEST_F(FormatTest, FormatsInlineASM) {