diff options
author | Krasimir Georgiev <krasimir@google.com> | 2017-10-02 15:53:37 +0000 |
---|---|---|
committer | Krasimir Georgiev <krasimir@google.com> | 2017-10-02 15:53:37 +0000 |
commit | 6a1c9d51fa55131ba5964a622355e5e8bbce04c9 (patch) | |
tree | ff5c9d7d9d4a90404d9241e4daa6799a04440710 /clang/lib/Format | |
parent | 65bde8806f7dad39fce95d09aa11d7cd11005bc6 (diff) | |
download | bcm5719-llvm-6a1c9d51fa55131ba5964a622355e5e8bbce04c9.tar.gz bcm5719-llvm-6a1c9d51fa55131ba5964a622355e5e8bbce04c9.zip |
[clang-format] Fix regression about short functions after #else
Summary:
This patch fixes a regression introduced in r312904, where the formatter confuses
the `else` in `#else` with an `else` of an `if-else` statement.
For example, formatting this code with google style
```
#ifdef A
int f() {}
#else
int f() {}
#endif
```
resulted in
```
#ifdef A
int f() {}
#else
int f() {
}
#endif
```
Reviewers: sammccall
Reviewed By: sammccall
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D37973
llvm-svn: 314683
Diffstat (limited to 'clang/lib/Format')
-rw-r--r-- | clang/lib/Format/UnwrappedLineFormatter.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp b/clang/lib/Format/UnwrappedLineFormatter.cpp index 6c75adaddc7..d25f0a1c29c 100644 --- a/clang/lib/Format/UnwrappedLineFormatter.cpp +++ b/clang/lib/Format/UnwrappedLineFormatter.cpp @@ -466,8 +466,7 @@ private: // Check that the current line allows merging. This depends on whether we // are in a control flow statements as well as several style flags. if (Line.First->isOneOf(tok::kw_else, tok::kw_case) || - (Line.First->Next && Line.First->Next->is(tok::kw_else)) || - (I != AnnotatedLines.begin() && I[-1]->Last->is(tok::kw_else))) + (Line.First->Next && Line.First->Next->is(tok::kw_else))) return 0; if (Line.First->isOneOf(tok::kw_if, tok::kw_while, tok::kw_do, tok::kw_try, tok::kw___try, tok::kw_catch, tok::kw___finally, |