MarcusJohnson91 updated this revision to Diff 247524. MarcusJohnson91 added a comment.
Full Context Diff (I think?) CHANGES SINCE LAST ACTION https://reviews.llvm.org/D75410/new/ https://reviews.llvm.org/D75410 Files: clang/docs/ClangFormatStyleOptions.rst clang/include/clang/Format/Format.h clang/lib/Format/UnwrappedLineParser.cpp clang/unittests/Format/FormatTest.cpp
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) { Index: clang/lib/Format/UnwrappedLineParser.cpp =================================================================== --- clang/lib/Format/UnwrappedLineParser.cpp +++ clang/lib/Format/UnwrappedLineParser.cpp @@ -1086,7 +1086,6 @@ nextToken(); if (FormatTok->Tok.is(tok::l_brace)) { if (Style.BraceWrapping.AfterExternBlock) { - addUnwrappedLine(); parseBlock(/*MustBeDeclaration=*/true); } else { parseBlock(/*MustBeDeclaration=*/true, /*AddLevel=*/false); Index: clang/include/clang/Format/Format.h =================================================================== --- clang/include/clang/Format/Format.h +++ clang/include/clang/Format/Format.h @@ -977,6 +977,29 @@ /// } catch () { /// } /// \endcode + /// \code + /// true: + /// #ifdef __cplusplus + /// extern "C" { + /// #endif + /// + /// void f(void); + /// + /// #ifdef __cplusplus + /// } + /// #endif + /// + /// false: + /// #ifdef __cplusplus + /// extern "C" { + /// #endif + /// + /// void f(void); + /// + /// #ifdef __cplusplus + /// } + /// #endif + /// \endcode bool BeforeCatch; /// Wrap before ``else``. /// \code Index: clang/docs/ClangFormatStyleOptions.rst =================================================================== --- clang/docs/ClangFormatStyleOptions.rst +++ clang/docs/ClangFormatStyleOptions.rst @@ -935,6 +935,28 @@ extern "C" { int foo(); } + + true: + #ifdef __cplusplus + extern "C" { + #endif + + void f(void); + + #ifdef __cplusplus + } + #endif + + false: + #ifdef __cplusplus + extern "C" { + #endif + + void f(void); + + #ifdef __cplusplus + } + #endif * ``bool BeforeCatch`` Wrap before ``catch``.
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits