Don't use Twine objects after their lifetimes end.
authorFilipe Cabecinhas <me@filcab.net>
Tue, 3 Nov 2015 13:48:21 +0000 (13:48 +0000)
committerFilipe Cabecinhas <me@filcab.net>
Tue, 3 Nov 2015 13:48:21 +0000 (13:48 +0000)
No test, since it would depend on what the compiler can optimize/reuse.
My next commit made this bug visible on Linux Release compiles with some
versions of gcc.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251909 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Bitcode/Reader/BitcodeReader.cpp

index 4b8b554b252e05a8c925947c66c73b6afbe17f41..74a5553ce6e4b018caf8f79fddc5ff0b52bf2b19 100644 (file)
@@ -526,19 +526,19 @@ static std::error_code error(DiagnosticHandlerFunction DiagnosticHandler,
 
 std::error_code BitcodeReader::error(BitcodeError E, const Twine &Message) {
   if (!ProducerIdentification.empty()) {
-    Twine MsgWithID = Message + " (Producer: '" + ProducerIdentification +
-                      "' Reader: 'LLVM " + LLVM_VERSION_STRING "')";
-    return ::error(DiagnosticHandler, make_error_code(E), MsgWithID);
+    return ::error(DiagnosticHandler, make_error_code(E),
+                   Message + " (Producer: '" + ProducerIdentification +
+                       "' Reader: 'LLVM " + LLVM_VERSION_STRING "')");
   }
   return ::error(DiagnosticHandler, make_error_code(E), Message);
 }
 
 std::error_code BitcodeReader::error(const Twine &Message) {
   if (!ProducerIdentification.empty()) {
-    Twine MsgWithID = Message + " (Producer: '" + ProducerIdentification +
-                      "' Reader: 'LLVM " + LLVM_VERSION_STRING "')";
     return ::error(DiagnosticHandler,
-                   make_error_code(BitcodeError::CorruptedBitcode), MsgWithID);
+                   make_error_code(BitcodeError::CorruptedBitcode),
+                   Message + " (Producer: '" + ProducerIdentification +
+                       "' Reader: 'LLVM " + LLVM_VERSION_STRING "')");
   }
   return ::error(DiagnosticHandler,
                  make_error_code(BitcodeError::CorruptedBitcode), Message);