[llvm-commits] [lld] Fix some warnings

Michael Spencer bigcheesegs at gmail.com
Thu Apr 26 11:39:57 PDT 2012


On Thu, Apr 26, 2012 at 8:47 AM, Evandro Menezes
<emenezes at codeaurora.org> wrote:
> Joerg,
>
> Yes, I guess then that StringRef::size_type is better.  See attachment.
>
> Thanks,
>
>
> --
> Evandro Menezes          Austin, TX          emenezes at codeaurora.org
> Qualcomm Innovation Center, Inc is a member of the Code Aurora Forum
>
>
> On 04/26/12 10:40, Joerg Sonnenberger wrote:
>>
>> On Thu, Apr 26, 2012 at 10:37:04AM -0500, Evandro Menezes wrote:
>>>
>>> With that said, there's only one warning:
>>>
>>> .../tools/lld/lib/Platforms/Darwin/ExecutableWriter.cpp:1222:30:
>>> warning: comparison between signed and unsigned integer expressions
>>> [-Wsign-compare]
>>>
>>> If this is worth getting rid off, is this patch OK?
>>
>>
>> Like I said, shouldn't that be either size_t or StringRef::size_type?
>> Otherwise it looks ok.
>>
>> Joerg
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>

> void DyldInfoChunk::append_string(StringRef str) {
>   const char *s = str.data();
>-  for (int i=str.size(); i > 0; --i) {
>+  for (auto i=str.size(); i > 0; --i) {
>     _bytes.push_back(*s++);
>   }

This can be replaced with:

_bytes.insert(_bytes.end(), str.begin(), str.end());

>   _bytes.push_back('\0');
>@@ -1219,7 +1219,7 @@ void SymbolStringsChunk::computeSize(const lld::Fi
> uint32_t SymbolStringsChunk::stringIndex(StringRef str) {
>   uint32_t result = _strings.size();
>   const char* s = str.data();
>-  for (int i=0; i < str.size(); ++i) {
>+  for (StringRef::size_type i=0; i < str.size(); ++i) {
>     _strings.push_back(s[i]);
>   }
>   _strings.push_back('\0');

Exact same thing here.

- Michael Spencer




More information about the llvm-commits mailing list