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] QualifierOrder does not reorder template arguments #53981

Closed
mkurdej opened this issue Feb 22, 2022 · 3 comments
Closed

[clang-format] QualifierOrder does not reorder template arguments #53981

mkurdej opened this issue Feb 22, 2022 · 3 comments
Assignees
Labels
clang-format enhancement Improving things as opposed to bug fixing, e.g. new or missing feature

Comments

@mkurdej
Copy link
Member

mkurdej commented Feb 22, 2022

Found when working on #53962.

The following test fails:

FormatStyle Style = getLLVMStyle();
Style.QualifierAlignment = FormatStyle::QAS_Custom;
Style.QualifierOrder = {"type", "const"};

verifyFormat("template <typename T>\n"
             "  requires Concept<T const>\n"
             "void f();",
             "template <typename T>\n"
             "  requires Concept<const T>\n"
             "void f();",
             Style);
verifyFormat("TemplateType<T const> t;", "TemplateType<const T> t;", Style);

I think it's a legitimate request to be able to reorder qualifiers inside a requires clause or a template type argument list.

That's because we skip all the tokens from TemplateOpener till TemplateCloser.

@mkurdej mkurdej added enhancement Improving things as opposed to bug fixing, e.g. new or missing feature clang-format labels Feb 22, 2022
@llvmbot
Copy link
Collaborator

llvmbot commented Feb 22, 2022

@llvm/issue-subscribers-clang-format

@mydeveloperday
Copy link
Contributor

@mkurdej thanks for the producer, I'm can't remember if the skipping was a conscious decision.

@mydeveloperday mydeveloperday self-assigned this Feb 24, 2022
@mydeveloperday mydeveloperday added the awaiting-review Has pending Phabricator review label Mar 1, 2022
@mkurdej
Copy link
Member Author

mkurdej commented Mar 2, 2022

Revision link: https://reviews.llvm.org/D120710.

@github-actions github-actions bot removed the awaiting-review Has pending Phabricator review label Mar 5, 2022
mem-frob pushed a commit to draperlaboratory/hope-llvm-project that referenced this issue Oct 7, 2022
llvm/llvm-project#53981

Reorder the qualifiers inside the template argument. This should handle the simple cases of

```
<const T>
<T const>
```

But only by relaxing that single letter capital variables are not possible macros

Fixes: #53981

Reviewed By: HazardyKnusperkeks, curdeius

Differential Revision: https://reviews.llvm.org/D120710
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang-format enhancement Improving things as opposed to bug fixing, e.g. new or missing feature
Projects
None yet
Development

No branches or pull requests

3 participants