[PATCH] D69764: [clang-format] Add Left/Right Const (East/West , Before/After) fixer capability

Ilya Mirsky via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 9 15:30:32 PST 2019


ilya added a comment.

In D69764#1775842 <https://reviews.llvm.org/D69764#1775842>, @MyDeveloperDay wrote:

> In D69764#1775835 <https://reviews.llvm.org/D69764#1775835>, @ilya wrote:
>
> > In D69764#1732235 <https://reviews.llvm.org/D69764#1732235>, @aaron.ballman wrote:
> >
> > > I like the functionality, but am slightly opposed to using "east/west" terminology -- that's not a ubiquitous phrase and it takes a bit of thinking before it makes sense. I think "left/right" is likely to be more universally understood.
> > >
> > > Also, should this apply to other qualifiers like `volatile` or `restrict`? If so, the name `ConstStyle` should probably be `CVQualifierStyle` or something else.
> >
> >
> > +1.
> >  In addition to `volatile` and `restrict`, in my organization we'd also be interested in applying this to address space qualifiers (custom keywords added in our downstream fork). Can this be generalized to accept a map of qualifier keywords and its desired orientation?
>
>
> Could you give me an example of what you mean?


As described in section 5 of the embedded C standard ISO/IEC J TC1 SC22 WG14 N1169 <http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1169.pdf>, our downstream llvm fork supports several address spaces, let's denote them `__as1` and `__as2`. These address space qualifiers behave similarly to `const`, so the following are semantically equal:

  __as1 int foo;
  int __as1 bar;

So for us it would be nice to be able to specify alignment options for a dynamic list of custom qualifiers. Something like the following:

  QualifierStyle:
    const:     Right
    volatile:  Right
    __as1:     Right
    __as2:     Right

But I don't know if this can be (easily) supported in a .clang-format file, since the style options are defined as (static) enums. I realize my proposal might be out of the scope of this patch, but I wanted to get some opinions from the community.


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

https://reviews.llvm.org/D69764





More information about the cfe-commits mailing list