diff options
author | Daniel Jasper <djasper@google.com> | 2017-01-31 12:07:35 +0000 |
---|---|---|
committer | Daniel Jasper <djasper@google.com> | 2017-01-31 12:07:35 +0000 |
commit | f201929010030af03686334aeb906f9570f17843 (patch) | |
tree | 572c3651ed7b9d9af47a084f216517d5bd826e2b /clang/lib/Format/TokenAnnotator.cpp | |
parent | 8f62cf74ef3377f01b81c909a8de6cbffa2c9cb4 (diff) | |
download | bcm5719-llvm-f201929010030af03686334aeb906f9570f17843.tar.gz bcm5719-llvm-f201929010030af03686334aeb906f9570f17843.zip |
clang-format: [JS] Fix incorrect line break in template strings.
Before:
var f = `aaaa ${a ? 'a' : 'b'
}`;
After:
var f = `aaaa ${a ? 'a' : 'b'}`;
llvm-svn: 293618
Diffstat (limited to 'clang/lib/Format/TokenAnnotator.cpp')
-rw-r--r-- | clang/lib/Format/TokenAnnotator.cpp | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp index 61d14432561..e58ca6d803e 100644 --- a/clang/lib/Format/TokenAnnotator.cpp +++ b/clang/lib/Format/TokenAnnotator.cpp @@ -2388,6 +2388,11 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line, if (Right.is(tok::plus) && Left.is(tok::string_literal) && Right.Next && Right.Next->is(tok::string_literal)) return true; + } else if (Style.Language == FormatStyle::LK_Cpp || + Style.Language == FormatStyle::LK_ObjC) { + if (Left.isStringLiteral() && + (Right.isStringLiteral() || Right.is(TT_ObjCStringLiteral))) + return true; } // If the last token before a '}' is a comma or a trailing comment, the @@ -2411,9 +2416,6 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line, (Right.NewlinesBefore > 0 && Right.HasUnescapedNewline); if (Left.isTrailingComment()) return true; - if (Left.isStringLiteral() && - (Right.isStringLiteral() || Right.is(TT_ObjCStringLiteral))) - return true; if (Right.Previous->IsUnterminatedLiteral) return true; if (Right.is(tok::lessless) && Right.Next && |