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``.
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``.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org