[PATCH] D71239: [clang-format] Fix ObjC keywords following try/catch getting split.
MyDeveloperDay via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue May 5 03:12:01 PDT 2020
MyDeveloperDay added a comment.
bool FormatTokenLexer::tryMergeAtTry() {
if (Tokens.size() < 2)
return false;
auto &At = *(Tokens.end() - 2);
auto &Try = *(Tokens.end() - 1);
if (!At->is(tok::at) || !String->is(tok::try))
return false;
At->Tok.setKind(tok::try);
At->TokenText = StringRef(At->TokenText.begin(),
String->TokenText.end() - At->TokenText.begin());
At->ColumnWidth += String->ColumnWidth;
Tokens.erase(Tokens.end() - 1);
return true;
}
bool FormatTokenLexer::tryMergeAtCatch() {
if (Tokens.size() < 2)
return false;
auto &At = *(Tokens.end() - 2);
auto &Try = *(Tokens.end() - 1);
if (!At->is(tok::at) || !String->is(tok::catch))
return false;
At->Tok.setKind(tok::catch);
At->TokenText = StringRef(At->TokenText.begin(),
String->TokenText.end() - At->TokenText.begin());
At->ColumnWidth += String->ColumnWidth;
Tokens.erase(Tokens.end() - 1);
return true;
}
I think adding these 2 functions could help to always treat @try and @catch the same as you we do `try` and `catch` (and any rules they have like `BeforeCatch` etc..
Did you consider doing that or are you not pursuing this patch any more?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D71239/new/
https://reviews.llvm.org/D71239
More information about the cfe-commits
mailing list