diff options
author | Daniel Jasper <djasper@google.com> | 2015-01-29 10:47:14 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2015-01-29 10:47:14 +0000 |
commit | 47b35aeaa14567eb1b5ed82a73f575f18afe3fa5 (patch) | |
tree | e168e4dc9290a79f96f8f7a9e858c5ca262efb35 /clang/lib/Format | |
parent | 310e3a8f608fbd9162e42cc50fe316af6713113c (diff) | |
download | bcm5719-llvm-47b35aeaa14567eb1b5ed82a73f575f18afe3fa5.tar.gz bcm5719-llvm-47b35aeaa14567eb1b5ed82a73f575f18afe3fa5.zip |
clang-format: Fix crasher caused by not properly setting dry-run.
llvm-svn: 227427
Diffstat (limited to 'clang/lib/Format')
-rw-r--r-- | clang/lib/Format/UnwrappedLineFormatter.cpp | 4 | ||||
-rw-r--r-- | clang/lib/Format/WhitespaceManager.cpp | 5 |
2 files changed, 7 insertions, 2 deletions
diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp b/clang/lib/Format/UnwrappedLineFormatter.cpp index 6c4aadc0f1c..4844b66f9fd 100644 --- a/clang/lib/Format/UnwrappedLineFormatter.cpp +++ b/clang/lib/Format/UnwrappedLineFormatter.cpp @@ -409,7 +409,7 @@ UnwrappedLineFormatter::format(const SmallVectorImpl<AnnotatedLine *> &Lines, TheLine.Type == LT_ImportStatement) { LineState State = Indenter->getInitialState(Indent, &TheLine, DryRun); while (State.NextToken) { - formatChildren(State, /*Newline=*/false, /*DryRun=*/false, Penalty); + formatChildren(State, /*Newline=*/false, DryRun, Penalty); Indenter->addTokenToState(State, /*Newline=*/false, DryRun); } } else if (Style.ColumnLimit == 0) { @@ -657,8 +657,8 @@ void UnwrappedLineFormatter::addNextStateToQueue(unsigned Penalty, bool UnwrappedLineFormatter::formatChildren(LineState &State, bool NewLine, bool DryRun, unsigned &Penalty) { - FormatToken &Previous = *State.NextToken->Previous; const FormatToken *LBrace = State.NextToken->getPreviousNonComment(); + FormatToken &Previous = *State.NextToken->Previous; if (!LBrace || LBrace->isNot(tok::l_brace) || LBrace->BlockKind != BK_Block || Previous.Children.size() == 0) // The previous token does not open a block. Nothing to do. We don't diff --git a/clang/lib/Format/WhitespaceManager.cpp b/clang/lib/Format/WhitespaceManager.cpp index bf1207e59c9..44e5f690a26 100644 --- a/clang/lib/Format/WhitespaceManager.cpp +++ b/clang/lib/Format/WhitespaceManager.cpp @@ -264,6 +264,11 @@ void WhitespaceManager::alignEscapedNewlines(unsigned Start, unsigned End, void WhitespaceManager::generateChanges() { for (unsigned i = 0, e = Changes.size(); i != e; ++i) { const Change &C = Changes[i]; + if (i > 0) { + assert(Changes[i - 1].OriginalWhitespaceRange.getBegin() != + C.OriginalWhitespaceRange.getBegin() && + "Generating two replacements for the same location"); + } if (C.CreateReplacement) { std::string ReplacementText = C.PreviousLinePostfix; if (C.ContinuesPPDirective) |