[PATCH] D25667: Fix call sites with spurious .c_str() calls from explicit StringRef conversion (NFC)

Mehdi AMINI via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 17 12:04:43 PDT 2016


mehdi_amini added a comment.

Thanks, will update!



================
Comment at: clang/lib/Driver/Job.cpp:183
         StringRef ShortName = llvm::sys::path::filename(CrashInfo->Filename);
-        printArg(OS, llvm::StringRef(ShortName.str().c_str()), Quote);
+        printArg(OS, ShortName.str(), Quote);
         continue;
----------------
malcolm.parsons wrote:
> .str() looks redundant.
Good point, one more sed line to add :)


================
Comment at: llvm/lib/MC/ELFObjectWriter.cpp:869
         Buf += Name.substr(Pos + Skip);
-        Name = StringRef(VersionSymSaver.save(StringRef(Buf.c_str())));
+        Name = VersionSymSaver.save(StringRef(Buf));
       }
----------------
malcolm.parsons wrote:
> sed didn't do what you wanted here.
Nice pattern, interestingly it is still compiling: double redundant StringRef()!


https://reviews.llvm.org/D25667





More information about the llvm-commits mailing list