christophe-calmejane added a comment.

I fixed it like this (not sure it's 100% correct though!!)

    State.Stack.back().HasMultipleNestedBlocks = Current.BlockParameterCount > 
1;
    if (Style.BraceWrapping.BeforeLambdaBody && Current.Next != nullptr &&
        Current.Tok.getKind() == tok::TokenKind::l_paren &&
        Current.BlockParameterCount >= 1) {
                // Search for any parameter that is a lambda
      auto const *nextTok = Current.Next;
      while (nextTok != nullptr) {
        if (nextTok->is(TT_LambdaLSquare)) {
          State.Stack.back().HasMultipleNestedBlocks = true;
          break;
        }
        nextTok = nextTok->Next;
      }
    }

It works for all cases I'm using to test:

  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 still think it's a hack (changing "HasMultipleNestedBlocks"), but it seems to 
work.


Repository:
  rC Clang

https://reviews.llvm.org/D44609



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

Reply via email to