diff options
| author | Martin Probst <martin@probst.io> | 2017-07-03 14:29:13 +0000 |
|---|---|---|
| committer | Martin Probst <martin@probst.io> | 2017-07-03 14:29:13 +0000 |
| commit | bd1eb12d3179f691a5c18e48f601f6005be70d14 (patch) | |
| tree | 4c034267b25f56955ad7757299d243e9ba8fc016 /clang/lib/Format | |
| parent | 448095c19bc0ec5a6d714f42bbb1aa349d282099 (diff) | |
| download | bcm5719-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.cpp | 6 |
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)) |

