Index: clang/lib/Format/TokenAnnotator.cpp =================================================================== --- clang/lib/Format/TokenAnnotator.cpp +++ clang/lib/Format/TokenAnnotator.cpp @@ -2852,6 +2852,8 @@ return false; } else if (isCppAttribute(IsCpp, *Next)) { Next = Next->MatchingParen; + if (!Next) + return false; } else if (Next->is(tok::l_paren)) { break; } else { Index: clang/unittests/Format/FormatTest.cpp =================================================================== --- clang/unittests/Format/FormatTest.cpp +++ clang/unittests/Format/FormatTest.cpp @@ -26065,6 +26065,8 @@ "}", Style); + verifyIncompleteFormat("class C final [[deprecated(l]] {});", Style); + // These tests are here to show a problem that may not be easily // solved, our implementation to remove semicolons is only as good // as our FunctionLBrace detection and this fails for empty braces