Index: clang/lib/Format/UnwrappedLineParser.cpp =================================================================== --- clang/lib/Format/UnwrappedLineParser.cpp +++ clang/lib/Format/UnwrappedLineParser.cpp @@ -1085,13 +1085,8 @@ if (FormatTok->Tok.is(tok::string_literal)) { nextToken(); if (FormatTok->Tok.is(tok::l_brace)) { - if (Style.BraceWrapping.AfterExternBlock && - Style.BraceWrapping.AfterNamespace) { - addUnwrappedLine(); + if (Style.BraceWrapping.AfterExternBlock) { parseBlock(/*MustBeDeclaration=*/true); - } else if (Style.BraceWrapping.AfterExternBlock && - Style.BraceWrapping.AfterNamespace == false) { - parseBlock(/*MustBeDeclaration=*/false); } else { parseBlock(/*MustBeDeclaration=*/true, /*AddLevel=*/false); } Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -2462,14 +2462,18 @@ Style.BraceWrapping.AfterExternBlock = true; Style.BraceWrapping.SplitEmptyRecord = false; - verifyFormat("extern \"C\"\n" - "{}", - Style); - verifyFormat("extern \"C\"\n" - "{\n" + verifyFormat("extern \"C\" {}", Style); + verifyFormat("extern \"C\" {\n" " int foo();\n" "}", Style); + + Style.BraceWrapping.AfterExternBlock = false; + verifyFormat("extern \"C\" {}", Style); + verifyFormat("extern \"C\" {\n" + "int foo();\n" + "}", + Style); } TEST_F(FormatTest, FormatsInlineASM) {