krasimir added a comment. In D127873#3651364 <https://reviews.llvm.org/D127873#3651364>, @jackhong12 wrote:
> I think we cannot identify `struct`, `union`, `class` or `enum` by the right > bracket. Clang-format will split the input into multiple lines. For instance > `struct Tmp {} *tmp;` will be separated as `struct Tmp {` and `} *tmp;`. In > annotating, we only handle the relation of tokens in a single line, so we > cannot know whether `}` belongs to `struct` or not. Interesting. Actually, it seems the splitting into multiple lines happens if we're in the `struct`, etc. case, but not if this was likely a braced list: % cat test.cc int i = int{16} * 1024; % ./clang-format -style=google -debug test.cc Args: ./clang-format -style=google -debug test.cc File encoding: UTF8 Language: C++ ---- Next [0] Token: int / int, Macro: 0 Next [1] Token: identifier / i, Macro: 0 Next [2] Token: equal / =, Macro: 0 Next [3] Token: int / int, Macro: 0 Next [4] Token: l_brace / {, Macro: 0 Getting Position: 4 Next [5] Token: numeric_constant / 16, Macro: 0 Next [6] Token: r_brace / }, Macro: 0 Next [7] Token: star / *, Macro: 0 Setting Position: 4 Next [5] Token: numeric_constant / 16, Macro: 0 Next [6] Token: r_brace / }, Macro: 0 Next [7] Token: star / *, Macro: 0 Next [8] Token: numeric_constant / 1024, Macro: 0 Next [9] Token: semi / ;, Macro: 0 Next [10] Token: eof / , Macro: 0 Line(0, FSC=0): int[T=108, OC=0] identifier[T=108, OC=4] equal[T=108, OC=6] int[T=108, OC=8] l_brace[T=108, OC=11] numeric_constant[T=108, OC=12] r_brace[T=108, OC=14] star[T=108, OC=16] numeric_constant[T=108, OC=18] semi[T=108, OC=22] Line(0, FSC=0): eof[T=108, OC=0] Run 0... Replacements for run 0: File encoding: UTF8 Language: C++ ---- Next [0] Token: int / int, Macro: 0 Next [1] Token: identifier / i, Macro: 0 Next [2] Token: equal / =, Macro: 0 Next [3] Token: int / int, Macro: 0 Next [4] Token: l_brace / {, Macro: 0 Getting Position: 4 Next [5] Token: numeric_constant / 16, Macro: 0 Next [6] Token: r_brace / }, Macro: 0 Next [7] Token: star / *, Macro: 0 Setting Position: 4 Next [5] Token: numeric_constant / 16, Macro: 0 Next [6] Token: r_brace / }, Macro: 0 Next [7] Token: star / *, Macro: 0 Next [8] Token: numeric_constant / 1024, Macro: 0 Next [9] Token: semi / ;, Macro: 0 Next [10] Token: eof / , Macro: 0 Line(0, FSC=0): int[T=108, OC=0] identifier[T=108, OC=4] equal[T=108, OC=6] int[T=108, OC=8] l_brace[T=108, OC=11] numeric_constant[T=108, OC=12] r_brace[T=108, OC=14] star[T=108, OC=16] numeric_constant[T=108, OC=18] semi[T=108, OC=22] Line(0, FSC=0): eof[T=108, OC=0] Run 0... Replacements for run 0: File encoding: UTF8 Language: C++ ---- Next [0] Token: int / int, Macro: 0 Next [1] Token: identifier / i, Macro: 0 Next [2] Token: equal / =, Macro: 0 Next [3] Token: int / int, Macro: 0 Next [4] Token: l_brace / {, Macro: 0 Getting Position: 4 Next [5] Token: numeric_constant / 16, Macro: 0 Next [6] Token: r_brace / }, Macro: 0 Next [7] Token: star / *, Macro: 0 Setting Position: 4 Next [5] Token: numeric_constant / 16, Macro: 0 Next [6] Token: r_brace / }, Macro: 0 Next [7] Token: star / *, Macro: 0 Next [8] Token: numeric_constant / 1024, Macro: 0 Next [9] Token: semi / ;, Macro: 0 Next [10] Token: eof / , Macro: 0 Line(0, FSC=0): int[T=108, OC=0] identifier[T=108, OC=4] equal[T=108, OC=6] int[T=108, OC=8] l_brace[T=108, OC=11] numeric_constant[T=108, OC=12] r_brace[T=108, OC=14] star[T=108, OC=16] numeric_constant[T=108, OC=18] semi[T=108, OC=22] Line(0, FSC=0): eof[T=108, OC=0] Run 0... AnnotatedTokens(L=0): M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=0 Name=int L=3 PPK=2 FakeLParens=2/ FakeRParens=0 II=0x1a4ea20 Text='int' M=0 C=1 T=StartOfName S=1 F=0 B=0 BK=0 P=220 Name=identifier L=5 PPK=2 FakeLParens= FakeRParens=0 II=0x1a8d578 Text='i' M=0 C=0 T=BinaryOperator S=1 F=0 B=0 BK=0 P=22 Name=equal L=7 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='=' M=0 C=1 T=Unknown S=1 F=0 B=0 BK=0 P=22 Name=int L=11 PPK=2 FakeLParens= FakeRParens=0 II=0x1a4ea20 Text='int' M=0 C=0 T=Unknown S=0 F=0 B=0 BK=2 P=23 Name=l_brace L=12 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='{' M=0 C=1 T=Unknown S=0 F=0 B=0 BK=0 P=59 Name=numeric_constant L=14 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='16' M=0 C=0 T=Unknown S=0 F=0 B=0 BK=2 P=41 Name=r_brace L=15 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='}' M=0 C=0 T=PointerOrReference S=0 F=0 B=0 BK=0 P=210 Name=star L=16 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='*' M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=34 Name=numeric_constant L=21 PPK=2 FakeLParens= FakeRParens=1 II=0x0 Text='1024' M=0 C=0 T=Unknown S=0 F=0 B=0 BK=0 P=23 Name=semi L=22 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text=';' ---- AnnotatedTokens(L=0): M=0 C=0 T=Unknown S=1 F=0 B=0 BK=0 P=0 Name=eof L=0 PPK=2 FakeLParens= FakeRParens=0 II=0x0 Text='' ---- Replacements for run 0: test.cc: 15:+1:"" int i = int{16}* 1024; So maybe we can base it off that distinction. I'll try and explore this idea in the next few days. Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D127873/new/ https://reviews.llvm.org/D127873 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits