Skip to content

[clang-format] && wrongfully interpreted as Boolean operation #139376

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

Open
prj- opened this issue May 10, 2025 · 5 comments
Open

[clang-format] && wrongfully interpreted as Boolean operation #139376

prj- opened this issue May 10, 2025 · 5 comments

Comments

@prj-
Copy link

prj- commented May 10, 2025

$ cat foo.cpp
template <class F, class... Args>
using invoke_result_t = typename std::result_of<F&& (Args &&...)>::type;
$ clang-format-20 foo.cpp
template <class F, class... Args>
using invoke_result_t = typename std::result_of<F && (Args && ...)>::type;
@llvmbot
Copy link
Member

llvmbot commented May 10, 2025

@llvm/issue-subscribers-clang-format

Author: Pierre Jolivet (prj-)

``` $ cat foo.cpp template <class F, class... Args> using invoke_result_t = typename std::result_of<F&& (Args &&...)>::type; $ clang-format-20 foo.cpp template <class F, class... Args> using invoke_result_t = typename std::result_of<F && (Args && ...)>::type; ```

@owenca
Copy link
Contributor

owenca commented May 10, 2025

@prj you need to add F to TypeNames for this to work:

$ clang-format -style='{TypeNames: [F]}' foo.cpp
template <class F, class... Args>
using invoke_result_t = typename std::result_of<F &&(Args &&...)>::type;

@prj-
Copy link
Author

prj- commented May 11, 2025

I see. Is there no way around this?

@owenca
Copy link
Contributor

owenca commented May 11, 2025

I don't know of any additional heuristics we can add to the parser for this construct, especially when parseAngle() already annotates the angles correctly.

@prj-
Copy link
Author

prj- commented May 11, 2025

OK, then I guess I need to find another type name because this is messing up the rest of our code using F as a variable. Feel free to close the issue.

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

No branches or pull requests

4 participants
@prj- @owenca @llvmbot and others