owenpan updated this revision to Diff 476719.
owenpan added a comment.

Added a test case.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138371/new/

https://reviews.llvm.org/D138371

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


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
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
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 {
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to