diff options
author | Daniel Jasper <djasper@google.com> | 2013-02-23 07:46:38 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2013-02-23 07:46:38 +0000 |
commit | 3a204418482c9ae70ad482e781132c54306c3aa6 (patch) | |
tree | 3e3ae9f1d077aaed04020e436e6ebd4dfe30a67e /lib/Format/TokenAnnotator.cpp | |
parent | a8f7a97a22d1ed92fd3309f071c0121c22e52aa3 (diff) |
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.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175959 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format/TokenAnnotator.cpp')
-rw-r--r-- | lib/Format/TokenAnnotator.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 9a52f82657..359923f02f 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/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) || |