<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jan 29, 2014 at 10:19 PM, Saleem Abdulrasool <span dir="ltr"><<a href="mailto:compnerd@compnerd.org" target="_blank">compnerd@compnerd.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: compnerd<br>
Date: Thu Jan 30 00:19:27 2014<br>
New Revision: 200457<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=200457&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=200457&view=rev</a><br>
Log:<br>
tools: fix Twine abuse<br>
<br>
utohexstr provides a temporary string, making it unsafe to use with the Twine<br>
interface which will not copy the string.  Switch to using std::string.<br>
<br>
Modified:<br>
    llvm/trunk/tools/llvm-readobj/ARMAttributeParser.cpp<br>
<br>
Modified: llvm/trunk/tools/llvm-readobj/ARMAttributeParser.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ARMAttributeParser.cpp?rev=200457&r1=200456&r2=200457&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-readobj/ARMAttributeParser.cpp?rev=200457&r1=200456&r2=200457&view=diff</a><br>

==============================================================================<br>
--- llvm/trunk/tools/llvm-readobj/ARMAttributeParser.cpp (original)<br>
+++ llvm/trunk/tools/llvm-readobj/ARMAttributeParser.cpp Thu Jan 30 00:19:27 2014<br>
@@ -317,16 +317,16 @@ void ARMAttributeParser::ABI_align_neede<br>
<br>
   uint64_t Value = ParseInteger(Data, Offset);<br>
<br>
-  Twine Description;<br>
+  std::string Description;<br>
   if (Value < countof(Strings))<br>
-    Description = StringRef(Strings[Value]);<br>
+    Description = std::string(Strings[Value]);<br></blockquote><div><br></div><div>I'm assuming the "std::string(*)" can be dropped here ^ (assuming Strings[Value] is already a const char* or similar?)</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
   else if (Value <= 12)<br>
-    Description = Twine("8-byte alignment, ") + utostr(1 << Value)<br>
-                + Twine("-byte extended alignment");<br>
+    Description = std::string("8-byte alignment, ") + utostr(1 << Value)<br>
+                + std::string("-byte extended alignment");<br></blockquote><div><br></div><div>Optionally, you can drop the second "std::string(*)" here.<br><br>(both comments apply below as well (speaking of, can these two chunks of code be refactored out into a common function))</div>
<div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
   else<br>
     Description = "Invalid";<br>
<br>
-  PrintAttribute(Tag, Value, Description.str());<br>
+  PrintAttribute(Tag, Value, Description);<br>
 }<br>
<br>
 void ARMAttributeParser::ABI_align_preserved(AttrType Tag, const uint8_t *Data,<br>
@@ -338,16 +338,16 @@ void ARMAttributeParser::ABI_align_prese<br>
<br>
   uint64_t Value = ParseInteger(Data, Offset);<br>
<br>
-  Twine Description;<br>
+  std::string Description;<br>
   if (Value < countof(Strings))<br>
-    Description = StringRef(Strings[Value]);<br>
+    Description = std::string(Strings[Value]);<br>
   else if (Value <= 12)<br>
-    Description = Twine("8-byte stack alignment, ") + utostr(1 << Value)<br>
-                + Twine("-byte data alignment");<br>
+    Description = std::string("8-byte stack alignment, ") + utostr(1 << Value)<br>
+                + std::string("-byte data alignment");<br>
   else<br>
     Description = "Invalid";<br>
<br>
-  PrintAttribute(Tag, Value, Description.str());<br>
+  PrintAttribute(Tag, Value, Description);<br>
 }<br>
<br>
 void ARMAttributeParser::ABI_enum_size(AttrType Tag, const uint8_t *Data,<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>