[lld] r284361 - ELF: Fix a misuse of Twine::toStringRef

Justin Bogner via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 16 23:08:48 PDT 2016


Author: bogner
Date: Mon Oct 17 01:08:48 2016
New Revision: 284361

URL: http://llvm.org/viewvc/llvm-project?rev=284361&view=rev
Log:
ELF: Fix a misuse of Twine::toStringRef

While the toStringRef API almost certainly ends up populating the
SmallString here, the correct way to use this API is to use the return
value.

Modified:
    lld/trunk/ELF/LinkerScript.cpp

Modified: lld/trunk/ELF/LinkerScript.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LinkerScript.cpp?rev=284361&r1=284360&r2=284361&view=diff
==============================================================================
--- lld/trunk/ELF/LinkerScript.cpp (original)
+++ lld/trunk/ELF/LinkerScript.cpp Mon Oct 17 01:08:48 2016
@@ -1018,10 +1018,10 @@ void ScriptParser::readLinkerScript() {
 
 void ScriptParser::addFile(StringRef S) {
   if (IsUnderSysroot && S.startswith("/")) {
-    SmallString<128> Path;
-    (Config->Sysroot + S).toStringRef(Path);
+    SmallString<128> PathData;
+    StringRef Path = (Config->Sysroot + S).toStringRef(PathData);
     if (sys::fs::exists(Path)) {
-      Driver->addFile(Saver.save(Path.str()));
+      Driver->addFile(Saver.save(Path));
       return;
     }
   }




More information about the llvm-commits mailing list