llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-format Author: Owen Pan (owenca) <details> <summary>Changes</summary> Fixes #<!-- -->123573. --- Full diff: https://github.com/llvm/llvm-project/pull/123690.diff 2 Files Affected: - (modified) clang/lib/Format/QualifierAlignmentFixer.cpp (+2-1) - (modified) clang/unittests/Format/QualifierFixerTest.cpp (+12) ``````````diff diff --git a/clang/lib/Format/QualifierAlignmentFixer.cpp b/clang/lib/Format/QualifierAlignmentFixer.cpp index 530b2dd538cee0..21fb5074b4928f 100644 --- a/clang/lib/Format/QualifierAlignmentFixer.cpp +++ b/clang/lib/Format/QualifierAlignmentFixer.cpp @@ -386,7 +386,8 @@ const FormatToken *LeftRightQualifierAlignmentFixer::analyzeLeft( // For left qualifiers preceeded by nothing, a template declaration, or *,&,&& // we only perform sorting. if (!TypeToken || TypeToken->isPointerOrReference() || - TypeToken->ClosesRequiresClause || TypeToken->ClosesTemplateDeclaration) { + TypeToken->ClosesRequiresClause || TypeToken->ClosesTemplateDeclaration || + TypeToken->is(tok::r_square)) { // Don't sort past a non-configured qualifier token. const FormatToken *FirstQual = Tok; diff --git a/clang/unittests/Format/QualifierFixerTest.cpp b/clang/unittests/Format/QualifierFixerTest.cpp index 9ed567445eb07e..129828b0d187a9 100644 --- a/clang/unittests/Format/QualifierFixerTest.cpp +++ b/clang/unittests/Format/QualifierFixerTest.cpp @@ -1279,6 +1279,18 @@ TEST_F(QualifierFixerTest, WithConstraints) { Style); } +TEST_F(QualifierFixerTest, WithCpp11Attribute) { + FormatStyle Style = getLLVMStyle(); + Style.QualifierAlignment = FormatStyle::QAS_Custom; + Style.QualifierOrder = {"static", "constexpr", "inline", "type"}; + + verifyFormat("[[nodiscard]] static constexpr inline int func() noexcept {}", + "[[nodiscard]] inline constexpr static int func() noexcept {}", + Style); + verifyFormat("[[maybe_unused]] static constexpr int A", + "[[maybe_unused]] constexpr static int A", Style); +} + TEST_F(QualifierFixerTest, DisableRegions) { FormatStyle Style = getLLVMStyle(); Style.QualifierAlignment = FormatStyle::QAS_Custom; `````````` </details> https://github.com/llvm/llvm-project/pull/123690 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits