mirror of
https://github.com/intel/llvm.git
synced 2026-01-17 06:40:01 +08:00
[clang] Use llvm::replace (NFC) (#140264)
This commit is contained in:
@@ -106,7 +106,7 @@ inline void printSourceLocationAsJson(raw_ostream &Out, SourceLocation Loc,
|
||||
return llvm::is_contained(ForbiddenChars, Char);
|
||||
});
|
||||
// Handle windows-specific path delimiters.
|
||||
std::replace(filename.begin(), filename.end(), '\\', '/');
|
||||
llvm::replace(filename, '\\', '/');
|
||||
}
|
||||
Out << "\"line\": " << PLoc.getLine()
|
||||
<< ", \"column\": " << PLoc.getColumn()
|
||||
|
||||
@@ -310,7 +310,7 @@ void AMDGPUTargetInfo::getTargetDefines(const LangOptions &Opts,
|
||||
// e.g. gfx10-1-generic -> gfx10_1_generic
|
||||
if (GPUKind >= llvm::AMDGPU::GK_AMDGCN_GENERIC_FIRST &&
|
||||
GPUKind <= llvm::AMDGPU::GK_AMDGCN_GENERIC_LAST) {
|
||||
std::replace(CanonName.begin(), CanonName.end(), '-', '_');
|
||||
llvm::replace(CanonName, '-', '_');
|
||||
}
|
||||
|
||||
Builder.defineMacro(Twine("__") + Twine(CanonName) + Twine("__"));
|
||||
@@ -329,7 +329,7 @@ void AMDGPUTargetInfo::getTargetDefines(const LangOptions &Opts,
|
||||
auto Loc = OffloadArchFeatures.find(F);
|
||||
if (Loc != OffloadArchFeatures.end()) {
|
||||
std::string NewF = F.str();
|
||||
std::replace(NewF.begin(), NewF.end(), '-', '_');
|
||||
llvm::replace(NewF, '-', '_');
|
||||
Builder.defineMacro(Twine("__amdgcn_feature_") + Twine(NewF) +
|
||||
Twine("__"),
|
||||
Loc->second ? "1" : "0");
|
||||
|
||||
@@ -126,7 +126,7 @@ static std::string getBlockDescriptorName(const CGBlockInfo &BlockInfo,
|
||||
CGM.getContext().getObjCEncodingForBlock(BlockInfo.getBlockExpr());
|
||||
/// Replace occurrences of '@' with '\1'. '@' is reserved on ELF platforms
|
||||
/// as a separator between symbol name and symbol version.
|
||||
std::replace(TypeAtEncoding.begin(), TypeAtEncoding.end(), '@', '\1');
|
||||
llvm::replace(TypeAtEncoding, '@', '\1');
|
||||
}
|
||||
Name += "e" + llvm::to_string(TypeAtEncoding.size()) + "_" + TypeAtEncoding;
|
||||
Name += "l" + CGM.getObjCRuntime().getRCBlockLayoutStr(CGM, BlockInfo);
|
||||
|
||||
@@ -1454,10 +1454,10 @@ class CGObjCGNUstep2 : public CGObjCGNUstep {
|
||||
// character that is not a valid type encoding character (and, being
|
||||
// non-printable, never will be!)
|
||||
if (CGM.getTriple().isOSBinFormatELF())
|
||||
std::replace(MangledTypes.begin(), MangledTypes.end(), '@', '\1');
|
||||
llvm::replace(MangledTypes, '@', '\1');
|
||||
// = in dll exported names causes lld to fail when linking on Windows.
|
||||
if (CGM.getTriple().isOSWindows())
|
||||
std::replace(MangledTypes.begin(), MangledTypes.end(), '=', '\2');
|
||||
llvm::replace(MangledTypes, '=', '\2');
|
||||
return MangledTypes;
|
||||
}
|
||||
llvm::Constant *GetTypeString(llvm::StringRef TypeEncoding) {
|
||||
|
||||
@@ -6208,7 +6208,7 @@ const char *Driver::GetNamedOutputPath(Compilation &C, const JobAction &JA,
|
||||
if (is_style_windows(llvm::sys::path::Style::native)) {
|
||||
// BoundArch may contains ':', which is invalid in file names on Windows,
|
||||
// therefore replace it with '%'.
|
||||
std::replace(BoundArch.begin(), BoundArch.end(), ':', '@');
|
||||
llvm::replace(BoundArch, ':', '@');
|
||||
}
|
||||
|
||||
llvm::PrettyStackTraceString CrashInfo("Computing output path");
|
||||
|
||||
@@ -1906,8 +1906,7 @@ Error OffloadBundler::UnbundleArchive() {
|
||||
.str();
|
||||
// Replace ':' in optional target feature list with '_' to ensure
|
||||
// cross-platform validity.
|
||||
std::replace(OutputBundleName.begin(), OutputBundleName.end(), ':',
|
||||
'_');
|
||||
llvm::replace(OutputBundleName, ':', '_');
|
||||
|
||||
std::unique_ptr<MemoryBuffer> MemBuf = MemoryBuffer::getMemBufferCopy(
|
||||
DataStream.str(), OutputBundleName);
|
||||
|
||||
@@ -221,7 +221,7 @@ RocmInstallationDetector::getInstallationPathCandidates() {
|
||||
std::string VerStr = DirName.drop_front(strlen("rocm-")).str();
|
||||
// The ROCm directory name follows the format of
|
||||
// rocm-{major}.{minor}.{subMinor}[-{build}]
|
||||
std::replace(VerStr.begin(), VerStr.end(), '-', '.');
|
||||
llvm::replace(VerStr, '-', '.');
|
||||
V.tryParse(VerStr);
|
||||
return V;
|
||||
};
|
||||
|
||||
@@ -96,7 +96,7 @@ TEST(ToolChainTest, VFSGCCInstallation) {
|
||||
C->getDefaultToolChain().printVerboseInfo(OS);
|
||||
}
|
||||
if (is_style_windows(llvm::sys::path::Style::native))
|
||||
std::replace(S.begin(), S.end(), '\\', '/');
|
||||
llvm::replace(S, '\\', '/');
|
||||
EXPECT_EQ(
|
||||
"Found candidate GCC installation: "
|
||||
"/usr/lib/gcc/arm-linux-gnueabihf/4.6.3\n"
|
||||
@@ -120,7 +120,7 @@ TEST(ToolChainTest, VFSGCCInstallation) {
|
||||
C->getDefaultToolChain().printVerboseInfo(OS);
|
||||
}
|
||||
if (is_style_windows(llvm::sys::path::Style::native))
|
||||
std::replace(S.begin(), S.end(), '\\', '/');
|
||||
llvm::replace(S, '\\', '/');
|
||||
// Test that 4.5.3 from --sysroot is not overridden by 4.6.3 (larger
|
||||
// version) from /usr.
|
||||
EXPECT_EQ("Found candidate GCC installation: "
|
||||
@@ -162,7 +162,7 @@ TEST(ToolChainTest, VFSGCCInstallationRelativeDir) {
|
||||
C->getDefaultToolChain().printVerboseInfo(OS);
|
||||
}
|
||||
if (is_style_windows(llvm::sys::path::Style::native))
|
||||
std::replace(S.begin(), S.end(), '\\', '/');
|
||||
llvm::replace(S, '\\', '/');
|
||||
EXPECT_EQ("Found candidate GCC installation: "
|
||||
"/home/test/bin/../lib/gcc/arm-linux-gnueabi/4.6.1\n"
|
||||
"Selected GCC installation: "
|
||||
@@ -213,7 +213,7 @@ TEST(ToolChainTest, VFSSolarisMultiGCCInstallation) {
|
||||
C->getDefaultToolChain().printVerboseInfo(OS);
|
||||
}
|
||||
if (is_style_windows(llvm::sys::path::Style::native))
|
||||
std::replace(S.begin(), S.end(), '\\', '/');
|
||||
llvm::replace(S, '\\', '/');
|
||||
EXPECT_EQ("Found candidate GCC installation: "
|
||||
"/usr/gcc/11/lib/gcc/x86_64-pc-solaris2.11/11.4.0\n"
|
||||
"Selected GCC installation: "
|
||||
@@ -237,7 +237,7 @@ TEST(ToolChainTest, VFSSolarisMultiGCCInstallation) {
|
||||
C->getDefaultToolChain().printVerboseInfo(OS);
|
||||
}
|
||||
if (is_style_windows(llvm::sys::path::Style::native))
|
||||
std::replace(S.begin(), S.end(), '\\', '/');
|
||||
llvm::replace(S, '\\', '/');
|
||||
EXPECT_EQ("Found candidate GCC installation: "
|
||||
"/usr/gcc/11/lib/gcc/x86_64-pc-solaris2.11/11.4.0\n"
|
||||
"Selected GCC installation: "
|
||||
@@ -261,7 +261,7 @@ TEST(ToolChainTest, VFSSolarisMultiGCCInstallation) {
|
||||
C->getDefaultToolChain().printVerboseInfo(OS);
|
||||
}
|
||||
if (is_style_windows(llvm::sys::path::Style::native))
|
||||
std::replace(S.begin(), S.end(), '\\', '/');
|
||||
llvm::replace(S, '\\', '/');
|
||||
EXPECT_EQ("Found candidate GCC installation: "
|
||||
"/usr/gcc/11/lib/gcc/x86_64-pc-solaris2.11/11.4.0\n"
|
||||
"Selected GCC installation: "
|
||||
@@ -285,7 +285,7 @@ TEST(ToolChainTest, VFSSolarisMultiGCCInstallation) {
|
||||
C->getDefaultToolChain().printVerboseInfo(OS);
|
||||
}
|
||||
if (is_style_windows(llvm::sys::path::Style::native))
|
||||
std::replace(S.begin(), S.end(), '\\', '/');
|
||||
llvm::replace(S, '\\', '/');
|
||||
EXPECT_EQ("Found candidate GCC installation: "
|
||||
"/usr/gcc/11/lib/gcc/sparcv9-sun-solaris2.11/11.4.0\n"
|
||||
"Selected GCC installation: "
|
||||
@@ -308,7 +308,7 @@ TEST(ToolChainTest, VFSSolarisMultiGCCInstallation) {
|
||||
C->getDefaultToolChain().printVerboseInfo(OS);
|
||||
}
|
||||
if (is_style_windows(llvm::sys::path::Style::native))
|
||||
std::replace(S.begin(), S.end(), '\\', '/');
|
||||
llvm::replace(S, '\\', '/');
|
||||
EXPECT_EQ("Found candidate GCC installation: "
|
||||
"/usr/gcc/11/lib/gcc/sparcv9-sun-solaris2.11/11.4.0\n"
|
||||
"Selected GCC installation: "
|
||||
@@ -329,7 +329,7 @@ MATCHER_P(jobHasArgs, Substr, "") {
|
||||
Args += Arg;
|
||||
}
|
||||
if (is_style_windows(llvm::sys::path::Style::native))
|
||||
std::replace(Args.begin(), Args.end(), '\\', '/');
|
||||
llvm::replace(Args, '\\', '/');
|
||||
if (llvm::StringRef(Args).contains(Substr))
|
||||
return true;
|
||||
*result_listener << "whose args are '" << Args << "'";
|
||||
|
||||
Reference in New Issue
Block a user