[llvm] r200457 - tools: fix Twine abuse

Saleem Abdulrasool compnerd at compnerd.org
Wed Jan 29 22:19:27 PST 2014


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]);
   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");
   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,





More information about the llvm-commits mailing list