Skip to content

clang-format improperly formats some string operators #43887

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

Closed
llvmbot opened this issue Jan 14, 2020 · 4 comments · Fixed by #92214
Closed

clang-format improperly formats some string operators #43887

llvmbot opened this issue Jan 14, 2020 · 4 comments · Fixed by #92214
Labels
bugzilla Issues migrated from bugzilla clang-format

Comments

@llvmbot
Copy link
Member

llvmbot commented Jan 14, 2020

Bugzilla Link 44542
Version unspecified
OS Linux
Reporter LLVM Bugzilla Contributor
CC @mydeveloperday

Extended Description

this line

log_error(log_, "from" << "asdf");

(we have some code written which makes it perfectly legal if not nicely looking c++)

is formatted into this

log_error(log_, "from"
<< "asdf");

None of the options that look even remotely relevant have any effect. It's specific to 2 strings, if you replace a string with some other type it doesn't break the line. Tested on versions from 6 till 9.

@llvmbot
Copy link
Member Author

llvmbot commented Jan 14, 2020

Tested on 10, same

@mydeveloperday
Copy link
Contributor

This is caused by the following in "mustBreakBefore()" which to be honest I think looks wrong. I don't understand why we MUST break between 2 string literals.

(I've seen this bug reported before)

if (Right.is(tok::lessless) && Right.Next &&
Right.Previous->is(tok::string_literal) &&
Right.Next->is(tok::string_literal))
return true;

#38220

@mydeveloperday
Copy link
Contributor

*** Bug #38220 has been marked as a duplicate of this bug. ***

@mydeveloperday
Copy link
Contributor

we are discussing here https://reviews.llvm.org/D80950

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 10, 2021
owenca added a commit to owenca/llvm-project that referenced this issue May 15, 2024
owenca added a commit that referenced this issue May 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bugzilla Issues migrated from bugzilla clang-format
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants