Skip to content

Commit 8210cdd

Browse files
[llvm] Use llvm::replace (NFC) (llvm#137481)
1 parent fda8b75 commit 8210cdd

File tree

16 files changed

+31
-42
lines changed

16 files changed

+31
-42
lines changed

llvm/include/llvm/TableGen/DirectiveEmitter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class BaseRecord {
116116
std::string getFormattedName() const {
117117
StringRef Name = Def->getValueAsString("name");
118118
std::string N = Name.str();
119-
std::replace(N.begin(), N.end(), ' ', '_');
119+
llvm::replace(N, ' ', '_');
120120
return N;
121121
}
122122

llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ StringRef CodeViewDebug::getFullFilepath(const DIFile *File) {
164164
// Canonicalize the path. We have to do it textually because we may no longer
165165
// have access the file in the filesystem.
166166
// First, replace all slashes with backslashes.
167-
std::replace(Filepath.begin(), Filepath.end(), '/', '\\');
167+
llvm::replace(Filepath, '/', '\\');
168168

169169
// Remove all "\.\" with "\".
170170
size_t Cursor = 0;

llvm/lib/CodeGen/LiveDebugValues/InstrRefBasedImpl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -928,8 +928,7 @@ class TransferTracker {
928928
assert(ActiveVLocIt != ActiveVLocs.end());
929929

930930
// Update all instances of Src in the variable's tracked values to Dst.
931-
std::replace(ActiveVLocIt->second.Ops.begin(),
932-
ActiveVLocIt->second.Ops.end(), SrcOp, DstOp);
931+
llvm::replace(ActiveVLocIt->second.Ops, SrcOp, DstOp);
933932

934933
auto &[Var, DILoc] = DVMap.lookupDVID(VarID);
935934
MachineInstr *MI = MTracker->emitLoc(ActiveVLocIt->second.Ops, Var, DILoc,

llvm/lib/CodeGen/LiveVariables.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -764,7 +764,7 @@ void LiveVariables::recomputeForSingleDefVirtReg(Register Reg) {
764764
void LiveVariables::replaceKillInstruction(Register Reg, MachineInstr &OldMI,
765765
MachineInstr &NewMI) {
766766
VarInfo &VI = getVarInfo(Reg);
767-
std::replace(VI.Kills.begin(), VI.Kills.end(), &OldMI, &NewMI);
767+
llvm::replace(VI.Kills, &OldMI, &NewMI);
768768
}
769769

770770
/// removeVirtualRegistersKilled - Remove all killed info for the specified

llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2713,8 +2713,7 @@ void SelectionDAGISel::UpdateChains(
27132713
assert(ChainVal.getValueType() == MVT::Other && "Not a chain?");
27142714
SelectionDAG::DAGNodeDeletedListener NDL(
27152715
*CurDAG, [&](SDNode *N, SDNode *E) {
2716-
std::replace(ChainNodesMatched.begin(), ChainNodesMatched.end(), N,
2717-
static_cast<SDNode *>(nullptr));
2716+
llvm::replace(ChainNodesMatched, N, static_cast<SDNode *>(nullptr));
27182717
});
27192718
if (ChainNode->getOpcode() != ISD::TokenFactor)
27202719
ReplaceUses(ChainVal, InputChain);

llvm/lib/DebugInfo/LogicalView/Core/LVSupport.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ LVStringPool &llvm::logicalview::getStringPool() { return StringPool; }
3131
std::string llvm::logicalview::transformPath(StringRef Path) {
3232
std::string Name(Path);
3333
std::transform(Name.begin(), Name.end(), Name.begin(), tolower);
34-
std::replace(Name.begin(), Name.end(), '\\', '/');
34+
llvm::replace(Name, '\\', '/');
3535

3636
// Remove all duplicate slashes.
3737
size_t Pos = 0;

llvm/lib/DebugInfo/PDB/PDBSymbolCompiland.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ std::string PDBSymbolCompiland::getSourceFileFullPath() const {
6363
auto Len = EnvWorkingDir.length();
6464
if (EnvWorkingDir[Len - 1] != '/' && EnvWorkingDir[Len - 1] != '\\') {
6565
std::string Path = EnvWorkingDir + "\\" + EnvSrc;
66-
std::replace(Path.begin(), Path.end(), '/', '\\');
66+
llvm::replace(Path, '/', '\\');
6767
// We will return it as full path if we can't find a better one.
6868
if (sys::path::is_absolute(Path))
6969
SourceFileFullPath = Path;

llvm/lib/Support/GraphWriter.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,8 @@ static std::string replaceIllegalFilenameChars(std::string Filename,
102102
std::string IllegalChars =
103103
is_style_windows(sys::path::Style::native) ? "\\/:?\"<>|" : "/";
104104

105-
for (char IllegalChar : IllegalChars) {
106-
std::replace(Filename.begin(), Filename.end(), IllegalChar,
107-
ReplacementChar);
108-
}
105+
for (char IllegalChar : IllegalChars)
106+
llvm::replace(Filename, IllegalChar, ReplacementChar);
109107

110108
return Filename;
111109
}

llvm/lib/Support/Path.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,7 @@ void native(SmallVectorImpl<char> &Path, Style style) {
561561
Path = PathHome;
562562
}
563563
} else {
564-
std::replace(Path.begin(), Path.end(), '\\', '/');
564+
llvm::replace(Path, '\\', '/');
565565
}
566566
}
567567

@@ -570,7 +570,7 @@ std::string convert_to_slash(StringRef path, Style style) {
570570
return std::string(path);
571571

572572
std::string s = path.str();
573-
std::replace(s.begin(), s.end(), '\\', '/');
573+
llvm::replace(s, '\\', '/');
574574
return s;
575575
}
576576

llvm/lib/Target/SPIRV/SPIRVPrepareFunctions.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ static std::string lowerLLVMIntrinsicName(IntrinsicInst *II) {
6767
Function *IntrinsicFunc = II->getCalledFunction();
6868
assert(IntrinsicFunc && "Missing function");
6969
std::string FuncName = IntrinsicFunc->getName().str();
70-
std::replace(FuncName.begin(), FuncName.end(), '.', '_');
70+
llvm::replace(FuncName, '.', '_');
7171
FuncName = "spirv." + FuncName;
7272
return FuncName;
7373
}

0 commit comments

Comments
 (0)