Index: clang/lib/Format/QualifierAlignmentFixer.cpp =================================================================== --- clang/lib/Format/QualifierAlignmentFixer.cpp +++ clang/lib/Format/QualifierAlignmentFixer.cpp @@ -334,7 +334,8 @@ Next->Previous->startsSequence(tok::identifier, TT_TemplateOpener)) { // Read from to the end of the TemplateOpener to // TemplateCloser const ArrayRef a; const ArrayRef &a; - assert(Next->MatchingParen && "Missing template closer"); + if (!Next->MatchingParen) + return Next; Next = Next->MatchingParen->Next; // Move to the end of any template class members e.g. Index: clang/unittests/Format/QualifierFixerTest.cpp =================================================================== --- clang/unittests/Format/QualifierFixerTest.cpp +++ clang/unittests/Format/QualifierFixerTest.cpp @@ -818,5 +818,18 @@ 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 using A = quantity /**/, 1>;", + Style); + EXPECT_EQ(ReplacementCount, 0); +} + } // namespace format } // namespace clang