-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[clang-format] Hanlde qualified type name for QualifierAlignment
#125327
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
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -132,8 +132,10 @@ static void rotateTokens(const SourceManager &SourceMgr, | |||||
| // Then move through the other tokens. | ||||||
| auto *Tok = Begin; | ||||||
| while (Tok != End) { | ||||||
| if (!NewText.empty() && !endsWithSpace(NewText)) | ||||||
| if (!NewText.empty() && !endsWithSpace(NewText) && | ||||||
| Tok->isNot(tok::coloncolon)) { | ||||||
| NewText += " "; | ||||||
| } | ||||||
|
|
||||||
| NewText += Tok->TokenText; | ||||||
| Tok = Tok->Next; | ||||||
|
|
@@ -412,6 +414,15 @@ const FormatToken *LeftRightQualifierAlignmentFixer::analyzeLeft( | |||||
| // The case `const long long volatile int` -> `const volatile long long int` | ||||||
| // The case `long volatile long int const` -> `const volatile long long int` | ||||||
| if (TypeToken->isTypeName(LangOpts)) { | ||||||
| for (const auto *Prev = TypeToken->getPreviousNonComment(); | ||||||
| Prev && Prev->is(tok::coloncolon); | ||||||
| Prev = Prev->getPreviousNonComment()) { | ||||||
| TypeToken = Prev; | ||||||
| Prev = Prev->getPreviousNonComment(); | ||||||
owenca marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| if (!(Prev && Prev->is(tok::identifier))) | ||||||
|
||||||
| if (!(Prev && Prev->is(tok::identifier))) | |
| if (!Prev || Prev->isNot(tok::identifier)) |
I personally don't like negated parenthesis.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Neither do I when the conditions inside the parentheses are unrelated. Otherwise, I prefer the negated parentheses. Another example is !(Foo == A || Foo == B || Foo == C) (i.e. Foo is not one of A, B, and C) vs Foo != A && Foo != B && Foo != C (i.e. Foo is not A, not B, and not C). The former is more readable to me.
Uh oh!
There was an error while loading. Please reload this page.