[all-commits] [llvm/llvm-project] 922015: clang-format: [JS] handle pseudo-keywords.

Martin Probst via All-commits all-commits at lists.llvm.org
Mon Apr 6 08:13:12 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 92201505cdecd8ba5795f5e33821c49dc57f0816
      https://github.com/llvm/llvm-project/commit/92201505cdecd8ba5795f5e33821c49dc57f0816
  Author: Martin Probst <martin at probst.io>
  Date:   2020-04-06 (Mon, 06 Apr 2020)

  Changed paths:
    M clang/lib/Format/FormatToken.h
    M clang/lib/Format/TokenAnnotator.cpp
    M clang/unittests/Format/FormatTestJS.cpp

  Log Message:
  -----------
  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




More information about the All-commits mailing list