https://github.com/kazutakahirata updated
https://github.com/llvm/llvm-project/pull/74916
>From ab33bda7fd31fbfc28344bb6f81ce08394e7c3fd Mon Sep 17 00:00:00 2001
From: Kazu Hirata
Date: Thu, 7 Dec 2023 23:20:42 -0800
Subject: [PATCH 1/3] [ADT] Rename SmallString::{starts,ends}with to
{starts,ends}_with
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.
---
clang-tools-extra/clang-doc/Mapper.cpp| 2 +-
clang-tools-extra/modularize/ModuleAssistant.cpp | 2 +-
clang/lib/AST/MicrosoftMangle.cpp | 8
clang/lib/Basic/Module.cpp| 2 +-
clang/lib/CrossTU/CrossTranslationUnit.cpp| 2 +-
clang/lib/Driver/Driver.cpp | 2 +-
clang/lib/Driver/ToolChains/Darwin.cpp| 2 +-
clang/lib/Lex/ModuleMap.cpp | 2 +-
clang/lib/Sema/SemaCodeComplete.cpp | 2 +-
lld/COFF/PDB.cpp | 2 +-
lld/MachO/InputFiles.cpp | 2 +-
lldb/source/Commands/CommandCompletions.cpp | 2 +-
llvm/include/llvm/ADT/SmallString.h | 12
llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp | 2 +-
llvm/tools/dsymutil/DebugMap.cpp | 2 +-
llvm/tools/llvm-cov/CodeCoverage.cpp | 2 +-
llvm/tools/llvm-cov/CoverageReport.cpp| 2 +-
llvm/tools/llvm-cov/SourceCoverageViewHTML.cpp| 2 +-
llvm/tools/llvm-ml/llvm-ml.cpp| 2 +-
llvm/unittests/Support/Path.cpp | 4 ++--
20 files changed, 27 insertions(+), 31 deletions(-)
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 ,
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