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

Marek Kurdej via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 28 08:42:27 PDT 2020


curdeius marked an inline comment as done.
curdeius added inline comments.


================
Comment at: clang/lib/Format/EastWestConstFixer.cpp:195
+                                FormatToken *Tok) {
+  // We only need to think about streams that begin with const.
+  if (!Tok->is(tok::kw_const)) {
----------------
MyDeveloperDay wrote:
> curdeius wrote:
> > Why? What about `unsigned const int`?
> @curdeius would you help me understand your expectation here?
> 
>  - east: `unsigned int const`
>  - west: `const unsigned int`
> 
> ?
Yes, precisely this. And as for all other cases, I would only move `const`, nothing else.


================
Comment at: clang/lib/Format/EastWestConstFixer.cpp:293
+      Tok->Next->Next->Next && Tok->Next->Next->Next->is(tok::kw_const)) {
+    swapFourTokens(SourceMgr, Fixes, Tok, Tok->Next, Tok->Next, Tok->Next->Next->Next,
+                         /*West=*/true);
----------------
MyDeveloperDay wrote:
> rsmith wrote:
> > There can be more than four type-specifiers / cv-qualifiers in a row. Eg: `unsigned long long int volatile const` -> `const volatile unsigned long long int`.
> you have the volatile moving too? if you had the choice would it become:
> 
> - `const unsigned long long int volatile`
> - `const volatile unsigned long long int`
> - `volatile const unsigned long long int`
> 
> Any reason why? or is that personal taste? what would be the ideal?
> 
> 
Given the size of this revision, it would be probably wiser not to touch anything else than `const`.


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

https://reviews.llvm.org/D69764





More information about the cfe-commits mailing list