diff options
author | Emilia Dreamer <emilia@rymiel.space> | 2023-02-25 12:19:13 +0200 |
---|---|---|
committer | Emilia Dreamer <emilia@rymiel.space> | 2023-02-25 12:19:20 +0200 |
commit | 393e197cd6eb8942c4eaec3fd6d05bc2e2289212 (patch) | |
tree | dce22a9f72e9fcaab7e965ada4af1ec114af66a9 /clang/lib/Format/QualifierAlignmentFixer.cpp | |
parent | 7ba91016c6ad4cb8f82ed154753ddeeb524f9a64 (diff) | |
download | llvm-393e197cd6eb8942c4eaec3fd6d05bc2e2289212.zip llvm-393e197cd6eb8942c4eaec3fd6d05bc2e2289212.tar.gz llvm-393e197cd6eb8942c4eaec3fd6d05bc2e2289212.tar.bz2 |
[clang-format] Don't move qualifiers past pointers-to-member
Previously, given a pointer-to-member type such as `Foo const Bar::*`,
clang-format would see the `const Bar::` part as a regular type name
with scope resolution operators, and with `QualifierAlignment: Right` it
would attempt to "fix" it, resulting in `Foo Bar::const *`, a syntax
error.
This patch no longer allows qualifiers to be moved across `::*`.
Fixes https://github.com/llvm/llvm-project/issues/60898
Reviewed By: owenpan, MyDeveloperDay, HazardyKnusperkeks
Differential Revision: https://reviews.llvm.org/D144537
Diffstat (limited to 'clang/lib/Format/QualifierAlignmentFixer.cpp')
-rw-r--r-- | clang/lib/Format/QualifierAlignmentFixer.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/clang/lib/Format/QualifierAlignmentFixer.cpp b/clang/lib/Format/QualifierAlignmentFixer.cpp index cef8b36..609b412 100644 --- a/clang/lib/Format/QualifierAlignmentFixer.cpp +++ b/clang/lib/Format/QualifierAlignmentFixer.cpp @@ -280,8 +280,11 @@ const FormatToken *LeftRightQualifierAlignmentFixer::analyzeRight( // The case `const Foo &&` -> `Foo const &&` // The case `const std::Foo &&` -> `std::Foo const &&` // The case `const std::Foo<T> &&` -> `std::Foo<T> const &&` - while (Next && Next->isOneOf(tok::identifier, tok::coloncolon)) + // However, `const Bar::*` remains the same. + while (Next && Next->isOneOf(tok::identifier, tok::coloncolon) && + !Next->startsSequence(tok::coloncolon, tok::star)) { Next = Next->Next; + } if (Next && Next->is(TT_TemplateOpener)) { Next = Next->MatchingParen; // Move to the end of any template class members e.g. |