DILineInfoSpecifier::FileLineInfoKind::AbsoluteFilePath, Info);
if (Info.Line == 0)
return "";
- std::string Ret = Info.FileName + ":" + std::to_string(Info.Line);
- convertToUnixPathSeparator({(char *)Ret.data(), Ret.size()});
- return Ret;
+ return convertToUnixPathSeparator(
+ Info.FileName + ":" + std::to_string(Info.Line));
}
// Returns "(internal)", "foo.a(bar.o)" or "baz.o".
// Returns the string form of the given argument.
std::string stringize(llvm::opt::Arg *Arg);
-// Converts path to use unix path separators.
-void convertToUnixPathSeparator(llvm::MutableArrayRef<char> Path);
+// Replaces backslashes with slashes if Windows.
+std::string convertToUnixPathSeparator(StringRef S);
}
// (i.e. in that case we are creating baz.cpio.)
SmallString<128> Fullpath;
path::append(Fullpath, Basename, Path);
- convertToUnixPathSeparator(Fullpath);
- writeMember(*OS, Fullpath, Data);
+ writeMember(*OS, convertToUnixPathSeparator(Fullpath), Data);
// Print the trailer and seek back.
// This way we have a valid archive if we crash.
Res = Root.substr(2);
path::append(Res, path::relative_path(Abs));
- convertToUnixPathSeparator(Res);
-
- return Res.str();
+ return convertToUnixPathSeparator(Res);
}
// Quote a given string if it contains a space character.
return K + " " + V;
}
-void lld::convertToUnixPathSeparator(MutableArrayRef<char> Path) {
+std::string lld::convertToUnixPathSeparator(StringRef S) {
#ifdef LLVM_ON_WIN32
- std::replace(Path.begin(), Path.end(), '\\', '/');
+ std:string Ret = S.str();
+ std::replace(Ret.begin(), Ret.end(), '\\', '/');
+ return Ret;
+#else
+ return S;
#endif
}