[PATCH] D63062: [clang-format] Added New Style Rule: BitFieldDeclarationsOnePerLine

Manikishan Ghantasala via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Sep 26 01:41:03 PDT 2019


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


================
Comment at: lib/Format/FormatToken.h:524
+    T = T->getPreviousNonComment();
+    return (T->Tok.is(tok::comma) && Tok.is(tok::identifier) &&
+            T->Next->Tok.is(tok::colon));
----------------
MyDeveloperDay wrote:
> Manikishan wrote:
> > MyDeveloperDay wrote:
> > > do you think you might need
> > > 
> > > (T && T->Tok.is(tok::comma)......
> > > 
> > I have found a method `FieldDecl::isBitField() ` which check whether a current field is a BitField, But `FieldDecl` is not used anywhere in `lib/Format/` . I think it may not be related to Formatting and so I have to modify my declaration of `isBitield()` in `FormatToken.h`. 
> > Can I get suggestions whether my understanding is correct?
> FieldDecl will be part of the AST tree, but clang-format doesn't use that (or it would need compiler arguments etc..)
> 
> Take a look at TokenAnnotator.cpp... (and try running clang-format with the -debug option), it may show you that the bitfield can be identified by the TT_BitFieldColon type rather than by a colon directly.
> 
> 
> ```
>       } else if (CurrentToken && CurrentToken->is(tok::numeric_constant)) {
>         Tok->Type = TT_BitFieldColon;
> 
> ```
> 
> 
Sure will have a look at it, and figure out how can I check for bitfields


Repository:
  rC Clang

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

https://reviews.llvm.org/D63062





More information about the cfe-commits mailing list