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

clang-format cannot format attributes on lambdas #92657

Closed
nico opened this issue May 18, 2024 · 1 comment · Fixed by #94119
Closed

clang-format cannot format attributes on lambdas #92657

nico opened this issue May 18, 2024 · 1 comment · Fixed by #94119
Assignees

Comments

@nico
Copy link
Contributor

nico commented May 18, 2024

Input:

% cat test.cc
void CanonicalCode::write_symbol(LittleEndianOutputBitStream& bit_stream, u32 symbol) const
{
    m_code.visit(
        [&](u32 single_code) __attribute__((always_inline)) -> void {},
        [&](Compress::CanonicalCode const& code) __attribute__((always_inline)) {});
}

clang-format strips the spaces around ->:

% ~/src/llvm-project/out/gn/bin/clang-format test.cc
void CanonicalCode::write_symbol(LittleEndianOutputBitStream& bit_stream, u32 symbol) const
{
    m_code.visit(
        [&](u32 single_code) __attribute__((always_inline))->void {},
        [&](Compress::CanonicalCode const& code) __attribute__((always_inline)) {});
}

This is with today's HEAD (58c7785), but it also repros with older clang-formats.

@llvmbot
Copy link
Collaborator

llvmbot commented May 18, 2024

@llvm/issue-subscribers-clang-format

Author: Nico Weber (nico)

Input:
% cat test.cc
void CanonicalCode::write_symbol(LittleEndianOutputBitStream& bit_stream, u32 symbol) const
{
    m_code.visit(
        [&](u32 single_code) __attribute__((always_inline)) -> void {},
        [&](Compress::CanonicalCode const& code) __attribute__((always_inline)) {});
}

clang-format strips the spaces around ->:

% ~/src/llvm-project/out/gn/bin/clang-format test.cc
void CanonicalCode::write_symbol(LittleEndianOutputBitStream& bit_stream, u32 symbol) const
{
    m_code.visit(
        [&](u32 single_code) __attribute__((always_inline))->void {},
        [&](Compress::CanonicalCode const& code) __attribute__((always_inline)) {});
}

This is with today's HEAD (58c7785), but it also repros with older clang-formats.

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

Successfully merging a pull request may close this issue.

3 participants