Author: Kazu Hirata
Date: 2023-12-09T14:28:45-08:00
New Revision: cc4ecfd68b79a44f101fe9924d088a83477797c0
URL:
https://github.com/llvm/llvm-project/commit/cc4ecfd68b79a44f101fe9924d088a83477797c0
DIFF:
https://github.com/llvm/llvm-project/commit/cc4ecfd68b79a44f101fe9924d088a83477797c0.diff
LOG: [ADT] Rename SmallString::{starts,ends}with to {starts,ends}_with (#74916)
This patch renames {starts,ends}with to {starts,ends}_with for
consistency with std::{string,string_view}::{starts,ends}_with in
C++20. Since there are only a handful of occurrences, this patch
skips the deprecation phase and simply renames them.
Added:
Modified:
clang-tools-extra/clang-doc/Mapper.cpp
clang-tools-extra/modularize/ModuleAssistant.cpp
clang/lib/AST/MicrosoftMangle.cpp
clang/lib/Basic/Module.cpp
clang/lib/CrossTU/CrossTranslationUnit.cpp
clang/lib/Driver/Driver.cpp
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Lex/ModuleMap.cpp
clang/lib/Sema/SemaCodeComplete.cpp
lld/COFF/PDB.cpp
lld/MachO/InputFiles.cpp
lldb/source/Commands/CommandCompletions.cpp
llvm/include/llvm/ADT/SmallString.h
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp
llvm/lib/Support/Windows/Path.inc
llvm/tools/dsymutil/DebugMap.cpp
llvm/tools/llvm-cov/CodeCoverage.cpp
llvm/tools/llvm-cov/CoverageReport.cpp
llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp
llvm/tools/llvm-ml/llvm-ml.cpp
llvm/unittests/Support/Path.cpp
Removed:
diff --git a/clang-tools-extra/clang-doc/Mapper.cpp
b/clang-tools-extra/clang-doc/Mapper.cpp
index 5264417748a12b..bb8b7952980ac6 100644
--- a/clang-tools-extra/clang-doc/Mapper.cpp
+++ b/clang-tools-extra/clang-doc/Mapper.cpp
@@ -103,7 +103,7 @@ llvm::SmallString<128> MapASTVisitor::getFile(const
NamedDecl *D,
.getPresumedLoc(D->getBeginLoc())
.getFilename());
IsFileInRootDir = false;
- if (RootDir.empty() || !File.startswith(RootDir))
+ if (RootDir.empty() || !File.starts_with(RootDir))
return File;
IsFileInRootDir = true;
llvm::SmallString<128> Prefix(RootDir);
diff --git a/clang-tools-extra/modularize/ModuleAssistant.cpp
b/clang-tools-extra/modularize/ModuleAssistant.cpp
index 0d4c09987eb1cf..5c11ffdb8589d5 100644
--- a/clang-tools-extra/modularize/ModuleAssistant.cpp
+++ b/clang-tools-extra/modularize/ModuleAssistant.cpp
@@ -175,7 +175,7 @@ static bool addModuleDescription(Module *RootModule,
llvm::SmallString<256> NativePath, NativePrefix;
llvm::sys::path::native(HeaderFilePath, NativePath);
llvm::sys::path::native(HeaderPrefix, NativePrefix);
- if (NativePath.startswith(NativePrefix))
+ if (NativePath.starts_with(NativePrefix))
FilePath = std::string(NativePath.substr(NativePrefix.size() + 1));
else
FilePath = std::string(HeaderFilePath);
diff --git a/clang/lib/AST/MicrosoftMangle.cpp
b/clang/lib/AST/MicrosoftMangle.cpp
index 50ab6ea59be9d0..c59a66e103a6e3 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -3809,14 +3809,14 @@ void
MicrosoftMangleContextImpl::mangleCXXRTTICompleteObjectLocator(
llvm::raw_svector_ostream Stream(VFTableMangling);
mangleCXXVFTable(Derived, BasePath, Stream);
- if (VFTableMangling.startswith("??@")) {
-assert(VFTableMangling.endswith("@"));
+ if (VFTableMangling.starts_with("??@")) {
+assert(VFTableMangling.ends_with("@"));
Out << VFTableMangling << "??_R4@";
return;
}
- assert(VFTableMangling.startswith("??_7") ||
- VFTableMangling.startswith("??_S"));
+ assert(VFTableMangling.starts_with("??_7") ||
+ VFTableMangling.starts_with("??_S"));
Out << "??_R4" << VFTableMangling.str().drop_front(4);
}
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index e4ac1abf12a7f8..7523e509a47108 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -89,7 +89,7 @@ static bool isPlatformEnvironment(const TargetInfo &Target,
StringRef Feature) {
// where both are valid examples of the same platform+environment but in the
// variant (2) the simulator is hardcoded as part of the platform name. Both
// forms above should match for "iossimulator" requirement.
- if (Target.getTriple().isOSDarwin() && PlatformEnv.endswith("simulator"))
+ if (Target.getTriple().isOSDarwin() && PlatformEnv.ends_with("simulator"))
return PlatformEnv == Feature || CmpPlatformEnv(PlatformEnv, Feature);
return PlatformEnv == Feature;
diff --git a/clang/lib/CrossTU/CrossTranslationUnit.cpp
b/clang/lib/CrossTU/CrossTranslationUnit.cpp
index 540c22d078654c..94c10e50d7d064 100644
--- a/clang/lib/CrossTU/CrossTranslationUnit.cpp
+++ b/clang/lib/CrossTU/CrossTranslationUnit.cpp
@@ -551,7 +551,7 @@ CrossTranslationUnitContext::ASTLoader::load(StringRef
Identifier) {
// Normalize by remov