[PATCH] D72401: Fixes for spaces around C# object initializers
Krasimir Georgiev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 11 02:41:17 PST 2020
krasimir requested changes to this revision.
krasimir added inline comments.
This revision now requires changes to proceed.
================
Comment at: clang/lib/Format/TokenAnnotator.cpp:2869
+ // space before '{' in "new MyType {"
+ if (Left.is(TT_Unknown) && Right.is(tok::l_brace) && Left.Previous &&
+ Left.Previous->is(tok::kw_new))
----------------
This test feels a bit too rigid: you might additionally want to consider `new Type<Param> {` and `new Type /*comment*/ {` and `new [] /* comment */ {`.
For these you might find the `MatchingParen` and `getPreviousNonComment` useful. And example for this is below, at line 2880-2885 in javascript handling.
================
Comment at: clang/lib/Format/TokenAnnotator.cpp:2870
+ if (Left.is(TT_Unknown) && Right.is(tok::l_brace) && Left.Previous &&
+ Left.Previous->is(tok::kw_new))
+ return true;
----------------
The `TT_Unknown` is a bit confusing -- why is it needed? If this is a workaround for something, please add it as a comment. We might need to improve the token detection later to allow for more complicated pattern matching.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D72401/new/
https://reviews.llvm.org/D72401
More information about the cfe-commits
mailing list