[PATCH] D79773: [clang-format] Improve clang-formats handling of concepts

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 19 03:45:18 PDT 2020


MyDeveloperDay planned changes to this revision.
MyDeveloperDay marked 4 inline comments as done.
MyDeveloperDay added inline comments.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:3499
     return true;
   if (Right.Previous->ClosesTemplateDeclaration &&
       Right.Previous->MatchingParen &&
----------------
miscco wrote:
> I think that your change should actually come in here where we determine what to do after a `ClosesTemplateDeclaration` 
> 
> With an potential new option `AlwaysBreakConceptDeclarations ` that should probably default to `AlwaysBreakTemplateDeclarations ` this would read
> ```
>   if (Right.Previous->ClosesTemplateDeclaration &&
>       Right.Previous->MatchingParen &&
>       Right.Previous->MatchingParen->NestingLevel == 0) { 
>       if (Right.is(tok::kw_requires)) {
>         switch(Style.AllowShortRequiresClause) {
>           case FormatStyle::SRCS_Never: 
>             return true;
>           case FormatStyle::SRCS_Always: 
>             return false;
>           case FormatStyle::SRCS_Single:
>             // TODO: Determine whether there is a single constraint 
>             return true;
>           case FormatStyle::SRCS_Short: 
>             // TODO: Determine whether the constraint clause is short enough
>             return true;
>         } 
>       } else if (Right.is(tok::kw_concept)) {
>         return Style.AlwaysBreakConceptDeclarations == FormatStyle::BTCS_Yes);
>       } else {
>         return Style.AlwaysBreakTemplateDeclarations == FormatStyle::BTDS_Yes);
>       }
>   }
> ```
yes this is a better place


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

https://reviews.llvm.org/D79773





More information about the cfe-commits mailing list