christophe-calmejane added a comment.

Hi,

Due to the pandemic, I wasn't able to look at https://reviews.llvm.org/D44609 
which got broken since it was pushed to LLVM. Nevertheless I commented in that 
post with a rather complete unit tests that should pass if any changes are to 
be pushed to that part of the code.

Here is the test suite:

  noOtherParams([](int x){call();});
  paramBeforeLambda(8,[](int x){call();});
  paramAfterLambda([](int x){call();},5);
  paramBeforeAndAfterLambda(8,[](int x){call();},5);
  doubleLambda(8,[](int x){call();},6,[](float f){return f*2;},5);
  nestedLambda1([](int x){return [](float f){return f*2;};});
  nestedLambda2([](int x){ call([](float f){return f*2;});});
  noExceptCall([](int x) noexcept {call();});
  mutableCall([](int x) mutable{call();});
  
  funcCallFunc(call(),[](int x){call();});
  
  auto const l=[](char v){if(v)call();};
  void f() { return [](char v){ if(v) return v++;}; }

And here is how it should be formatted:

  noOtherParams(
          [](int x)
          {
                  call();
          });
  paramBeforeLambda(8,
          [](int x)
          {
                  call();
          });
  paramAfterLambda(
          [](int x)
          {
                  call();
          },
          5);
  paramBeforeAndAfterLambda(8,
          [](int x)
          {
                  call();
          },
          5);
  doubleLambda(8,
          [](int x)
          {
                  call();
          },
          6,
          [](float f)
          {
                  return f * 2;
          },
          5);
  nestedLambda1(
          [](int x)
          {
                  return [](float f)
                  {
                          return f * 2;
                  };
          });
  nestedLambda2(
          [](int x)
          {
                  call(
                          [](float f)
                          {
                                  return f * 2;
                          });
          });
  noExceptCall(
          [](int x) noexcept
          {
                  call();
          });
  mutableCall(
          [](int x) mutable
          {
                  call();
          });
  
  funcCallFunc(call(),
          [](int x)
          {
                  call();
          });
  
  auto const l = [](char v)
  {
          if (v)
                  call();
  };
  void f()
  {
          return [](char v)
          {
                  if (v)
                          return v++;
          };
  }

I couldn't find the time to test this case with the latest clang-format 
release, but I guess it's still broken and doesn't match the expected output.
Anyway, this test suite is helpful as it covers most cases, and if someone with 
enough knowledge of LLVM is willing to add this to the unit tests it would help 
a lot.

Best regards,
Chris


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

https://reviews.llvm.org/D104222

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to