[lld] r337633 - Simplify; no behavior change.

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 20 16:06:34 PDT 2018


Author: nico
Date: Fri Jul 20 16:06:34 2018
New Revision: 337633

URL: http://llvm.org/viewvc/llvm-project?rev=337633&view=rev
Log:
Simplify; no behavior change.

Reviewed as part of https://reviews.llvm.org/D49189

Modified:
    lld/trunk/COFF/InputFiles.cpp

Modified: lld/trunk/COFF/InputFiles.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/InputFiles.cpp?rev=337633&r1=337632&r2=337633&view=diff
==============================================================================
--- lld/trunk/COFF/InputFiles.cpp (original)
+++ lld/trunk/COFF/InputFiles.cpp Fri Jul 20 16:06:34 2018
@@ -27,6 +27,7 @@
 #include "llvm/Support/Error.h"
 #include "llvm/Support/ErrorOr.h"
 #include "llvm/Support/FileSystem.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Target/TargetOptions.h"
 #include <cstring>
 #include <system_error>
@@ -489,10 +490,7 @@ MachineTypes BitcodeFile::getMachineType
 
 // Returns the last element of a path, which is supposed to be a filename.
 static StringRef getBasename(StringRef Path) {
-  size_t Pos = Path.find_last_of("\\/");
-  if (Pos == StringRef::npos)
-    return Path;
-  return Path.substr(Pos + 1);
+  return sys::path::filename(Path, sys::path::Style::windows);
 }
 
 // Returns a string in the format of "foo.obj" or "foo.obj(bar.lib)".




More information about the llvm-commits mailing list