[PATCH] D140843: [clang-format] fix template closer followed by >

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 3 02:40:58 PST 2023


MyDeveloperDay added a comment.

I'm good with this but I'd be interesting in @owenpan  and @HazardyKnusperkeks opinion.



================
Comment at: clang/lib/Format/TokenAnnotator.cpp:169-171
+            CurrentToken->getStartOfNonWhitespace() ==
+                CurrentToken->Next->getStartOfNonWhitespace().getLocWithOffset(
+                    -1)) {
----------------
I was wondering this is actually saying....   

I think its saying... 2 tokens are next to each other ">>"  its not so much formatting but ensuring the existing formatting is maintained, is that what you understand?

Whilst this works it won't correct the case where the whitespace is wrong

i.e. I don't think

```
if (std::tuple_size_v < T >> 0) {
}
```

will be corrected to be

```
if (std::tuple_size_v<T> > 0) {
}
```

I'm a little wary of rules that use the existing whitespace, but I tend to agree that it might be ok without the extra check. 

It would be good to capture this as an annotator test (I like the verifyformat one you put in) but the annotator tests we can assert that its actually a templatecloser and binary operatror





Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140843/new/

https://reviews.llvm.org/D140843



More information about the cfe-commits mailing list