[clang-tools-extra] Use llvm::replace (NFC) (#140200)
This commit is contained in:
@@ -1022,12 +1022,12 @@ static llvm::Error serializeIndex(ClangDocContext &CDCtx) {
|
|||||||
// JavaScript from escaping characters incorrectly, and introducing bad paths
|
// JavaScript from escaping characters incorrectly, and introducing bad paths
|
||||||
// in the URLs.
|
// in the URLs.
|
||||||
std::string RootPathEscaped = RootPath.str().str();
|
std::string RootPathEscaped = RootPath.str().str();
|
||||||
std::replace(RootPathEscaped.begin(), RootPathEscaped.end(), '\\', '/');
|
llvm::replace(RootPathEscaped, '\\', '/');
|
||||||
OS << "var RootPath = \"" << RootPathEscaped << "\";\n";
|
OS << "var RootPath = \"" << RootPathEscaped << "\";\n";
|
||||||
|
|
||||||
llvm::SmallString<128> Base(CDCtx.Base);
|
llvm::SmallString<128> Base(CDCtx.Base);
|
||||||
std::string BaseEscaped = Base.str().str();
|
std::string BaseEscaped = Base.str().str();
|
||||||
std::replace(BaseEscaped.begin(), BaseEscaped.end(), '\\', '/');
|
llvm::replace(BaseEscaped, '\\', '/');
|
||||||
OS << "var Base = \"" << BaseEscaped << "\";\n";
|
OS << "var Base = \"" << BaseEscaped << "\";\n";
|
||||||
|
|
||||||
CDCtx.Idx.sort();
|
CDCtx.Idx.sort();
|
||||||
|
|||||||
@@ -49,9 +49,9 @@ std::string LLVMHeaderGuardCheck::getHeaderGuard(StringRef Filename,
|
|||||||
if (PosLLVM != StringRef::npos)
|
if (PosLLVM != StringRef::npos)
|
||||||
Guard = Guard.substr(PosLLVM);
|
Guard = Guard.substr(PosLLVM);
|
||||||
|
|
||||||
std::replace(Guard.begin(), Guard.end(), '/', '_');
|
llvm::replace(Guard, '/', '_');
|
||||||
std::replace(Guard.begin(), Guard.end(), '.', '_');
|
llvm::replace(Guard, '.', '_');
|
||||||
std::replace(Guard.begin(), Guard.end(), '-', '_');
|
llvm::replace(Guard, '-', '_');
|
||||||
|
|
||||||
// The prevalent style in clang is LLVM_CLANG_FOO_BAR_H
|
// The prevalent style in clang is LLVM_CLANG_FOO_BAR_H
|
||||||
if (StringRef(Guard).starts_with("clang"))
|
if (StringRef(Guard).starts_with("clang"))
|
||||||
|
|||||||
@@ -496,7 +496,7 @@ void IdentifierNamingCheck::HungarianNotation::loadFileConfig(
|
|||||||
StringRef Val = Options.get(Buffer, "");
|
StringRef Val = Options.get(Buffer, "");
|
||||||
if (!Val.empty()) {
|
if (!Val.empty()) {
|
||||||
std::string Type = PrimType.str();
|
std::string Type = PrimType.str();
|
||||||
std::replace(Type.begin(), Type.end(), '-', ' ');
|
llvm::replace(Type, '-', ' ');
|
||||||
HNOption.PrimitiveType[Type] = Val.str();
|
HNOption.PrimitiveType[Type] = Val.str();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1358,7 +1358,7 @@ IdentifierNamingCheck::getFailureInfo(
|
|||||||
std::string KindName =
|
std::string KindName =
|
||||||
fixupWithCase(Type, StyleNames[SK], ND, Style, HNOption,
|
fixupWithCase(Type, StyleNames[SK], ND, Style, HNOption,
|
||||||
IdentifierNamingCheck::CT_LowerCase);
|
IdentifierNamingCheck::CT_LowerCase);
|
||||||
std::replace(KindName.begin(), KindName.end(), '_', ' ');
|
llvm::replace(KindName, '_', ' ');
|
||||||
|
|
||||||
std::string Fixup = fixupWithStyle(Type, Name, Style, HNOption, ND);
|
std::string Fixup = fixupWithStyle(Type, Name, Style, HNOption, ND);
|
||||||
if (StringRef(Fixup) == Name) {
|
if (StringRef(Fixup) == Name) {
|
||||||
|
|||||||
@@ -800,7 +800,7 @@ void StoreDiags::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
|
|||||||
M << "'";
|
M << "'";
|
||||||
}
|
}
|
||||||
// Don't allow source code to inject newlines into diagnostics.
|
// Don't allow source code to inject newlines into diagnostics.
|
||||||
std::replace(Message.begin(), Message.end(), '\n', ' ');
|
llvm::replace(Message, '\n', ' ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Message.empty()) // either !SyntheticMessage, or we failed to make one.
|
if (Message.empty()) // either !SyntheticMessage, or we failed to make one.
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ LLVM_ATTRIBUTE_UNUSED std::string nodeToString(const DynTypedNode &N) {
|
|||||||
OS << ": ";
|
OS << ": ";
|
||||||
N.print(OS, PrintingPolicy(LangOptions()));
|
N.print(OS, PrintingPolicy(LangOptions()));
|
||||||
}
|
}
|
||||||
std::replace(S.begin(), S.end(), '\n', ' ');
|
llvm::replace(S, '\n', ' ');
|
||||||
return S;
|
return S;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -381,7 +381,7 @@ std::unique_ptr<SymbolIndex> openIndex(llvm::StringRef Index) {
|
|||||||
|
|
||||||
bool runCommand(std::string Request, const SymbolIndex &Index) {
|
bool runCommand(std::string Request, const SymbolIndex &Index) {
|
||||||
// Split on spaces and add required null-termination.
|
// Split on spaces and add required null-termination.
|
||||||
std::replace(Request.begin(), Request.end(), ' ', '\0');
|
llvm::replace(Request, ' ', '\0');
|
||||||
llvm::SmallVector<llvm::StringRef> Args;
|
llvm::SmallVector<llvm::StringRef> Args;
|
||||||
llvm::StringRef(Request).split(Args, '\0', /*MaxSplit=*/-1,
|
llvm::StringRef(Request).split(Args, '\0', /*MaxSplit=*/-1,
|
||||||
/*KeepEmpty=*/false);
|
/*KeepEmpty=*/false);
|
||||||
|
|||||||
@@ -443,7 +443,7 @@ static std::string replaceDotDot(StringRef Path) {
|
|||||||
// \returns The file path in canonical form.
|
// \returns The file path in canonical form.
|
||||||
std::string ModularizeUtilities::getCanonicalPath(StringRef FilePath) {
|
std::string ModularizeUtilities::getCanonicalPath(StringRef FilePath) {
|
||||||
std::string Tmp(replaceDotDot(FilePath));
|
std::string Tmp(replaceDotDot(FilePath));
|
||||||
std::replace(Tmp.begin(), Tmp.end(), '\\', '/');
|
llvm::replace(Tmp, '\\', '/');
|
||||||
StringRef Tmp2(Tmp);
|
StringRef Tmp2(Tmp);
|
||||||
if (Tmp2.starts_with("./"))
|
if (Tmp2.starts_with("./"))
|
||||||
Tmp = std::string(Tmp2.substr(2));
|
Tmp = std::string(Tmp2.substr(2));
|
||||||
|
|||||||
@@ -156,8 +156,8 @@ ensureNoCollisionWithReservedName(llvm::StringRef MightBeReservedName) {
|
|||||||
static std::string
|
static std::string
|
||||||
ensureVaidModuleName(llvm::StringRef MightBeInvalidName) {
|
ensureVaidModuleName(llvm::StringRef MightBeInvalidName) {
|
||||||
std::string SafeName(MightBeInvalidName);
|
std::string SafeName(MightBeInvalidName);
|
||||||
std::replace(SafeName.begin(), SafeName.end(), '-', '_');
|
llvm::replace(SafeName, '-', '_');
|
||||||
std::replace(SafeName.begin(), SafeName.end(), '.', '_');
|
llvm::replace(SafeName, '.', '_');
|
||||||
if (isdigit(SafeName[0]))
|
if (isdigit(SafeName[0]))
|
||||||
SafeName = "_" + SafeName;
|
SafeName = "_" + SafeName;
|
||||||
return SafeName;
|
return SafeName;
|
||||||
@@ -192,7 +192,7 @@ static bool addModuleDescription(Module *RootModule,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
// Make canonical.
|
// Make canonical.
|
||||||
std::replace(FilePath.begin(), FilePath.end(), '\\', '/');
|
llvm::replace(FilePath, '\\', '/');
|
||||||
// Insert module into tree, using subdirectories as submodules.
|
// Insert module into tree, using subdirectories as submodules.
|
||||||
for (llvm::sys::path::const_iterator I = llvm::sys::path::begin(FilePath),
|
for (llvm::sys::path::const_iterator I = llvm::sys::path::begin(FilePath),
|
||||||
E = llvm::sys::path::end(FilePath);
|
E = llvm::sys::path::end(FilePath);
|
||||||
|
|||||||
@@ -904,7 +904,7 @@ public:
|
|||||||
// Convert to a canonical path.
|
// Convert to a canonical path.
|
||||||
std::string getCanonicalPath(llvm::StringRef path) const {
|
std::string getCanonicalPath(llvm::StringRef path) const {
|
||||||
std::string CanonicalPath(path);
|
std::string CanonicalPath(path);
|
||||||
std::replace(CanonicalPath.begin(), CanonicalPath.end(), '\\', '/');
|
llvm::replace(CanonicalPath, '\\', '/');
|
||||||
return CanonicalPath;
|
return CanonicalPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ static std::string getSourceLocationString(Preprocessor &PP,
|
|||||||
std::string Result = SS.str();
|
std::string Result = SS.str();
|
||||||
|
|
||||||
// YAML treats backslash as escape, so use forward slashes.
|
// YAML treats backslash as escape, so use forward slashes.
|
||||||
std::replace(Result.begin(), Result.end(), '\\', '/');
|
llvm::replace(Result, '\\', '/');
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
@@ -653,7 +653,7 @@ void PPCallbacksTracker::appendFilePathArgument(const char *Name,
|
|||||||
llvm::StringRef Value) {
|
llvm::StringRef Value) {
|
||||||
std::string Path(Value);
|
std::string Path(Value);
|
||||||
// YAML treats backslash as escape, so use forward slashes.
|
// YAML treats backslash as escape, so use forward slashes.
|
||||||
std::replace(Path.begin(), Path.end(), '\\', '/');
|
llvm::replace(Path, '\\', '/');
|
||||||
appendQuotedArgument(Name, Path);
|
appendQuotedArgument(Name, Path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user