summaryrefslogtreecommitdiffstats
path: root/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
commit71d3b5cd916106005ef23467e3f6c7fbca7bc499 (patch)
treefd8b90b7ad407a7248ecece059e8183fdaa4c5a9 /lib/Format
parent0305311a4e50b9a1d54a9a1d050d93754f26f9cf (diff)
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 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@307023 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Format')
-rw-r--r--lib/Format/TokenAnnotator.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp
index d78a37532f..471f7e1358 100644
--- a/lib/Format/TokenAnnotator.cpp
+++ b/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))