[PATCH] D132911: [clang-format] Fix annotating when deleting array of pointers

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 30 17:09:54 PDT 2022


owenpan added inline comments.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:2375-2378
+    const FormatToken *Prev = PrevToken;
+    if (Prev->is(tok::r_square) && (Prev = Prev->getPreviousNonComment()) &&
+        Prev->is(tok::l_square) && (Prev = Prev->getPreviousNonComment()) &&
+        Prev->is(tok::kw_delete))
----------------
`endsSequence()` is exactly what you want here. ;)


================
Comment at: clang/unittests/Format/FormatTest.cpp:10538
 
+  Style.PointerAlignment = FormatStyle::PAS_Right;
+  verifyFormat("delete[] *ptr;", Style);
----------------
A typo?


================
Comment at: clang/unittests/Format/FormatTest.cpp:10541
+  verifyFormat("delete[] **ptr;", Style);
+  verifyFormat("delete[] *(ptr);", Style);
+
----------------
MyDeveloperDay wrote:
> could you cover the other PointerAlignment case for completeness
IMO, testing only `PAS_Left` would suffice as we just want to ensure that no spaces are added after the `*`s.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D132911



More information about the cfe-commits mailing list