[llvm] r223911 - DataLayout: Provide nicer diagnostics for malformed strings

David Majnemer david.majnemer at gmail.com
Tue Dec 9 21:07:37 PST 2014


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.


On Tue, Dec 9, 2014 at 8:43 PM, Robinson, Paul <
Paul_Robinson at playstation.sony.com> wrote:

> This is all lovely and I'm not complaining, as I probably couldn't have
> gotten back to PR21678 before the new year; but did you look at what
> Reid suggested in that PR?  It felt a little cleaner than converting
> assertions to report_fatal_error directly.
> Thanks,
> --paulr
>
> > -----Original Message-----
> > From: llvm-commits-bounces at cs.uiuc.edu [mailto:llvm-commits-
> > bounces at cs.uiuc.edu] On Behalf Of David Majnemer
> > Sent: Tuesday, December 09, 2014 6:37 PM
> > To: llvm-commits at cs.uiuc.edu
> > Subject: [llvm] r223911 - DataLayout: Provide nicer diagnostics for
> > malformed strings
> >
> > Author: majnemer
> > Date: Tue Dec  9 20:36:41 2014
> > New Revision: 223911
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=223911&view=rev
> > Log:
> > DataLayout: Provide nicer diagnostics for malformed strings
> >
> > Added:
> >     llvm/trunk/test/Assembler/invalid-datalayout10.ll
> >     llvm/trunk/test/Assembler/invalid-datalayout11.ll
> >     llvm/trunk/test/Assembler/invalid-datalayout12.ll
> >     llvm/trunk/test/Assembler/invalid-datalayout13.ll
> > Modified:
> >     llvm/trunk/lib/IR/DataLayout.cpp
> >
> > Modified: llvm/trunk/lib/IR/DataLayout.cpp
> > URL: http://llvm.org/viewvc/llvm-
> >
> project/llvm/trunk/lib/IR/DataLayout.cpp?rev=223911&r1=223910&r2=223911&vi
> > ew=diff
> >
> ==========================================================================
> > ====
> > --- llvm/trunk/lib/IR/DataLayout.cpp (original)
> > +++ llvm/trunk/lib/IR/DataLayout.cpp Tue Dec  9 20:36:41 2014
> > @@ -199,6 +199,8 @@ static std::pair<StringRef, StringRef> s
> >    std::pair<StringRef, StringRef> Split = Str.split(Separator);
> >    if (Split.second.empty() && Split.first != Str)
> >      report_fatal_error("Trailing separator in datalayout string");
> > +  if (!Split.second.empty() && Split.first.empty())
> > +    report_fatal_error("Expected token before separator in datalayout
> > string");
> >    return Split;
> >  }
> >
> > @@ -297,6 +299,9 @@ void DataLayout::parseSpecifier(StringRe
> >              "Sized aggregate specification in datalayout string");
> >
> >        // ABI alignment.
> > +      if (Rest.empty())
> > +        report_fatal_error(
> > +            "Missing alignment specification in datalayout string");
> >        Split = split(Rest, ':');
> >        unsigned ABIAlign = inBytes(getInt(Tok));
> >
> > @@ -328,8 +333,12 @@ void DataLayout::parseSpecifier(StringRe
> >        break;
> >      }
> >      case 'm':
> > -      assert(Tok.empty());
> > -      assert(Rest.size() == 1);
> > +      if (!Tok.empty())
> > +        report_fatal_error("Unexpected trailing characters after
> mangling
> > specifier in datalayout string");
> > +      if (Rest.empty())
> > +        report_fatal_error("Expected mangling specifier in datalayout
> > string");
> > +      if (Rest.size() > 1)
> > +        report_fatal_error("Unknown mangling specifier in datalayout
> > string");
> >        switch(Rest[0]) {
> >        default:
> >          report_fatal_error("Unknown mangling in datalayout string");
> >
> > Added: llvm/trunk/test/Assembler/invalid-datalayout10.ll
> > URL: http://llvm.org/viewvc/llvm-
> > project/llvm/trunk/test/Assembler/invalid-
> > datalayout10.ll?rev=223911&view=auto
> >
> ==========================================================================
> > ====
> > --- llvm/trunk/test/Assembler/invalid-datalayout10.ll (added)
> > +++ llvm/trunk/test/Assembler/invalid-datalayout10.ll Tue Dec  9 20:36:41
> > 2014
> > @@ -0,0 +1,3 @@
> > +; RUN: not llvm-as < %s 2>&1 | FileCheck %s
> > +target datalayout = "m"
> > +; CHECK: Expected mangling specifier in datalayout string
> >
> > Added: llvm/trunk/test/Assembler/invalid-datalayout11.ll
> > URL: http://llvm.org/viewvc/llvm-
> > project/llvm/trunk/test/Assembler/invalid-
> > datalayout11.ll?rev=223911&view=auto
> >
> ==========================================================================
> > ====
> > --- llvm/trunk/test/Assembler/invalid-datalayout11.ll (added)
> > +++ llvm/trunk/test/Assembler/invalid-datalayout11.ll Tue Dec  9 20:36:41
> > 2014
> > @@ -0,0 +1,3 @@
> > +; RUN: not llvm-as < %s 2>&1 | FileCheck %s
> > +target datalayout = "m."
> > +; CHECK: Unexpected trailing characters after mangling specifier in
> > datalayout string
> >
> > Added: llvm/trunk/test/Assembler/invalid-datalayout12.ll
> > URL: http://llvm.org/viewvc/llvm-
> > project/llvm/trunk/test/Assembler/invalid-
> > datalayout12.ll?rev=223911&view=auto
> >
> ==========================================================================
> > ====
> > --- llvm/trunk/test/Assembler/invalid-datalayout12.ll (added)
> > +++ llvm/trunk/test/Assembler/invalid-datalayout12.ll Tue Dec  9 20:36:41
> > 2014
> > @@ -0,0 +1,3 @@
> > +; RUN: not llvm-as < %s 2>&1 | FileCheck %s
> > +target datalayout = "f"
> > +; CHECK: Missing alignment specification in datalayout string
> >
> > Added: llvm/trunk/test/Assembler/invalid-datalayout13.ll
> > URL: http://llvm.org/viewvc/llvm-
> > project/llvm/trunk/test/Assembler/invalid-
> > datalayout13.ll?rev=223911&view=auto
> >
> ==========================================================================
> > ====
> > --- llvm/trunk/test/Assembler/invalid-datalayout13.ll (added)
> > +++ llvm/trunk/test/Assembler/invalid-datalayout13.ll Tue Dec  9 20:36:41
> > 2014
> > @@ -0,0 +1,3 @@
> > +; RUN: not llvm-as < %s 2>&1 | FileCheck %s
> > +target datalayout = ":32"
> > +; CHECK: Expected token before separator in datalayout string
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at cs.uiuc.edu
> > http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20141209/e8fa445b/attachment.html>


More information about the llvm-commits mailing list