diff options
author | Martin Probst <martin@probst.io> | 2019-03-19 12:28:41 +0000 |
---|---|---|
committer | Martin Probst <martin@probst.io> | 2019-03-19 12:28:41 +0000 |
commit | 26a484f479d54ea5501628a65b99316e20f3dc99 (patch) | |
tree | b9a8d52e1d48bff20832024588da6e4edc340172 /llvm/lib/Transforms/Utils/Local.cpp | |
parent | 9497b2b2f7212896493756137cf9aa13bc1dede6 (diff) | |
download | llvm-26a484f479d54ea5501628a65b99316e20f3dc99.zip llvm-26a484f479d54ea5501628a65b99316e20f3dc99.tar.gz llvm-26a484f479d54ea5501628a65b99316e20f3dc99.tar.bz2 |
[clang-format] [JS] handle private members.
Addresses PR40999 https://bugs.llvm.org/show_bug.cgi?id=40999
Private fields and methods in JavaScript would get incorrectly indented
(it sees them as preprocessor directives and hence left aligns them)
In this revision `#identifier` tokens `tok::hash->tok::identifier` are
merged into a single new token `tok::identifier` with the `#` contained
inside the TokenText.
Before:
```
class Example {
pub = 1;
static pub2 = "foo";
static #priv2 = "bar";
method() { this.#priv = 5; }
static staticMethod() {
switch (this.#priv) {
case '1':
break;
}
}
this.#privateMethod(); // infinite loop
}
static #staticPrivateMethod() {}
}
```
After this fix the code will be correctly indented
```
class Example {
pub = 1;
#priv = 2;
static pub2 = "foo";
static #priv2 = "bar";
method() { this.#priv = 5; }
static staticMethod() {
switch (this.#priv) {
case '1':
#priv = 3;
break;
}
}
#privateMethod() {
this.#privateMethod(); // infinite loop
}
static #staticPrivateMethod() {}
}
```
NOTE: There might be some JavaScript code out there which uses the C
processor to preprocess .js files
http://www.nongnu.org/espresso/js-cpp.html. It's not clear how this
revision or even private fields and methods would interact.
Patch originally by MyDeveloperDays (thanks!).
llvm-svn: 356449
Diffstat (limited to 'llvm/lib/Transforms/Utils/Local.cpp')
0 files changed, 0 insertions, 0 deletions