diff options
author | Daniel Jasper <djasper@google.com> | 2017-06-19 07:45:41 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2017-06-19 07:45:41 +0000 |
commit | f92659e4ea0196d081ff714220e004f63d7fc5ef (patch) | |
tree | f504a332dc864c5e8f2dc7b801a31ebaed805dbd /clang/lib/Format | |
parent | 6a7d5a7a22a6522e0bfb7e60b3a15acb2eed2f60 (diff) | |
download | bcm5719-llvm-f92659e4ea0196d081ff714220e004f63d7fc5ef.tar.gz bcm5719-llvm-f92659e4ea0196d081ff714220e004f63d7fc5ef.zip |
clang-format: Improve understanding of combined typedef+record declarations
Fixes an issue where struct A { int X; }; would be broken onto multiple
lines, but typedef struct A { int X; } A2; was collapsed onto a single
line.
Patch by Jacob Bandes-Storch. Thank you.
llvm-svn: 305667
Diffstat (limited to 'clang/lib/Format')
-rw-r--r-- | clang/lib/Format/UnwrappedLineFormatter.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp b/clang/lib/Format/UnwrappedLineFormatter.cpp index 7f644651a6a..63a0b7df59f 100644 --- a/clang/lib/Format/UnwrappedLineFormatter.cpp +++ b/clang/lib/Format/UnwrappedLineFormatter.cpp @@ -434,8 +434,11 @@ private: } else if (Limit != 0 && !Line.startsWith(tok::kw_namespace) && !startsExternCBlock(Line)) { // We don't merge short records. - if (Line.First->isOneOf(tok::kw_class, tok::kw_union, tok::kw_struct, - Keywords.kw_interface)) + FormatToken *RecordTok = + Line.First->is(tok::kw_typedef) ? Line.First->Next : Line.First; + if (RecordTok && + RecordTok->isOneOf(tok::kw_class, tok::kw_union, tok::kw_struct, + Keywords.kw_interface)) return 0; // Check that we still have three lines and they fit into the limit. |