mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-01-01 13:20:25 +00:00
Make convertToUnixPathSeparator return a new string instead of mutating argument.
llvm-svn: 288972
This commit is contained in:
parent
8b8f74f6b7
commit
63d064e9d1
@ -91,9 +91,8 @@ std::string elf::ObjectFile<ELFT>::getLineInfo(InputSectionBase<ELFT> *S,
|
||||
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".
|
||||
|
@ -66,8 +66,8 @@ std::string rewritePath(StringRef S);
|
||||
// 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);
|
||||
|
||||
}
|
||||
|
||||
|
@ -59,9 +59,8 @@ void CpioFile::append(StringRef Path, StringRef Data) {
|
||||
// (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.
|
||||
@ -92,9 +91,7 @@ std::string lld::relativeToRoot(StringRef Path) {
|
||||
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.
|
||||
@ -120,8 +117,12 @@ std::string lld::stringize(opt::Arg *Arg) {
|
||||
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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user