diff options
author | Daniel Jasper <djasper@google.com> | 2013-08-23 10:05:49 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-08-23 10:05:49 +0000 |
commit | ed51c02f4c87ddb2d2f45193e4041921ac363f76 (patch) | |
tree | 145f13ac6960ec597e557d9205a2467c0f22d0b3 /lib/Format/FormatToken.cpp | |
parent | 034457d1b022decb5bac4315ea6839025eab4634 (diff) |
clang-format: Handle trailing commas in column layout of braced list.
Before, this was causing errors.
Also exit early in breakProtrudingToken() (before the expensive call to
SourceManager::getSpellingColumnNumber()). This makes formatting huge
(100k+-item) braced lists possible.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@189094 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/FormatToken.cpp')
-rw-r--r-- | lib/Format/FormatToken.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/Format/FormatToken.cpp b/lib/Format/FormatToken.cpp index 4e232afda5..1b6d360190 100644 --- a/lib/Format/FormatToken.cpp +++ b/lib/Format/FormatToken.cpp @@ -92,6 +92,11 @@ void CommaSeparatedList::precomputeFormattingInfos(const FormatToken *Token) { SmallVector<unsigned, 8> EndOfLineItemLength; for (unsigned i = 0, e = Commas.size() + 1; i != e; ++i) { + // If there is a trailing comma in the list, the next item will start at the + // closing brace. Don't create an extra item for this. + if (ItemBegin == Token->MatchingParen) + break; + // Skip comments on their own line. while (ItemBegin->HasUnescapedNewline && ItemBegin->isTrailingComment()) ItemBegin = ItemBegin->Next; |