[PATCH] D139834: [clang-format] AllowShortCompoundRequirementOnASingleLine

Zhikai Zeng via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Dec 13 07:06:03 PST 2022


Backl1ght added inline comments.


================
Comment at: clang/lib/Format/Format.cpp:809
                    Style.AllowShortCaseLabelsOnASingleLine);
+    IO.mapOptional("AllowShortCompoundRequirementOnASingleLine",
+                   Style.AllowShortCompoundRequirementOnASingleLine);
----------------
MyDeveloperDay wrote:
> haven't we use "Requires" in other options? What is the definition of Compound?
> 
> I might be tempted for this to be AllShortRequiresOnASingleLine but then it be an enum with the following options
> 
> ```
> Leave
> Never
> Always
> Compound
> ```
There are some options related to requires like IndentRequiresClause, RequiresClausePosition, etc. But as for single line and brace wrapping, requires is not yet considered.

"Compound" is from Compound Requirements section in this page https://en.cppreference.com/w/cpp/language/requires

I think this is a better way, I would try implementing it.


================
Comment at: clang/lib/Format/Format.cpp:1265
   LLVMStyle.AllowShortCaseLabelsOnASingleLine = false;
+  LLVMStyle.AllowShortCompoundRequirementOnASingleLine = true;
   LLVMStyle.AllowShortEnumsOnASingleLine = true;
----------------
MyDeveloperDay wrote:
> why would the default be true, is that what happens today?
yes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139834



More information about the cfe-commits mailing list