MyDeveloperDay updated this revision to Diff 397806. MyDeveloperDay added a comment.
The cause is because Next is a comment, not a template opener, handle that case. CHANGES SINCE LAST ACTION https://reviews.llvm.org/D116726/new/ https://reviews.llvm.org/D116726 Files: clang/lib/Format/QualifierAlignmentFixer.cpp clang/unittests/Format/QualifierFixerTest.cpp Index: clang/unittests/Format/QualifierFixerTest.cpp =================================================================== --- clang/unittests/Format/QualifierFixerTest.cpp +++ clang/unittests/Format/QualifierFixerTest.cpp @@ -818,5 +818,19 @@ EXPECT_EQ(ReplacementCount, 0); } +TEST_F(QualifierFixerTest, QualifierTemplates) { + + FormatStyle Style = getLLVMStyle(); + Style.QualifierAlignment = FormatStyle::QAS_Custom; + Style.QualifierOrder = {"static", "const", "type"}; + + ReplacementCount = 0; + EXPECT_EQ(ReplacementCount, 0); + verifyFormat("template <class Id> using A = quantity<kind<Id>, 1>;", Style); + verifyFormat("template <class Id> using A = quantity /**/<kind<Id>, 1>;", + Style); + EXPECT_EQ(ReplacementCount, 0); +} + } // namespace format } // namespace clang Index: clang/lib/Format/QualifierAlignmentFixer.cpp =================================================================== --- clang/lib/Format/QualifierAlignmentFixer.cpp +++ clang/lib/Format/QualifierAlignmentFixer.cpp @@ -334,6 +334,8 @@ Next->Previous->startsSequence(tok::identifier, TT_TemplateOpener)) { // Read from to the end of the TemplateOpener to // TemplateCloser const ArrayRef<int> a; const ArrayRef<int> &a; + if (Next->is(TT_BlockComment) && Next->Next) + Next = Next->Next; assert(Next->MatchingParen && "Missing template closer"); Next = Next->MatchingParen->Next;
Index: clang/unittests/Format/QualifierFixerTest.cpp =================================================================== --- clang/unittests/Format/QualifierFixerTest.cpp +++ clang/unittests/Format/QualifierFixerTest.cpp @@ -818,5 +818,19 @@ EXPECT_EQ(ReplacementCount, 0); } +TEST_F(QualifierFixerTest, QualifierTemplates) { + + FormatStyle Style = getLLVMStyle(); + Style.QualifierAlignment = FormatStyle::QAS_Custom; + Style.QualifierOrder = {"static", "const", "type"}; + + ReplacementCount = 0; + EXPECT_EQ(ReplacementCount, 0); + verifyFormat("template <class Id> using A = quantity<kind<Id>, 1>;", Style); + verifyFormat("template <class Id> using A = quantity /**/<kind<Id>, 1>;", + Style); + EXPECT_EQ(ReplacementCount, 0); +} + } // namespace format } // namespace clang Index: clang/lib/Format/QualifierAlignmentFixer.cpp =================================================================== --- clang/lib/Format/QualifierAlignmentFixer.cpp +++ clang/lib/Format/QualifierAlignmentFixer.cpp @@ -334,6 +334,8 @@ Next->Previous->startsSequence(tok::identifier, TT_TemplateOpener)) { // Read from to the end of the TemplateOpener to // TemplateCloser const ArrayRef<int> a; const ArrayRef<int> &a; + if (Next->is(TT_BlockComment) && Next->Next) + Next = Next->Next; assert(Next->MatchingParen && "Missing template closer"); Next = Next->MatchingParen->Next;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits