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

MyDeveloperDay via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 9 01:54:08 PDT 2020


MyDeveloperDay added a subscriber: klimek.
MyDeveloperDay added a comment.

This issue is caused by the presence of the `;` in the requires clause (`0)>;`) inside the template declaration

  template <std::semiregular F, std::semiregular... Args>
      requires std::invocable<F, std::invoke_result_t<Args>...>
  struct [[nodiscard]] constant : std::bool_constant < requires
  {
      typename _require_constant_<(std::invoke(F{}, Args{}()...), 0)>;
  } > {};

These below may not be legal C++ examples but show the same behaviour

  struct constant : Foo < typename {
      Foo;
  } > {};
  
  struct constant : Foo<typename {Foo}> { };

This is actually failing in the handling of parsing the `<>`  in (`parseAngle()` actually `parseBrace()` inside of that), it is not really concepts specific except it may be seen now because of the presence of the `;`

The problem comes about I think because the line is broken by the ";" during the `parseBrace` at some point the `Next` token is null, I assume that's because the lines are broken by the ';' as such ultimately the < and > rather than being seen as TT_TemplateOpener and TT_TemplateCloser are seen as TT_BinaryOperators (by default when parseAngle fails)

I'm not sure how I could solve this, I might need help from a higher power @klimek


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

https://reviews.llvm.org/D79773





More information about the cfe-commits mailing list