[llvm] r238579 - Fix crash in MCExpr::print.
dblaikie at gmail.com
Fri May 29 11:17:34 PDT 2015
On Fri, May 29, 2015 at 11:01 AM, Pete Cooper <peter_cooper at apple.com>
> On May 29, 2015, at 10:59 AM, David Blaikie <dblaikie at gmail.com> wrote:
> On Fri, May 29, 2015 at 10:19 AM, Pete Cooper <peter_cooper at apple.com>
>> Author: pete
>> Date: Fri May 29 12:19:11 2015
>> New Revision: 238579
>> URL: http://llvm.org/viewvc/llvm-project?rev=238579&view=rev
>> Fix crash in MCExpr::print.
>> Symbols are no longer required to be named, but this leads to a crash
>> here if an
>> unnamed symbol checks that its first character is '$'.
>> Change the code to first check for a name, then check its first character.
>> No test case i'm afraid as this is debugging code, but any test case with
>> temp labels
>> and 'llc --debug --filetype=obj' would have crashed.
> I think I missed a step - why wouldn't we have a test that does that? (llc
> --debug --filetype=obj)?
> I guess we could, I just didn’t think we tended to have tests that do
> --debug. I’ve got no problem adding it if you want.
Doesn't look like we do, but I reckon it wouldn't hurt to add them/some/a
>> Modified: llvm/trunk/lib/MC/MCExpr.cpp
>> --- llvm/trunk/lib/MC/MCExpr.cpp (original)
>> +++ llvm/trunk/lib/MC/MCExpr.cpp Fri May 29 12:19:11 2015
>> @@ -43,7 +43,7 @@ void MCExpr::print(raw_ostream &OS) cons
>> const MCSymbol &Sym = SRE.getSymbol();
>> // Parenthesize names that start with $ so that they don't look like
>> // absolute names.
>> - bool UseParens = Sym.getName() == '$';
>> + bool UseParens = !Sym.getName().empty() && Sym.getName() == '$';
Also, might be easier to just write this as: Sym.getName().startswith("$")
> if (UseParens)
>> OS << '(' << Sym << ')';
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the llvm-commits