<div dir="ltr">Nice! Did you run a fuzzer to find all these?</div><div class="gmail_extra"><br><div class="gmail_quote">On Mon, Jan 19, 2015 at 3:49 AM, Daniel Jasper <span dir="ltr"><<a href="mailto:djasper@google.com" target="_blank">djasper@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: djasper<br>
Date: Mon Jan 19 05:49:32 2015<br>
New Revision: 226454<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=226454&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=226454&view=rev</a><br>
Log:<br>
clang-format: Fix crasher on weird comments.<br>
<br>
Crashing input:<br>
  /\<br>
  / comment<br>
<br>
Modified:<br>
    cfe/trunk/lib/Format/TokenAnnotator.cpp<br>
    cfe/trunk/unittests/Format/FormatTest.cpp<br>
<br>
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=226454&r1=226453&r2=226454&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=226454&r1=226453&r2=226454&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)<br>
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Jan 19 05:49:32 2015<br>
@@ -838,10 +838,8 @@ private:<br>
                (!Current.Previous || Current.Previous->isNot(tok::l_square))) {<br>
       Current.Type = TT_BinaryOperator;<br>
     } else if (Current.is(tok::comment)) {<br>
-      if (Current.TokenText.startswith("//"))<br>
-        Current.Type = TT_LineComment;<br>
-      else<br>
-        Current.Type = TT_BlockComment;<br>
+      Current.Type =<br>
+          Current.TokenText.startswith("/*") ? TT_BlockComment : TT_LineComment;<br>
     } else if (Current.is(tok::r_paren)) {<br>
       if (rParenEndsCast(Current))<br>
         Current.Type = TT_CastRParen;<br>
<br>
Modified: cfe/trunk/unittests/Format/FormatTest.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=226454&r1=226453&r2=226454&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=226454&r1=226453&r2=226454&view=diff</a><br>
==============================================================================<br>
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)<br>
+++ cfe/trunk/unittests/Format/FormatTest.cpp Mon Jan 19 05:49:32 2015<br>
@@ -1035,6 +1035,9 @@ TEST_F(FormatTest, UnderstandsSingleLine<br>
                    "     // spanning two lines\n"<br>
                    " x + 3) {\n"<br>
                    "}"));<br>
+<br>
+  verifyNoCrash("/\\\n/");<br>
+  verifyNoCrash("/\\\n* */");<br>
 }<br>
<br>
 TEST_F(FormatTest, KeepsParameterWithTrailingCommentsOnTheirOwnLine) {<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div>