[cfe-commits] r172537 - /cfe/trunk/lib/Format/Format.cpp
Manuel Klimek
klimek at google.com
Tue Jan 15 08:41:02 PST 2013
Author: klimek
Date: Tue Jan 15 10:41:02 2013
New Revision: 172537
URL: http://llvm.org/viewvc/llvm-project?rev=172537&view=rev
Log:
Do not traverse the break-state when we know we cannot break anyway.
This is an optimization that djasper spottet. For now, we do not format
anything after the first token that belongs to such an implicit string
literal. All our state is not made for handling that anyway, so we'll
revisit this if we find a problem.
Modified:
cfe/trunk/lib/Format/Format.cpp
Modified: cfe/trunk/lib/Format/Format.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=172537&r1=172536&r2=172537&view=diff
==============================================================================
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Tue Jan 15 10:41:02 2013
@@ -253,6 +253,12 @@
// Start iterating at 1 as we have correctly formatted of Token #0 above.
while (State.NextToken != NULL) {
+ if (State.NextToken->Type == TT_ImplicitStringLiteral)
+ // We will not touch the rest of the white space in this
+ // \c UnwrappedLine. The returned value can also not matter, as we
+ // cannot continue an top-level implicit string literal on the next
+ // line.
+ return 0;
if (FitsOnALine) {
addTokenToState(false, false, State);
} else {
@@ -374,11 +380,6 @@
assert(State.Stack.size());
unsigned ParenLevel = State.Stack.size() - 1;
- if (Current.Type == TT_ImplicitStringLiteral) {
- moveStateToNextToken(State);
- return;
- }
-
if (Newline) {
unsigned WhitespaceStartColumn = State.Column;
if (Current.is(tok::r_brace)) {
More information about the cfe-commits
mailing list