[PATCH] D69764: [clang-format] Add East/West Const fixer capability

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 26 15:50:42 PDT 2020


MyDeveloperDay marked 8 inline comments as done.
MyDeveloperDay added inline comments.


================
Comment at: clang/lib/Format/EastWestConstFixer.cpp:139
+  return (Tok->isSimpleTypeSpecifier() ||
+          Tok->isOneOf(tok::kw_volatile, tok::kw_auto));
+}
----------------
aaron.ballman wrote:
> Do you need to look for `restrict` here as well as `volatile`?
I think restrict only occurs the other side of the * am I right?


================
Comment at: clang/lib/Format/EastWestConstFixer.cpp:157-158
+      IsCVQualifierOrType(Tok->Next->Next)) {
+    // The unsigned/signed case  `const unsigned int` -> `unsigned int
+    // const`
+    swapFirstThreeTokens(SourceMgr, Fixes, Tok, Tok->Next, Tok->Next->Next,
----------------
aaron.ballman wrote:
> What about something like `const unsigned long long` or the less-common-but-equally-valid `long const long unsigned`? Or multiple qualifiers like `unsigned volatile long const long * restrict`
I would like to cover as many cases as possible, but a small part of me thinks that at least initially if we skip a case or two like this I'd be fine.

But I'll take a look and see what I think we could add easily in terms of multiple simple types in a row.


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

https://reviews.llvm.org/D69764





More information about the cfe-commits mailing list