[llvm] r200457 - tools: fix Twine abuse
David Blaikie
dblaikie at gmail.com
Thu Jan 30 09:25:53 PST 2014
On Wed, Jan 29, 2014 at 10:19 PM, Saleem Abdulrasool
<compnerd at compnerd.org>wrote:
> Author: compnerd
> Date: Thu Jan 30 00:19:27 2014
> New Revision: 200457
>
> URL: http://llvm.org/viewvc/llvm-project?rev=200457&view=rev
> Log:
> tools: fix Twine abuse
>
> utohexstr provides a temporary string, making it unsafe to use with the
> Twine
> interface which will not copy the string. Switch to using std::string.
>
> Modified:
> llvm/trunk/tools/llvm-readobj/ARMAttributeParser.cpp
>
> Modified: llvm/trunk/tools/llvm-readobj/ARMAttributeParser.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ARMAttributeParser.cpp?rev=200457&r1=200456&r2=200457&view=diff
>
> ==============================================================================
> --- llvm/trunk/tools/llvm-readobj/ARMAttributeParser.cpp (original)
> +++ llvm/trunk/tools/llvm-readobj/ARMAttributeParser.cpp Thu Jan 30
> 00:19:27 2014
> @@ -317,16 +317,16 @@ void ARMAttributeParser::ABI_align_neede
>
> uint64_t Value = ParseInteger(Data, Offset);
>
> - Twine Description;
> + std::string Description;
> if (Value < countof(Strings))
> - Description = StringRef(Strings[Value]);
> + Description = std::string(Strings[Value]);
>
I'm assuming the "std::string(*)" can be dropped here ^ (assuming
Strings[Value] is already a const char* or similar?)
> else if (Value <= 12)
> - Description = Twine("8-byte alignment, ") + utostr(1 << Value)
> - + Twine("-byte extended alignment");
> + Description = std::string("8-byte alignment, ") + utostr(1 << Value)
> + + std::string("-byte extended alignment");
>
Optionally, you can drop the second "std::string(*)" here.
(both comments apply below as well (speaking of, can these two chunks of
code be refactored out into a common function))
> else
> Description = "Invalid";
>
> - PrintAttribute(Tag, Value, Description.str());
> + PrintAttribute(Tag, Value, Description);
> }
>
> void ARMAttributeParser::ABI_align_preserved(AttrType Tag, const uint8_t
> *Data,
> @@ -338,16 +338,16 @@ void ARMAttributeParser::ABI_align_prese
>
> uint64_t Value = ParseInteger(Data, Offset);
>
> - Twine Description;
> + std::string Description;
> if (Value < countof(Strings))
> - Description = StringRef(Strings[Value]);
> + Description = std::string(Strings[Value]);
> else if (Value <= 12)
> - Description = Twine("8-byte stack alignment, ") + utostr(1 << Value)
> - + Twine("-byte data alignment");
> + Description = std::string("8-byte stack alignment, ") + utostr(1 <<
> Value)
> + + std::string("-byte data alignment");
> else
> Description = "Invalid";
>
> - PrintAttribute(Tag, Value, Description.str());
> + PrintAttribute(Tag, Value, Description);
> }
>
> void ARMAttributeParser::ABI_enum_size(AttrType Tag, const uint8_t *Data,
>
>
> _______________________________________________
> 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/20140130/21abd4be/attachment.html>
More information about the llvm-commits
mailing list