llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-codegen Author: Kazu Hirata (kazutakahirata) <details> <summary>Changes</summary> --- Full diff: https://github.com/llvm/llvm-project/pull/140264.diff 8 Files Affected: - (modified) clang/include/clang/Basic/JsonSupport.h (+1-1) - (modified) clang/lib/Basic/Targets/AMDGPU.cpp (+2-2) - (modified) clang/lib/CodeGen/CGBlocks.cpp (+1-1) - (modified) clang/lib/CodeGen/CGObjCGNU.cpp (+2-2) - (modified) clang/lib/Driver/Driver.cpp (+1-1) - (modified) clang/lib/Driver/OffloadBundler.cpp (+1-2) - (modified) clang/lib/Driver/ToolChains/AMDGPU.cpp (+1-1) - (modified) clang/unittests/Driver/ToolChainTest.cpp (+9-9) ``````````diff diff --git a/clang/include/clang/Basic/JsonSupport.h b/clang/include/clang/Basic/JsonSupport.h index bcaa3d364444e..51fb76c011067 100644 --- a/clang/include/clang/Basic/JsonSupport.h +++ b/clang/include/clang/Basic/JsonSupport.h @@ -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() diff --git a/clang/lib/Basic/Targets/AMDGPU.cpp b/clang/lib/Basic/Targets/AMDGPU.cpp index c368200f3f739..9a935948882fd 100644 --- a/clang/lib/Basic/Targets/AMDGPU.cpp +++ b/clang/lib/Basic/Targets/AMDGPU.cpp @@ -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"); diff --git a/clang/lib/CodeGen/CGBlocks.cpp b/clang/lib/CodeGen/CGBlocks.cpp index 40627d6ffd3c9..adb353d568cd2 100644 --- a/clang/lib/CodeGen/CGBlocks.cpp +++ b/clang/lib/CodeGen/CGBlocks.cpp @@ -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); diff --git a/clang/lib/CodeGen/CGObjCGNU.cpp b/clang/lib/CodeGen/CGObjCGNU.cpp index e03539d1ccdd0..3fc837c12a925 100644 --- a/clang/lib/CodeGen/CGObjCGNU.cpp +++ b/clang/lib/CodeGen/CGObjCGNU.cpp @@ -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) { diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp index 192f97996f69e..a5a0393ad7912 100644 --- a/clang/lib/Driver/Driver.cpp +++ b/clang/lib/Driver/Driver.cpp @@ -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"); diff --git a/clang/lib/Driver/OffloadBundler.cpp b/clang/lib/Driver/OffloadBundler.cpp index e7a737796925e..3dfd51ee2365a 100644 --- a/clang/lib/Driver/OffloadBundler.cpp +++ b/clang/lib/Driver/OffloadBundler.cpp @@ -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); diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp index 35ca019795ddc..998106cf52d66 100644 --- a/clang/lib/Driver/ToolChains/AMDGPU.cpp +++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp @@ -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; }; diff --git a/clang/unittests/Driver/ToolChainTest.cpp b/clang/unittests/Driver/ToolChainTest.cpp index 9fe8cd18beb9b..c1ffe4a82ce4b 100644 --- a/clang/unittests/Driver/ToolChainTest.cpp +++ b/clang/unittests/Driver/ToolChainTest.cpp @@ -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 << "'"; `````````` </details> https://github.com/llvm/llvm-project/pull/140264 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits