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] SeparateDefinitionBlocks always puts a break between a comment and the function the comment it for #52976

Closed
mydeveloperday opened this issue Jan 4, 2022 · 3 comments
Labels
bug Indicates an unexpected problem or unintended behavior clang-format

Comments

@mydeveloperday
Copy link
Contributor

I'm seeing some odd behaviour in SeperateDefinitionBlocks..

SeparateDefinitionBlocks: Always

void foo() {}
/* ABC */
void bar() {}

becomes

void foo() {}

/* ABC */

void bar() {}

If the ABC comment is a doxygen style comment it doesn't make sense to separate it from the function below

@mydeveloperday mydeveloperday added bug Indicates an unexpected problem or unintended behavior clang-format labels Jan 4, 2022
@mydeveloperday
Copy link
Contributor Author

This is also true for line comments

void foo() {}

/* ABC */

void bar() {}

void foo() {}

// bar function

void bar() {}

@mydeveloperday
Copy link
Contributor Author

Also true for namespaces

// mynamespace

namespace {}

I kind of feel this level of separation is not required

@mkurdej
Copy link
Member

mkurdej commented Jan 6, 2022

Review: https://reviews.llvm.org/D116663.

@mkurdej mkurdej added the awaiting-review Has pending Phabricator review label Jan 6, 2022
@ksyx ksyx closed this as completed in ee25a32 Jan 11, 2022
@asl asl removed the awaiting-review Has pending Phabricator review label Jan 27, 2022
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this issue Oct 7, 2022
Fixes llvm/llvm-project#52976.

- Make no formatting for macros
- Attach comment with definition headers
- Make no change on use of empty lines at block start/end
- Fix misrecognition of keyword namespace

Differential Revision: https://reviews.llvm.org/D116663
Reviewed By: MyDeveloperDay, HazardyKnusperkeks, curdeius
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior clang-format
Projects
None yet
Development

No branches or pull requests

3 participants