[PATCH] D75410: Fixed Extern Block Indentation in libFormat
Marcus Johnson via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Feb 29 11:10:18 PST 2020
MarcusJohnson91 created this revision.
MarcusJohnson91 added reviewers: clang, clang-tools-extra, clang-format.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
Not sure what else to say
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D75410
Files:
clang/docs/ClangFormatStyleOptions.rst
clang/include/clang/Format/Format.h
clang/lib/Format/UnwrappedLineParser.cpp
Index: clang/lib/Format/UnwrappedLineParser.cpp
===================================================================
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1085,9 +1085,11 @@
if (FormatTok->Tok.is(tok::string_literal)) {
nextToken();
if (FormatTok->Tok.is(tok::l_brace)) {
- if (Style.BraceWrapping.AfterExternBlock) {
+ if (Style.BraceWrapping.AfterExternBlock && Style.BraceWrapping.AfterNamespace) {
addUnwrappedLine();
parseBlock(/*MustBeDeclaration=*/true);
+ } else if (Style.BraceWrapping.AfterExternBlock && Style.BraceWrapping.AfterNamespace == false) {
+ parseBlock(/*MustBeDeclaration=*/false);
} 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``.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D75410.247453.patch
Type: text/x-patch
Size: 2212 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200229/d38f23bc/attachment.bin>
More information about the cfe-commits
mailing list