[lld] r259186 - Replace StringRef with std::string in LinkerDriver::addLibrary(StringRef Name) because std::string is destroyed after assigning what fills the buffer with garbage and StringRef is no more valid.

George Rimar via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 29 02:52:53 PST 2016


Author: grimar
Date: Fri Jan 29 04:52:52 2016
New Revision: 259186

URL: http://llvm.org/viewvc/llvm-project?rev=259186&view=rev
Log:
Replace StringRef with std::string in LinkerDriver::addLibrary(StringRef Name) because std::string is destroyed after assigning what fills the buffer with garbage and StringRef is no more valid.
That fixes few failing tests under windows+msvs2015(debug).

Modified:
    lld/trunk/ELF/Driver.cpp

Modified: lld/trunk/ELF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.cpp?rev=259186&r1=259185&r2=259186&view=diff
==============================================================================
--- lld/trunk/ELF/Driver.cpp (original)
+++ lld/trunk/ELF/Driver.cpp Fri Jan 29 04:52:52 2016
@@ -114,7 +114,7 @@ void LinkerDriver::addFile(StringRef Pat
 
 // Add a given library by searching it from input search paths.
 void LinkerDriver::addLibrary(StringRef Name) {
-  StringRef Path = searchLibrary(Name);
+  std::string Path = searchLibrary(Name);
   if (Path.empty())
     error("Unable to find library -l" + Name);
   else




More information about the llvm-commits mailing list