HomePhabricator

clang-format: [JS] handle pseudo-keywords.

Authored by mprobst on Apr 6 2020, 6:20 AM.

Description

clang-format: [JS] handle pseudo-keywords.

Summary:
The previous change in https://reviews.llvm.org/D77311 attempted to
detect more C++ keywords. However it also precisely detected all
JavaScript keywords. That's generally correct, but many JavaScripy
keywords, e.g. get, are so-called pseudo-keywords. They can be used in
positions where a keyword would never be legal, e.g. in a dotted
expression:

x.type;  // type is a pseudo-keyword, but can be used here.
x.get;   // same for get etc.

This change introduces an additional parameter to
IsJavaScriptIdentifier, allowing clients to toggle whether they want
to allow IdentifierName tokens, i.e. pseudo-keywords.

Reviewers: krasimir

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D77548