<div dir="ltr">Test cases added in <span style="font-family:monospace">232420, </span><span style="font-family:monospace">232424, </span><span style="font-family:monospace">232427.<br><br>I just wrote small examples and modified the writer temporarily to generate the appropriately broken bitcode.</span></div><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Mar 14, 2015 at 11:22 AM, Filipe Cabecinhas <span dir="ltr"><<a href="mailto:filcab@gmail.com" target="_blank">filcab@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">test/BitCode/invalid.test with inputs from test/BitCode/Inputs/invalid-*.bc<div><br></div><div>Constructing them is hard, though. I haven't automated anything, I just go and hexedit the smallest tests I can find :-(</div><div><br></div><div>Good luck!<div><div class="h5"><span></span><br><br>On Saturday, March 14, 2015, David Blaikie <<a href="mailto:dblaikie@gmail.com" target="_blank">dblaikie@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Any examples of existing tests for invalid bitcode & how to construct such input files?</p>
<div class="gmail_quote">On Mar 14, 2015 6:02 AM, "Rafael Espíndola" <<a>rafael.espindola@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><p dir="ltr">Filipe has been adding tests for the error handling. The old testing situation was pretty bad, so if you could create a broken bitcode file to test this it would be awesome. </p>
<div class="gmail_quote">On Mar 13, 2015 5:13 PM, "David Blaikie" <<a>dblaikie@gmail.com</a>> wrote:<br type="attribution"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: dblaikie<br>
Date: Fri Mar 13 16:03:34 2015<br>
New Revision: 232215<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=232215&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=232215&view=rev</a><br>
Log:<br>
Turn assertion into bitcode reading error<br>
<br>
I don't think we test invalid bitcode records in any detail, so no test<br>
here - just a change for consistency with existing error checks in<br>
surrounding code.<br>
<br>
Modified:<br>
    llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp<br>
<br>
Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=232215&r1=232214&r2=232215&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=232215&r1=232214&r2=232215&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)<br>
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Fri Mar 13 16:03:34 2015<br>
@@ -3126,8 +3126,8 @@ std::error_code BitcodeReader::ParseFunc<br>
       }<br>
<br>
       I = GetElementPtrInst::Create(BasePtr, GEPIdx);<br>
-      (void)Ty;<br>
-      assert(!Ty || Ty == cast<GetElementPtrInst>(I)->getSourceElementType());<br>
+      if (Ty && Ty != cast<GetElementPtrInst>(I)->getSourceElementType())<br>
+        return Error("Invalid record");<br>
       InstructionList.push_back(I);<br>
       if (InBounds)<br>
         cast<GetElementPtrInst>(I)->setIsInBounds(true);<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a>llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div>
</blockquote></div>
</blockquote></div></div></div><span class="HOEnZb"><font color="#888888"><br><br>-- <br>  F<br><br>
</font></span></blockquote></div><br></div>