summaryrefslogtreecommitdiffstats
path: root/clang/lib/Format
diff options
context:
space:
mode:
authorMartin Probst <martin@probst.io>2017-07-03 14:29:13 +0000
committerMartin Probst <martin@probst.io>2017-07-03 14:29:13 +0000
commitbd1eb12d3179f691a5c18e48f601f6005be70d14 (patch)
tree4c034267b25f56955ad7757299d243e9ba8fc016 /clang/lib/Format
parent448095c19bc0ec5a6d714f42bbb1aa349d282099 (diff)
downloadbcm5719-llvm-bd1eb12d3179f691a5c18e48f601f6005be70d14.tar.gz
bcm5719-llvm-bd1eb12d3179f691a5c18e48f601f6005be70d14.zip
clang-format: [JS] space between pseudo keywords and template literals.
Summary: Before: yield`foo`; After: yield `foo`; Reviewers: djasper Subscribers: klimek Differential Revision: https://reviews.llvm.org/D34938 llvm-svn: 307023
Diffstat (limited to 'clang/lib/Format')
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index d78a37532fe..471f7e13585 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2300,7 +2300,11 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
if ((Left.is(TT_TemplateString) && Left.TokenText.endswith("${")) ||
(Right.is(TT_TemplateString) && Right.TokenText.startswith("}")))
return false;
- if (Left.is(tok::identifier) && Right.is(TT_TemplateString))
+ // In tagged template literals ("html`bar baz`"), there is no space between
+ // the tag identifier and the template string. getIdentifierInfo makes sure
+ // that the identifier is not a pseudo keyword like `yield`, either.
+ if (Left.is(tok::identifier) && Left.Tok.getIdentifierInfo() == nullptr &&
+ Right.is(TT_TemplateString))
return false;
if (Right.is(tok::star) &&
Left.isOneOf(Keywords.kw_function, Keywords.kw_yield))
OpenPOWER on IntegriCloud