[clang] [clang-format] Hanlde qualified type name for `QualifierAlignment` (PR #125327)
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Sun Feb 2 15:51:15 PST 2025
================
@@ -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();
+ if (!(Prev && Prev->is(tok::identifier)))
----------------
owenca wrote:
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.
https://github.com/llvm/llvm-project/pull/125327
More information about the cfe-commits
mailing list