[cfe-dev] clang-format: inconsistency in function arg layout (C++)

Oleg Smolsky via cfe-dev cfe-dev at lists.llvm.org
Mon Sep 10 12:47:34 PDT 2018


Hi, I've just boiled down an interesting C++ lambda formatting trait and 
would like to clarify the tool's behavior. Consider the following 
snippet (please view with a fixed-width font):

void f() {
   something->One(
       [this] {
         Do1();
         Do2();
       },
       1);
   something->Two(1,
                  [this] {
                    Do1();
                    Do2();
                  },
                  1);
}

There is an inconsistency in the way lambda args are formatted, 
depending on whether it is first (the "One()" call above) or not (the 
"Two()" call above). Is there some internal guide that the tool uses to 
decide between the two layouts? Or is it just an artifact of the 
implementation?

More generally, would you entertain a patch that forces the format one 
way or another? (Perhaps even with a user-defined setting?)

Thanks,
Oleg.




More information about the cfe-dev mailing list