[llvm] r238579 - Fix crash in MCExpr::print.

David Blaikie 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>
wrote:

>
> 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>
> wrote:
>
>> Author: pete
>> Date: Fri May 29 12:19:11 2015
>> New Revision: 238579
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=238579&view=rev
>> Log:
>> 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
start.

- Dave


>
> Cheers,
> Pete
>
>
>
>>
>> Modified:
>>     llvm/trunk/lib/MC/MCExpr.cpp
>>
>> Modified: llvm/trunk/lib/MC/MCExpr.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCExpr.cpp?rev=238579&r1=238578&r2=238579&view=diff
>>
>> ==============================================================================
>> --- 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()[0] == '$';
>> +    bool UseParens = !Sym.getName().empty() && Sym.getName()[0] == '$';
>>
>
Also, might be easier to just write this as: Sym.getName().startswith("$")


>      if (UseParens)
>>        OS << '(' << Sym << ')';
>>      else
>>
>>
>> _______________________________________________
>> 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/20150529/06fc96ce/attachment.html>


More information about the llvm-commits mailing list