[PATCH] D75410: Fixed Extern Block Indentation in libFormat

2020-02-29 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 updated this revision to Diff 247457.
MarcusJohnson91 added a comment.

Clang-Formatted UnwrappedLineParser.cpp


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75410/new/

https://reviews.llvm.org/D75410

Files:
  clang/lib/Format/UnwrappedLineParser.cpp


Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1085,10 +1085,12 @@
 if (FormatTok->Tok.is(tok::string_literal)) {
   nextToken();
   if (FormatTok->Tok.is(tok::l_brace)) {
-if (Style.BraceWrapping.AfterExternBlock && 
Style.BraceWrapping.AfterNamespace) {
+if (Style.BraceWrapping.AfterExternBlock &&
+Style.BraceWrapping.AfterNamespace) {
   addUnwrappedLine();
   parseBlock(/*MustBeDeclaration=*/true);
-} else if (Style.BraceWrapping.AfterExternBlock && 
Style.BraceWrapping.AfterNamespace == false) {
+} else if (Style.BraceWrapping.AfterExternBlock &&
+   Style.BraceWrapping.AfterNamespace == false) {
   parseBlock(/*MustBeDeclaration=*/false);
 } else {
   parseBlock(/*MustBeDeclaration=*/true, /*AddLevel=*/false);


Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -1085,10 +1085,12 @@
 if (FormatTok->Tok.is(tok::string_literal)) {
   nextToken();
   if (FormatTok->Tok.is(tok::l_brace)) {
-if (Style.BraceWrapping.AfterExternBlock && Style.BraceWrapping.AfterNamespace) {
+if (Style.BraceWrapping.AfterExternBlock &&
+Style.BraceWrapping.AfterNamespace) {
   addUnwrappedLine();
   parseBlock(/*MustBeDeclaration=*/true);
-} else if (Style.BraceWrapping.AfterExternBlock && Style.BraceWrapping.AfterNamespace == false) {
+} else if (Style.BraceWrapping.AfterExternBlock &&
+   Style.BraceWrapping.AfterNamespace == false) {
   parseBlock(/*MustBeDeclaration=*/false);
 } else {
   parseBlock(/*MustBeDeclaration=*/true, /*AddLevel=*/false);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75410: Fixed Extern Block Indentation in libFormat

2020-02-29 Thread Marcus Johnson via Phabricator via cfe-commits
MarcusJohnson91 added a comment.

Not sure why it failed to compile, it compiles just fine on my machine...

I'm gonna re-pull from master and see if it works.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D75410/new/

https://reviews.llvm.org/D75410



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D75410: Fixed Extern Block Indentation in libFormat

2020-02-29 Thread Marcus Johnson via Phabricator via cfe-commits
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