diff options
author | Krasimir Georgiev <krasimir@google.com> | 2017-09-15 11:23:50 +0000 |
---|---|---|
committer | Krasimir Georgiev <krasimir@google.com> | 2017-09-15 11:23:50 +0000 |
commit | d6ce937f495cab544058616404148381f4e77fad (patch) | |
tree | 4d95c80af20859f0ee8233d7700631a3a1fe35b1 /clang/lib/Format/UnwrappedLineParser.cpp | |
parent | 905e79c4dc3e4babb0249182043ca695d4f8eaba (diff) | |
download | bcm5719-llvm-d6ce937f495cab544058616404148381f4e77fad.tar.gz bcm5719-llvm-d6ce937f495cab544058616404148381f4e77fad.zip |
[clang-format] New flag - BraceWrapping.AfterExternBlock
Summary:
Bug: https://bugs.llvm.org/show_bug.cgi?id=34016 - **"extern C part"**
**Problem:**
Due to the lack of "brace wrapping extern" flag, clang format does parse the block after **extern** keyword moving the opening bracket to the header line always!
**Patch description:**
A new style added, new configuration flag - **BraceWrapping.AfterExternBlock** that allows us to decide whether we want a break before brace or not.
Reviewers: djasper, krasimir
Reviewed By: krasimir
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D37845
Contributed by @PriMee!
llvm-svn: 313354
Diffstat (limited to 'clang/lib/Format/UnwrappedLineParser.cpp')
-rw-r--r-- | clang/lib/Format/UnwrappedLineParser.cpp | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp index b15e52aeb2c..40d133ff0dd 100644 --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -1039,7 +1039,12 @@ void UnwrappedLineParser::parseStructuralElement() { if (FormatTok->Tok.is(tok::string_literal)) { nextToken(); if (FormatTok->Tok.is(tok::l_brace)) { - parseBlock(/*MustBeDeclaration=*/true, /*AddLevel=*/false); + if (Style.BraceWrapping.AfterExternBlock) { + addUnwrappedLine(); + parseBlock(/*MustBeDeclaration=*/true); + } else { + parseBlock(/*MustBeDeclaration=*/true, /*AddLevel=*/false); + } addUnwrappedLine(); return; } |