<div dir="ltr">I don't think what Reid was suggesting is reasonable, we construct the DataLayout in the AsmParser. The AsmParser cannot run passes, of which the verifier is one of. A similar scheme might be possible but I don't see how it would provide real benefit; I guess I have trouble imagining why a tool would like to continue running after such an error. That said, I wouldn't oppose such a refactoring.<div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 9, 2014 at 8:43 PM, Robinson, Paul <span dir="ltr"><<a href="mailto:Paul_Robinson@playstation.sony.com" target="_blank">Paul_Robinson@playstation.sony.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This is all lovely and I'm not complaining, as I probably couldn't have<br>
gotten back to PR21678 before the new year; but did you look at what<br>
Reid suggested in that PR? It felt a little cleaner than converting<br>
assertions to report_fatal_error directly.<br>
Thanks,<br>
--paulr<br>
<div class="HOEnZb"><div class="h5"><br>
> -----Original Message-----<br>
> From: <a href="mailto:llvm-commits-bounces@cs.uiuc.edu">llvm-commits-bounces@cs.uiuc.edu</a> [mailto:<a href="mailto:llvm-commits-">llvm-commits-</a><br>
> <a href="mailto:bounces@cs.uiuc.edu">bounces@cs.uiuc.edu</a>] On Behalf Of David Majnemer<br>
> Sent: Tuesday, December 09, 2014 6:37 PM<br>
> To: <a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
> Subject: [llvm] r223911 - DataLayout: Provide nicer diagnostics for<br>
> malformed strings<br>
><br>
> Author: majnemer<br>
> Date: Tue Dec 9 20:36:41 2014<br>
> New Revision: 223911<br>
><br>
> URL: <a href="http://llvm.org/viewvc/llvm-project?rev=223911&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=223911&view=rev</a><br>
> Log:<br>
> DataLayout: Provide nicer diagnostics for malformed strings<br>
><br>
> Added:<br>
> llvm/trunk/test/Assembler/invalid-datalayout10.ll<br>
> llvm/trunk/test/Assembler/invalid-datalayout11.ll<br>
> llvm/trunk/test/Assembler/invalid-datalayout12.ll<br>
> llvm/trunk/test/Assembler/invalid-datalayout13.ll<br>
> Modified:<br>
> llvm/trunk/lib/IR/DataLayout.cpp<br>
><br>
> Modified: llvm/trunk/lib/IR/DataLayout.cpp<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/llvm/trunk/lib/IR/DataLayout.cpp?rev=223911&r1=223910&r2=223911&vi<br>
> ew=diff<br>
> ==========================================================================<br>
> ====<br>
> --- llvm/trunk/lib/IR/DataLayout.cpp (original)<br>
> +++ llvm/trunk/lib/IR/DataLayout.cpp Tue Dec 9 20:36:41 2014<br>
> @@ -199,6 +199,8 @@ static std::pair<StringRef, StringRef> s<br>
> std::pair<StringRef, StringRef> Split = Str.split(Separator);<br>
> if (Split.second.empty() && Split.first != Str)<br>
> report_fatal_error("Trailing separator in datalayout string");<br>
> + if (!Split.second.empty() && Split.first.empty())<br>
> + report_fatal_error("Expected token before separator in datalayout<br>
> string");<br>
> return Split;<br>
> }<br>
><br>
> @@ -297,6 +299,9 @@ void DataLayout::parseSpecifier(StringRe<br>
> "Sized aggregate specification in datalayout string");<br>
><br>
> // ABI alignment.<br>
> + if (Rest.empty())<br>
> + report_fatal_error(<br>
> + "Missing alignment specification in datalayout string");<br>
> Split = split(Rest, ':');<br>
> unsigned ABIAlign = inBytes(getInt(Tok));<br>
><br>
> @@ -328,8 +333,12 @@ void DataLayout::parseSpecifier(StringRe<br>
> break;<br>
> }<br>
> case 'm':<br>
> - assert(Tok.empty());<br>
> - assert(Rest.size() == 1);<br>
> + if (!Tok.empty())<br>
> + report_fatal_error("Unexpected trailing characters after mangling<br>
> specifier in datalayout string");<br>
> + if (Rest.empty())<br>
> + report_fatal_error("Expected mangling specifier in datalayout<br>
> string");<br>
> + if (Rest.size() > 1)<br>
> + report_fatal_error("Unknown mangling specifier in datalayout<br>
> string");<br>
> switch(Rest[0]) {<br>
> default:<br>
> report_fatal_error("Unknown mangling in datalayout string");<br>
><br>
> Added: llvm/trunk/test/Assembler/invalid-datalayout10.ll<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/llvm/trunk/test/Assembler/invalid-<br>
> datalayout10.ll?rev=223911&view=auto<br>
> ==========================================================================<br>
> ====<br>
> --- llvm/trunk/test/Assembler/invalid-datalayout10.ll (added)<br>
> +++ llvm/trunk/test/Assembler/invalid-datalayout10.ll Tue Dec 9 20:36:41<br>
> 2014<br>
> @@ -0,0 +1,3 @@<br>
> +; RUN: not llvm-as < %s 2>&1 | FileCheck %s<br>
> +target datalayout = "m"<br>
> +; CHECK: Expected mangling specifier in datalayout string<br>
><br>
> Added: llvm/trunk/test/Assembler/invalid-datalayout11.ll<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/llvm/trunk/test/Assembler/invalid-<br>
> datalayout11.ll?rev=223911&view=auto<br>
> ==========================================================================<br>
> ====<br>
> --- llvm/trunk/test/Assembler/invalid-datalayout11.ll (added)<br>
> +++ llvm/trunk/test/Assembler/invalid-datalayout11.ll Tue Dec 9 20:36:41<br>
> 2014<br>
> @@ -0,0 +1,3 @@<br>
> +; RUN: not llvm-as < %s 2>&1 | FileCheck %s<br>
> +target datalayout = "m."<br>
> +; CHECK: Unexpected trailing characters after mangling specifier in<br>
> datalayout string<br>
><br>
> Added: llvm/trunk/test/Assembler/invalid-datalayout12.ll<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/llvm/trunk/test/Assembler/invalid-<br>
> datalayout12.ll?rev=223911&view=auto<br>
> ==========================================================================<br>
> ====<br>
> --- llvm/trunk/test/Assembler/invalid-datalayout12.ll (added)<br>
> +++ llvm/trunk/test/Assembler/invalid-datalayout12.ll Tue Dec 9 20:36:41<br>
> 2014<br>
> @@ -0,0 +1,3 @@<br>
> +; RUN: not llvm-as < %s 2>&1 | FileCheck %s<br>
> +target datalayout = "f"<br>
> +; CHECK: Missing alignment specification in datalayout string<br>
><br>
> Added: llvm/trunk/test/Assembler/invalid-datalayout13.ll<br>
> URL: <a href="http://llvm.org/viewvc/llvm-" target="_blank">http://llvm.org/viewvc/llvm-</a><br>
> project/llvm/trunk/test/Assembler/invalid-<br>
> datalayout13.ll?rev=223911&view=auto<br>
> ==========================================================================<br>
> ====<br>
> --- llvm/trunk/test/Assembler/invalid-datalayout13.ll (added)<br>
> +++ llvm/trunk/test/Assembler/invalid-datalayout13.ll Tue Dec 9 20:36:41<br>
> 2014<br>
> @@ -0,0 +1,3 @@<br>
> +; RUN: not llvm-as < %s 2>&1 | FileCheck %s<br>
> +target datalayout = ":32"<br>
> +; CHECK: Expected token before separator in datalayout string<br>
><br>
><br>
> _______________________________________________<br>
> llvm-commits mailing list<br>
> <a href="mailto:llvm-commits@cs.uiuc.edu">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>
</div></div></blockquote></div><br></div>