summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManuel Klimek <klimek@google.com>2013-01-15 16:41:02 +0000
committerManuel Klimek <klimek@google.com>2013-01-15 16:41:02 +0000
commita31e58b2dfe6b572c7e89c014d949d086c407066 (patch)
tree2ccb4e94b269860f4fd897022ff4df28fe8b2561
parent99c7baa3cfdfa73a683b65d371162cfa766ae8c0 (diff)
downloadbcm5719-llvm-a31e58b2dfe6b572c7e89c014d949d086c407066.tar.gz
bcm5719-llvm-a31e58b2dfe6b572c7e89c014d949d086c407066.zip
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. llvm-svn: 172537
-rw-r--r--clang/lib/Format/Format.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index a6b9e2031d3..445a4064b46 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -253,6 +253,12 @@ public:
// 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 @@ private:
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)) {
OpenPOWER on IntegriCloud