summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2013-02-23 07:46:38 +0000
committerDaniel Jasper <djasper@google.com>2013-02-23 07:46:38 +0000
commitaf5ba0ed8cb742475d8de6c6f4e5718b8ebbf34c (patch)
tree89e6dbdab2bb18d20b70e9334d483f42cb072e64 /clang/lib
parent4e80d9e853b15e4386d921fb889b1ce8769cc27f (diff)
downloadbcm5719-llvm-af5ba0ed8cb742475d8de6c6f4e5718b8ebbf34c.tar.gz
bcm5719-llvm-af5ba0ed8cb742475d8de6c6f4e5718b8ebbf34c.zip
Allow splitting between string literals and identifiers.
Also don't break in long include directives as that is not desired. We can now format: #include "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aaaaaaaaaaaaaaaaaaaaaaaaaaaaa" #define LL_FORMAT "ll" printf("aaaaa: %d, bbbbbbbbb: %" LL_FORMAT "d, cccccccc: %" LL_FORMAT "d, ddddddddd: %" LL_FORMAT "d\n"); Before, this led to weird results. llvm-svn: 175959
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 9a52f826571..359923f02f8 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -415,6 +415,10 @@ private:
}
} else {
while (CurrentToken != NULL) {
+ if (CurrentToken->is(tok::string_literal))
+ // Mark these string literals as "implicit" literals, too, so that
+ // they are not split or line-wrapped.
+ CurrentToken->Type = TT_ImplicitStringLiteral;
next();
}
}
@@ -1098,6 +1102,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
if (Right.is(tok::r_paren) || Right.is(tok::greater))
return false;
+ if (Left.is(tok::identifier) && Right.is(tok::string_literal))
+ return true;
return (isBinaryOperator(Left) && Left.isNot(tok::lessless)) ||
Left.is(tok::comma) || Right.is(tok::lessless) ||
Right.is(tok::arrow) || Right.is(tok::period) ||
OpenPOWER on IntegriCloud