aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Format/FormatTestJS.cpp
diff options
context:
space:
mode:
authorMartin Probst <martin@probst.io>2020-04-06 15:20:54 +0200
committerMartin Probst <martin@probst.io>2020-04-06 17:13:04 +0200
commit92201505cdecd8ba5795f5e33821c49dc57f0816 (patch)
tree0527074e355256be3d03644c9c3f93d4c1347f71 /clang/unittests/Format/FormatTestJS.cpp
parentab1fad8a3a8b8e3264c34448205061add013b8d7 (diff)
downloadllvm-92201505cdecd8ba5795f5e33821c49dc57f0816.zip
llvm-92201505cdecd8ba5795f5e33821c49dc57f0816.tar.gz
llvm-92201505cdecd8ba5795f5e33821c49dc57f0816.tar.bz2
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
Diffstat (limited to 'clang/unittests/Format/FormatTestJS.cpp')
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index 3fd795c..eadea35 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -2412,6 +2412,11 @@ TEST_F(FormatTestJS, CppKeywords) {
verifyFormat("using!;");
verifyFormat("virtual!;");
verifyFormat("wchar_t!;");
+
+ // Positive tests:
+ verifyFormat("x.type!;");
+ verifyFormat("x.get!;");
+ verifyFormat("x.set!;");
}
TEST_F(FormatTestJS, NullPropagatingOperator) {