Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve formatting of concepts #64

Open
bernhardmgruber opened this issue Dec 31, 2022 · 4 comments
Open

Improve formatting of concepts #64

bernhardmgruber opened this issue Dec 31, 2022 · 4 comments

Comments

@bernhardmgruber
Copy link
Collaborator

The current style config makes concept definitions quite verbose:

Here is a LLAMA concept using my private .clang-format:

    template <typename M>
    concept Mapping = requires(M m) {
        typename M::ArrayExtents;
        typename M::ArrayIndex;
        typename M::RecordDim;
        { m.extents() } -> std::same_as<typename M::ArrayExtents>;
        { +M::blobCount } -> std::same_as<std::size_t>;
        std::integral_constant<std::size_t, M::blobCount>{}; // validates constexpr-ness
        { m.blobSize(typename M::ArrayExtents::value_type{}) } -> std::same_as<typename M::ArrayExtents::value_type>;
    };

And now formatted with the CRP .clang-format:

    template<typename M>
    concept Mapping = requires(M m) {
                          typename M::ArrayExtents;
                          typename M::ArrayIndex;
                          typename M::RecordDim;
                          {
                              m.extents()
                              } -> std::same_as<typename M::ArrayExtents>;
                          {
                              +M::blobCount
                              } -> std::same_as<std::size_t>;
                          std::integral_constant<std::size_t, M::blobCount>{}; // validates constexpr-ness
                          {
                              m.blobSize(typename M::ArrayExtents::value_type{})
                              } -> std::same_as<typename M::ArrayExtents::value_type>;
                      };

Please consider improving the status-quo.

@psychocoderHPC
Copy link
Member

Which config entry is the reason for the issue. I assume it is an alignment option and you use in llama only indentions.

@bernhardmgruber
Copy link
Collaborator Author

It is caused by BreakBeforeBraces: Allman. If I replace it with:

BreakBeforeBraces: Custom
BraceWrapping:
  AfterFunction:   false

the formattign is much better. Obviously, this also changes the formatting of ordinary functions as well.

@j-stephan
Copy link
Collaborator

This was a LLVM bug that was recently fixed. I suggest to wait until it appears in a clang-format release.

@SimeonEhrig
Copy link
Contributor

The PR was merge in July 2022 and Clang 15 was released in September 2022. I think we need to update to clang-format-15.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants