aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2023-12-13 08:54:13 -0800
committerGitHub <noreply@github.com>2023-12-13 08:54:13 -0800
commitf3dcc2351cff7b26c9870d737e5d431551542d9e (patch)
tree31fa2bd937d91cd191045356b5f1ee23316605a3
parenteaa11526c873b65a9dc0aaf0ebaf66de3db8ed21 (diff)
downloadllvm-f3dcc2351cff7b26c9870d737e5d431551542d9e.zip
llvm-f3dcc2351cff7b26c9870d737e5d431551542d9e.tar.gz
llvm-f3dcc2351cff7b26c9870d737e5d431551542d9e.tar.bz2
[clang] Use StringRef::{starts,ends}_with (NFC) (#75149)
This patch replaces uses of StringRef::{starts,ends}with with StringRef::{starts,ends}_with for consistency with std::{string,string_view}::{starts,ends}_with in C++20. I'm planning to deprecate and eventually remove StringRef::{starts,ends}with.
-rw-r--r--clang/include/clang/Basic/Attr.td6
-rw-r--r--clang/include/clang/Basic/IdentifierTable.h2
-rw-r--r--clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h4
-rw-r--r--clang/lib/APINotes/APINotesManager.cpp2
-rw-r--r--clang/lib/APINotes/APINotesYAMLCompiler.cpp2
-rw-r--r--clang/lib/ARCMigrate/ARCMT.cpp2
-rw-r--r--clang/lib/ARCMigrate/ObjCMT.cpp14
-rw-r--r--clang/lib/ARCMigrate/TransUnbridgedCasts.cpp2
-rw-r--r--clang/lib/ARCMigrate/TransformActions.cpp2
-rw-r--r--clang/lib/ARCMigrate/Transforms.cpp2
-rw-r--r--clang/lib/AST/ASTContext.cpp4
-rw-r--r--clang/lib/AST/DeclPrinter.cpp2
-rw-r--r--clang/lib/AST/Mangle.cpp2
-rw-r--r--clang/lib/AST/MicrosoftMangle.cpp2
-rw-r--r--clang/lib/AST/PrintfFormatString.cpp2
-rw-r--r--clang/lib/AST/RawCommentList.cpp4
-rw-r--r--clang/lib/AST/Stmt.cpp7
-rw-r--r--clang/lib/ASTMatchers/ASTMatchersInternal.cpp12
-rw-r--r--clang/lib/ASTMatchers/Dynamic/Parser.cpp6
-rw-r--r--clang/lib/Analysis/BodyFarm.cpp4
-rw-r--r--clang/lib/Analysis/CallGraph.cpp2
-rw-r--r--clang/lib/Analysis/CalledOnceCheck.cpp2
-rw-r--r--clang/lib/Analysis/CocoaConventions.cpp11
-rw-r--r--clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp2
-rw-r--r--clang/lib/Analysis/RetainSummaryManager.cpp14
-rw-r--r--clang/lib/Basic/Attributes.cpp6
-rw-r--r--clang/lib/Basic/DiagnosticIDs.cpp2
-rw-r--r--clang/lib/Basic/IdentifierTable.cpp4
-rw-r--r--clang/lib/Basic/Module.cpp3
-rw-r--r--clang/lib/Basic/Sarif.cpp2
-rw-r--r--clang/lib/Basic/TargetInfo.cpp10
-rw-r--r--clang/lib/Basic/Targets/AArch64.cpp16
-rw-r--r--clang/lib/Basic/Targets/AMDGPU.cpp2
-rw-r--r--clang/lib/Basic/Targets/Mips.cpp2
-rw-r--r--clang/lib/Basic/Targets/NVPTX.cpp2
-rw-r--r--clang/lib/Basic/Targets/RISCV.cpp8
-rw-r--r--clang/lib/Basic/Warnings.cpp8
-rw-r--r--clang/lib/CodeGen/CGCall.cpp2
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp7
-rw-r--r--clang/lib/CodeGen/CGException.cpp6
-rw-r--r--clang/lib/CodeGen/CGExpr.cpp4
-rw-r--r--clang/lib/CodeGen/CGObjCMac.cpp4
-rw-r--r--clang/lib/CodeGen/CGRecordLayoutBuilder.cpp2
-rw-r--r--clang/lib/CodeGen/CGStmt.cpp2
-rw-r--r--clang/lib/CodeGen/CodeGenAction.cpp2
-rw-r--r--clang/lib/CodeGen/CodeGenModule.cpp16
-rw-r--r--clang/lib/CodeGen/Targets/SPIR.cpp6
-rw-r--r--clang/lib/Driver/Distro.cpp12
-rw-r--r--clang/lib/Driver/Driver.cpp22
-rw-r--r--clang/lib/Driver/Job.cpp8
-rw-r--r--clang/lib/Driver/ToolChain.cpp4
-rw-r--r--clang/lib/Driver/ToolChains/AIX.cpp6
-rw-r--r--clang/lib/Driver/ToolChains/AMDGPU.cpp18
-rw-r--r--clang/lib/Driver/ToolChains/Arch/AArch64.cpp4
-rw-r--r--clang/lib/Driver/ToolChains/Arch/ARM.cpp18
-rw-r--r--clang/lib/Driver/ToolChains/Arch/X86.cpp10
-rw-r--r--clang/lib/Driver/ToolChains/Clang.cpp86
-rw-r--r--clang/lib/Driver/ToolChains/CommonArgs.cpp16
-rw-r--r--clang/lib/Driver/ToolChains/Cuda.cpp2
-rw-r--r--clang/lib/Driver/ToolChains/Darwin.cpp31
-rw-r--r--clang/lib/Driver/ToolChains/Flang.cpp2
-rw-r--r--clang/lib/Driver/ToolChains/Gnu.cpp6
-rw-r--r--clang/lib/Driver/ToolChains/Hexagon.cpp8
-rw-r--r--clang/lib/Driver/ToolChains/Hurd.cpp4
-rw-r--r--clang/lib/Driver/ToolChains/MSP430.cpp2
-rw-r--r--clang/lib/Driver/ToolChains/MSVC.cpp2
-rw-r--r--clang/lib/Driver/ToolChains/MinGW.cpp6
-rw-r--r--clang/lib/Driver/ToolChains/PPCLinux.cpp4
-rw-r--r--clang/lib/Driver/ToolChains/Solaris.cpp2
-rw-r--r--clang/lib/Driver/ToolChains/WebAssembly.cpp4
-rw-r--r--clang/lib/Edit/Commit.cpp2
-rw-r--r--clang/lib/Edit/RewriteObjCFoundationAPI.cpp6
-rw-r--r--clang/lib/ExtractAPI/ExtractAPIConsumer.cpp4
-rw-r--r--clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp2
-rw-r--r--clang/lib/Format/BreakableToken.cpp44
-rw-r--r--clang/lib/Format/ContinuationIndenter.cpp33
-rw-r--r--clang/lib/Format/Format.cpp26
-rw-r--r--clang/lib/Format/FormatToken.h10
-rw-r--r--clang/lib/Format/FormatTokenLexer.cpp8
-rw-r--r--clang/lib/Format/SortJavaScriptImports.cpp4
-rw-r--r--clang/lib/Format/TokenAnnotator.cpp20
-rw-r--r--clang/lib/Format/UnwrappedLineParser.cpp10
-rw-r--r--clang/lib/Frontend/CompilerInvocation.cpp16
-rw-r--r--clang/lib/Frontend/DependencyGraph.cpp2
-rw-r--r--clang/lib/Frontend/Rewrite/InclusionRewriter.cpp2
-rw-r--r--clang/lib/Frontend/VerifyDiagnosticConsumer.cpp21
-rw-r--r--clang/lib/Index/IndexSymbol.cpp2
-rw-r--r--clang/lib/IndexSerialization/SerializablePathCollection.cpp4
-rw-r--r--clang/lib/Lex/HeaderSearch.cpp10
-rw-r--r--clang/lib/Lex/InitHeaderSearch.cpp4
-rw-r--r--clang/lib/Lex/Lexer.cpp4
-rw-r--r--clang/lib/Lex/ModuleMap.cpp12
-rw-r--r--clang/lib/Lex/PPDirectives.cpp12
-rw-r--r--clang/lib/Lex/PPExpressions.cpp2
-rw-r--r--clang/lib/Lex/PPMacroExpansion.cpp11
-rw-r--r--clang/lib/Parse/ParseDecl.cpp4
-rw-r--r--clang/lib/Parse/Parser.cpp2
-rw-r--r--clang/lib/Rewrite/Rewriter.cpp4
-rw-r--r--clang/lib/Sema/CodeCompleteConsumer.cpp11
-rw-r--r--clang/lib/Sema/SemaChecking.cpp11
-rw-r--r--clang/lib/Sema/SemaCodeComplete.cpp4
-rw-r--r--clang/lib/Sema/SemaDecl.cpp4
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp16
-rw-r--r--clang/lib/Sema/SemaDeclObjC.cpp2
-rw-r--r--clang/lib/Sema/SemaExpr.cpp14
-rw-r--r--clang/lib/Sema/SemaModule.cpp2
-rw-r--r--clang/lib/Sema/SemaType.cpp2
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp4
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp4
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp2
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp2
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp6
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp10
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp4
-rw-r--r--clang/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp2
-rw-r--r--clang/lib/StaticAnalyzer/Core/BugReporter.cpp20
-rw-r--r--clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp2
-rw-r--r--clang/lib/StaticAnalyzer/Core/CallEvent.cpp6
-rw-r--r--clang/lib/StaticAnalyzer/Core/CheckerContext.cpp5
-rw-r--r--clang/lib/StaticAnalyzer/Core/CheckerRegistryData.cpp6
-rw-r--r--clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp2
-rw-r--r--clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp4
-rw-r--r--clang/lib/Support/RISCVVIntrinsicUtils.cpp2
-rw-r--r--clang/lib/Tooling/ASTDiff/ASTDiff.cpp2
-rw-r--r--clang/lib/Tooling/ArgumentsAdjusters.cpp14
-rw-r--r--clang/lib/Tooling/CompilationDatabase.cpp2
-rw-r--r--clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp4
-rw-r--r--clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp4
-rw-r--r--clang/lib/Tooling/Inclusions/HeaderAnalysis.cpp6
-rw-r--r--clang/lib/Tooling/Inclusions/HeaderIncludes.cpp18
-rw-r--r--clang/lib/Tooling/Refactoring/AtomicChange.cpp2
-rw-r--r--clang/lib/Tooling/Refactoring/Lookup.cpp14
-rw-r--r--clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp8
-rw-r--r--clang/lib/Tooling/Tooling.cpp8
-rw-r--r--clang/lib/Tooling/Transformer/SourceCode.cpp2
-rw-r--r--clang/tools/arcmt-test/arcmt-test.cpp2
-rw-r--r--clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp2
-rw-r--r--clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp4
-rw-r--r--clang/tools/clang-refactor/ClangRefactor.cpp2
-rw-r--r--clang/tools/clang-repl/ClangRepl.cpp2
-rw-r--r--clang/tools/clang-scan-deps/ClangScanDeps.cpp4
-rw-r--r--clang/tools/diagtool/TreeView.cpp2
-rw-r--r--clang/tools/driver/driver.cpp4
-rw-r--r--clang/tools/libclang/CIndexUSRs.cpp2
-rw-r--r--clang/unittests/Analysis/CloneDetectionTest.cpp2
-rw-r--r--clang/unittests/Driver/ModuleCacheTest.cpp2
-rw-r--r--clang/unittests/Driver/MultilibBuilderTest.cpp4
-rw-r--r--clang/unittests/Driver/ToolChainTest.cpp2
-rw-r--r--clang/unittests/Frontend/OutputStreamTest.cpp2
-rw-r--r--clang/unittests/Interpreter/IncrementalProcessingTest.cpp2
-rw-r--r--clang/unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp4
-rw-r--r--clang/unittests/Tooling/HeaderIncludesTest.cpp11
-rw-r--r--clang/unittests/libclang/LibclangTest.cpp6
-rw-r--r--clang/utils/TableGen/ASTTableGen.cpp2
-rw-r--r--clang/utils/TableGen/MveEmitter.cpp8
155 files changed, 547 insertions, 541 deletions
diff --git a/clang/include/clang/Basic/Attr.td b/clang/include/clang/Basic/Attr.td
index 0d94ea2..c8b17cb 100644
--- a/clang/include/clang/Basic/Attr.td
+++ b/clang/include/clang/Basic/Attr.td
@@ -2878,7 +2878,7 @@ def Target : InheritableAttr {
for (auto &Feature : AttrFeatures) {
Feature = Feature.trim();
- if (Feature.startswith("arch="))
+ if (Feature.starts_with("arch="))
return Feature.drop_front(sizeof("arch=") - 1);
}
return "";
@@ -2896,8 +2896,8 @@ def Target : InheritableAttr {
for (auto &Feature : AttrFeatures) {
Feature = Feature.trim();
- if (!Feature.startswith("no-") && !Feature.startswith("arch=") &&
- !Feature.startswith("fpmath=") && !Feature.startswith("tune="))
+ if (!Feature.starts_with("no-") && !Feature.starts_with("arch=") &&
+ !Feature.starts_with("fpmath=") && !Feature.starts_with("tune="))
Out.push_back(Feature);
}
}
diff --git a/clang/include/clang/Basic/IdentifierTable.h b/clang/include/clang/Basic/IdentifierTable.h
index 0898e7d..1ac182d 100644
--- a/clang/include/clang/Basic/IdentifierTable.h
+++ b/clang/include/clang/Basic/IdentifierTable.h
@@ -511,7 +511,7 @@ public:
/// function(<#int x#>);
/// \endcode
bool isEditorPlaceholder() const {
- return getName().startswith("<#") && getName().endswith("#>");
+ return getName().starts_with("<#") && getName().ends_with("#>");
}
/// Determine whether \p this is a name reserved for the implementation (C99
diff --git a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
index a947bd0..276d11e 100644
--- a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -409,8 +409,8 @@ AnalyzerOptions::getRegisteredCheckers(bool IncludeExperimental) {
};
std::vector<StringRef> Checkers;
for (StringRef CheckerName : StaticAnalyzerCheckerNames) {
- if (!CheckerName.startswith("debug.") &&
- (IncludeExperimental || !CheckerName.startswith("alpha.")))
+ if (!CheckerName.starts_with("debug.") &&
+ (IncludeExperimental || !CheckerName.starts_with("alpha.")))
Checkers.push_back(CheckerName);
}
return Checkers;
diff --git a/clang/lib/APINotes/APINotesManager.cpp b/clang/lib/APINotes/APINotesManager.cpp
index ec1fb3f..a921c8b 100644
--- a/clang/lib/APINotes/APINotesManager.cpp
+++ b/clang/lib/APINotes/APINotesManager.cpp
@@ -198,7 +198,7 @@ static void checkPrivateAPINotesName(DiagnosticsEngine &Diags,
StringRef RealFileName =
llvm::sys::path::filename(File->tryGetRealPathName());
StringRef RealStem = llvm::sys::path::stem(RealFileName);
- if (RealStem.endswith("_private"))
+ if (RealStem.ends_with("_private"))
return;
unsigned DiagID = diag::warn_apinotes_private_case;
diff --git a/clang/lib/APINotes/APINotesYAMLCompiler.cpp b/clang/lib/APINotes/APINotesYAMLCompiler.cpp
index 4dfd01d..57d6da7 100644
--- a/clang/lib/APINotes/APINotesYAMLCompiler.cpp
+++ b/clang/lib/APINotes/APINotesYAMLCompiler.cpp
@@ -745,7 +745,7 @@ public:
convertCommonEntity(M, MI, M.Selector);
// Check if the selector ends with ':' to determine if it takes arguments.
- bool takesArguments = M.Selector.endswith(":");
+ bool takesArguments = M.Selector.ends_with(":");
// Split the selector into pieces.
llvm::SmallVector<StringRef, 4> Args;
diff --git a/clang/lib/ARCMigrate/ARCMT.cpp b/clang/lib/ARCMigrate/ARCMT.cpp
index 8e39897..b410d5f 100644
--- a/clang/lib/ARCMigrate/ARCMT.cpp
+++ b/clang/lib/ARCMigrate/ARCMT.cpp
@@ -201,7 +201,7 @@ createInvocationForMigration(CompilerInvocation &origCI,
for (std::vector<std::string>::iterator
I = CInvok->getDiagnosticOpts().Warnings.begin(),
E = CInvok->getDiagnosticOpts().Warnings.end(); I != E; ++I) {
- if (!StringRef(*I).startswith("error"))
+ if (!StringRef(*I).starts_with("error"))
WarnOpts.push_back(*I);
}
WarnOpts.push_back("error=arc-unsafe-retained-assign");
diff --git a/clang/lib/ARCMigrate/ObjCMT.cpp b/clang/lib/ARCMigrate/ObjCMT.cpp
index 5a25c88..ed363a4 100644
--- a/clang/lib/ARCMigrate/ObjCMT.cpp
+++ b/clang/lib/ARCMigrate/ObjCMT.cpp
@@ -562,7 +562,7 @@ static void rewriteToObjCProperty(const ObjCMethodDecl *Getter,
static bool IsCategoryNameWithDeprecatedSuffix(ObjCContainerDecl *D) {
if (ObjCCategoryDecl *CatDecl = dyn_cast<ObjCCategoryDecl>(D)) {
StringRef Name = CatDecl->getName();
- return Name.endswith("Deprecated");
+ return Name.ends_with("Deprecated");
}
return false;
}
@@ -1176,12 +1176,12 @@ bool ObjCMigrateASTConsumer::migrateProperty(ASTContext &Ctx,
if (!SetterMethod) {
// try a different naming convention for getter: isXxxxx
StringRef getterNameString = getterName->getName();
- bool IsPrefix = getterNameString.startswith("is");
+ bool IsPrefix = getterNameString.starts_with("is");
// Note that we don't want to change an isXXX method of retainable object
// type to property (readonly or otherwise).
if (IsPrefix && GRT->isObjCRetainableType())
return false;
- if (IsPrefix || getterNameString.startswith("get")) {
+ if (IsPrefix || getterNameString.starts_with("get")) {
LengthOfPrefix = (IsPrefix ? 2 : 3);
const char *CGetterName = getterNameString.data() + LengthOfPrefix;
// Make sure that first character after "is" or "get" prefix can
@@ -1320,11 +1320,11 @@ void ObjCMigrateASTConsumer::migrateFactoryMethod(ASTContext &Ctx,
if (OIT_Family == OIT_Singleton || OIT_Family == OIT_ReturnsSelf) {
StringRef STRefMethodName(MethodName);
size_t len = 0;
- if (STRefMethodName.startswith("standard"))
+ if (STRefMethodName.starts_with("standard"))
len = strlen("standard");
- else if (STRefMethodName.startswith("shared"))
+ else if (STRefMethodName.starts_with("shared"))
len = strlen("shared");
- else if (STRefMethodName.startswith("default"))
+ else if (STRefMethodName.starts_with("default"))
len = strlen("default");
else
return;
@@ -1341,7 +1341,7 @@ void ObjCMigrateASTConsumer::migrateFactoryMethod(ASTContext &Ctx,
StringRef LoweredMethodName(MethodName);
std::string StringLoweredMethodName = LoweredMethodName.lower();
LoweredMethodName = StringLoweredMethodName;
- if (!LoweredMethodName.startswith(ClassNamePostfix))
+ if (!LoweredMethodName.starts_with(ClassNamePostfix))
return;
if (OIT_Family == OIT_ReturnsSelf)
ReplaceWithClasstype(*this, OM);
diff --git a/clang/lib/ARCMigrate/TransUnbridgedCasts.cpp b/clang/lib/ARCMigrate/TransUnbridgedCasts.cpp
index 40220a2e..1e6354f 100644
--- a/clang/lib/ARCMigrate/TransUnbridgedCasts.cpp
+++ b/clang/lib/ARCMigrate/TransUnbridgedCasts.cpp
@@ -146,7 +146,7 @@ private:
ento::cocoa::isRefType(E->getSubExpr()->getType(), "CF",
FD->getIdentifier()->getName())) {
StringRef fname = FD->getIdentifier()->getName();
- if (fname.endswith("Retain") || fname.contains("Create") ||
+ if (fname.ends_with("Retain") || fname.contains("Create") ||
fname.contains("Copy")) {
// Do not migrate to couple of bridge transfer casts which
// cancel each other out. Leave it unchanged so error gets user
diff --git a/clang/lib/ARCMigrate/TransformActions.cpp b/clang/lib/ARCMigrate/TransformActions.cpp
index bd5c793..6bc6fed 100644
--- a/clang/lib/ARCMigrate/TransformActions.cpp
+++ b/clang/lib/ARCMigrate/TransformActions.cpp
@@ -431,7 +431,7 @@ bool TransformActionsImpl::canReplaceText(SourceLocation loc, StringRef text) {
if (invalidTemp)
return false;
- return file.substr(locInfo.second).startswith(text);
+ return file.substr(locInfo.second).starts_with(text);
}
void TransformActionsImpl::commitInsert(SourceLocation loc, StringRef text) {
diff --git a/clang/lib/ARCMigrate/Transforms.cpp b/clang/lib/ARCMigrate/Transforms.cpp
index 90b2b32b..2808e35 100644
--- a/clang/lib/ARCMigrate/Transforms.cpp
+++ b/clang/lib/ARCMigrate/Transforms.cpp
@@ -95,7 +95,7 @@ bool trans::isPlusOne(const Expr *E) {
ento::cocoa::isRefType(callE->getType(), "CF",
FD->getIdentifier()->getName())) {
StringRef fname = FD->getIdentifier()->getName();
- if (fname.endswith("Retain") || fname.contains("Create") ||
+ if (fname.ends_with("Retain") || fname.contains("Create") ||
fname.contains("Copy"))
return true;
}
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index e877f90..0395b3e 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -8223,7 +8223,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string &S,
// Another legacy compatibility encoding. Some ObjC qualifier and type
// combinations need to be rearranged.
// Rewrite "in const" from "nr" to "rn"
- if (StringRef(S).endswith("nr"))
+ if (StringRef(S).ends_with("nr"))
S.replace(S.end()-2, S.end(), "rn");
}
@@ -13519,7 +13519,7 @@ void ASTContext::getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap,
Target->getTargetOpts().FeaturesAsWritten.begin(),
Target->getTargetOpts().FeaturesAsWritten.end());
} else {
- if (VersionStr.startswith("arch="))
+ if (VersionStr.starts_with("arch="))
TargetCPU = VersionStr.drop_front(sizeof("arch=") - 1);
else if (VersionStr != "default")
Features.push_back((StringRef{"+"} + VersionStr).str());
diff --git a/clang/lib/AST/DeclPrinter.cpp b/clang/lib/AST/DeclPrinter.cpp
index 30a26d5..24da6f2 100644
--- a/clang/lib/AST/DeclPrinter.cpp
+++ b/clang/lib/AST/DeclPrinter.cpp
@@ -1728,7 +1728,7 @@ void DeclPrinter::VisitObjCPropertyDecl(ObjCPropertyDecl *PDecl) {
std::string TypeStr = PDecl->getASTContext().getUnqualifiedObjCPointerType(T).
getAsString(Policy);
Out << ' ' << TypeStr;
- if (!StringRef(TypeStr).endswith("*"))
+ if (!StringRef(TypeStr).ends_with("*"))
Out << ' ';
Out << *PDecl;
if (Policy.PolishForDeclaration)
diff --git a/clang/lib/AST/Mangle.cpp b/clang/lib/AST/Mangle.cpp
index 64c9719..d3a6b61 100644
--- a/clang/lib/AST/Mangle.cpp
+++ b/clang/lib/AST/Mangle.cpp
@@ -147,7 +147,7 @@ void MangleContext::mangleName(GlobalDecl GD, raw_ostream &Out) {
// If the label isn't literal, or if this is an alias for an LLVM intrinsic,
// do not add a "\01" prefix.
- if (!ALA->getIsLiteralLabel() || ALA->getLabel().startswith("llvm.")) {
+ if (!ALA->getIsLiteralLabel() || ALA->getLabel().starts_with("llvm.")) {
Out << ALA->getLabel();
return;
}
diff --git a/clang/lib/AST/MicrosoftMangle.cpp b/clang/lib/AST/MicrosoftMangle.cpp
index c59a66e..8346ad8 100644
--- a/clang/lib/AST/MicrosoftMangle.cpp
+++ b/clang/lib/AST/MicrosoftMangle.cpp
@@ -63,7 +63,7 @@ struct msvc_hashing_ostream : public llvm::raw_svector_ostream {
: llvm::raw_svector_ostream(Buffer), OS(OS) {}
~msvc_hashing_ostream() override {
StringRef MangledName = str();
- bool StartsWithEscape = MangledName.startswith("\01");
+ bool StartsWithEscape = MangledName.starts_with("\01");
if (StartsWithEscape)
MangledName = MangledName.drop_front(1);
if (MangledName.size() < 4096) {
diff --git a/clang/lib/AST/PrintfFormatString.cpp b/clang/lib/AST/PrintfFormatString.cpp
index f0b9d0e..3b09ca4 100644
--- a/clang/lib/AST/PrintfFormatString.cpp
+++ b/clang/lib/AST/PrintfFormatString.cpp
@@ -140,7 +140,7 @@ static PrintfSpecifierResult ParsePrintfSpecifier(FormatStringHandler &H,
// Set the privacy flag if the privacy annotation in the
// comma-delimited segment is at least as strict as the privacy
// annotations in previous comma-delimited segments.
- if (MatchedStr.startswith("mask")) {
+ if (MatchedStr.starts_with("mask")) {
StringRef MaskType = MatchedStr.substr(sizeof("mask.") - 1);
unsigned Size = MaskType.size();
if (Warn && (Size == 0 || Size > 8))
diff --git a/clang/lib/AST/RawCommentList.cpp b/clang/lib/AST/RawCommentList.cpp
index c3beb23..dffa007 100644
--- a/clang/lib/AST/RawCommentList.cpp
+++ b/clang/lib/AST/RawCommentList.cpp
@@ -141,8 +141,8 @@ RawComment::RawComment(const SourceManager &SourceMgr, SourceRange SR,
Kind = K.first;
IsTrailingComment |= K.second;
- IsAlmostTrailingComment = RawText.startswith("//<") ||
- RawText.startswith("/*<");
+ IsAlmostTrailingComment =
+ RawText.starts_with("//<") || RawText.starts_with("/*<");
} else {
Kind = RCK_Merged;
IsTrailingComment =
diff --git a/clang/lib/AST/Stmt.cpp b/clang/lib/AST/Stmt.cpp
index c31fb48..afd0588 100644
--- a/clang/lib/AST/Stmt.cpp
+++ b/clang/lib/AST/Stmt.cpp
@@ -811,11 +811,12 @@ std::string MSAsmStmt::generateAsmString(const ASTContext &C) const {
StringRef Instruction = Pieces[I];
// For vex/vex2/vex3/evex masm style prefix, convert it to att style
// since we don't support masm style prefix in backend.
- if (Instruction.startswith("vex "))
+ if (Instruction.starts_with("vex "))
MSAsmString += '{' + Instruction.substr(0, 3).str() + '}' +
Instruction.substr(3).str();
- else if (Instruction.startswith("vex2 ") ||
- Instruction.startswith("vex3 ") || Instruction.startswith("evex "))
+ else if (Instruction.starts_with("vex2 ") ||
+ Instruction.starts_with("vex3 ") ||
+ Instruction.starts_with("evex "))
MSAsmString += '{' + Instruction.substr(0, 4).str() + '}' +
Instruction.substr(4).str();
else
diff --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index 435bbde..8ed213c 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -480,11 +480,11 @@ HasNameMatcher::HasNameMatcher(std::vector<std::string> N)
static bool consumeNameSuffix(StringRef &FullName, StringRef Suffix) {
StringRef Name = FullName;
- if (!Name.endswith(Suffix))
+ if (!Name.ends_with(Suffix))
return false;
Name = Name.drop_back(Suffix.size());
if (!Name.empty()) {
- if (!Name.endswith("::"))
+ if (!Name.ends_with("::"))
return false;
Name = Name.drop_back(2);
}
@@ -530,7 +530,7 @@ public:
PatternSet(ArrayRef<std::string> Names) {
Patterns.reserve(Names.size());
for (StringRef Name : Names)
- Patterns.push_back({Name, Name.startswith("::")});
+ Patterns.push_back({Name, Name.starts_with("::")});
}
/// Consumes the name suffix from each pattern in the set and removes the ones
@@ -652,11 +652,11 @@ bool HasNameMatcher::matchesNodeFullSlow(const NamedDecl &Node) const {
const StringRef FullName = OS.str();
for (const StringRef Pattern : Names) {
- if (Pattern.startswith("::")) {
+ if (Pattern.starts_with("::")) {
if (FullName == Pattern)
return true;
- } else if (FullName.endswith(Pattern) &&
- FullName.drop_back(Pattern.size()).endswith("::")) {
+ } else if (FullName.ends_with(Pattern) &&
+ FullName.drop_back(Pattern.size()).ends_with("::")) {
return true;
}
}
diff --git a/clang/lib/ASTMatchers/Dynamic/Parser.cpp b/clang/lib/ASTMatchers/Dynamic/Parser.cpp
index 33a10fe..27096a8 100644
--- a/clang/lib/ASTMatchers/Dynamic/Parser.cpp
+++ b/clang/lib/ASTMatchers/Dynamic/Parser.cpp
@@ -187,10 +187,10 @@ private:
break;
++TokenLength;
}
- if (TokenLength == 4 && Code.startswith("true")) {
+ if (TokenLength == 4 && Code.starts_with("true")) {
Result.Kind = TokenInfo::TK_Literal;
Result.Value = true;
- } else if (TokenLength == 5 && Code.startswith("false")) {
+ } else if (TokenLength == 5 && Code.starts_with("false")) {
Result.Kind = TokenInfo::TK_Literal;
Result.Value = false;
} else {
@@ -737,7 +737,7 @@ bool Parser::parseMatcherExpressionImpl(const TokenInfo &NameToken,
// Completions minus the prefix.
void Parser::addCompletion(const TokenInfo &CompToken,
const MatcherCompletion& Completion) {
- if (StringRef(Completion.TypedText).startswith(CompToken.Text) &&
+ if (StringRef(Completion.TypedText).starts_with(CompToken.Text) &&
Completion.Specificity > 0) {
Completions.emplace_back(Completion.TypedText.substr(CompToken.Text.size()),
Completion.MatcherDecl, Completion.Specificity);
diff --git a/clang/lib/Analysis/BodyFarm.cpp b/clang/lib/Analysis/BodyFarm.cpp
index 13ec9b6..127e843 100644
--- a/clang/lib/Analysis/BodyFarm.cpp
+++ b/clang/lib/Analysis/BodyFarm.cpp
@@ -726,8 +726,8 @@ Stmt *BodyFarm::getBody(const FunctionDecl *D) {
FF = nullptr;
break;
}
- } else if (Name.startswith("OSAtomicCompareAndSwap") ||
- Name.startswith("objc_atomicCompareAndSwap")) {
+ } else if (Name.starts_with("OSAtomicCompareAndSwap") ||
+ Name.starts_with("objc_atomicCompareAndSwap")) {
FF = create_OSAtomicCompareAndSwap;
} else if (Name == "call_once" && D->getDeclContext()->isStdNamespace()) {
FF = create_call_once;
diff --git a/clang/lib/Analysis/CallGraph.cpp b/clang/lib/Analysis/CallGraph.cpp
index 59cc939..f892980 100644
--- a/clang/lib/Analysis/CallGraph.cpp
+++ b/clang/lib/Analysis/CallGraph.cpp
@@ -168,7 +168,7 @@ bool CallGraph::includeCalleeInGraph(const Decl *D) {
return false;
IdentifierInfo *II = FD->getIdentifier();
- if (II && II->getName().startswith("__inline"))
+ if (II && II->getName().starts_with("__inline"))
return false;
}
diff --git a/clang/lib/Analysis/CalledOnceCheck.cpp b/clang/lib/Analysis/CalledOnceCheck.cpp
index 5b4fc24..04c5f6a 100644
--- a/clang/lib/Analysis/CalledOnceCheck.cpp
+++ b/clang/lib/Analysis/CalledOnceCheck.cpp
@@ -973,7 +973,7 @@ private:
/// Return true if the given name has conventional suffixes.
static bool hasConventionalSuffix(llvm::StringRef Name) {
return llvm::any_of(CONVENTIONAL_SUFFIXES, [Name](llvm::StringRef Suffix) {
- return Name.endswith(Suffix);
+ return Name.ends_with(Suffix);
});
}
diff --git a/clang/lib/Analysis/CocoaConventions.cpp b/clang/lib/Analysis/CocoaConventions.cpp
index 571d72e..836859c 100644
--- a/clang/lib/Analysis/CocoaConventions.cpp
+++ b/clang/lib/Analysis/CocoaConventions.cpp
@@ -26,10 +26,10 @@ bool cocoa::isRefType(QualType RetTy, StringRef Prefix,
// Recursively walk the typedef stack, allowing typedefs of reference types.
while (const TypedefType *TD = RetTy->getAs<TypedefType>()) {
StringRef TDName = TD->getDecl()->getIdentifier()->getName();
- if (TDName.startswith(Prefix) && TDName.endswith("Ref"))
+ if (TDName.starts_with(Prefix) && TDName.ends_with("Ref"))
return true;
// XPC unfortunately uses CF-style function names, but aren't CF types.
- if (TDName.startswith("xpc_"))
+ if (TDName.starts_with("xpc_"))
return false;
RetTy = TD->getDecl()->getUnderlyingType();
}
@@ -43,7 +43,7 @@ bool cocoa::isRefType(QualType RetTy, StringRef Prefix,
return false;
// Does the name start with the prefix?
- return Name.startswith(Prefix);
+ return Name.starts_with(Prefix);
}
/// Returns true when the passed-in type is a CF-style reference-counted
@@ -127,10 +127,9 @@ bool coreFoundation::followsCreateRule(const FunctionDecl *fn) {
// Scan for *lowercase* 'reate' or 'opy', followed by no lowercase
// character.
StringRef suffix = functionName.substr(it - start);
- if (suffix.startswith("reate")) {
+ if (suffix.starts_with("reate")) {
it += 5;
- }
- else if (suffix.startswith("opy")) {
+ } else if (suffix.starts_with("opy")) {
it += 3;
} else {
// Keep scanning.
diff --git a/clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp b/clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp
index f49087a..5ac71e1 100644
--- a/clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp
+++ b/clang/lib/Analysis/FlowSensitive/Models/ChromiumCheckModel.cpp
@@ -43,7 +43,7 @@ bool isCheckLikeMethod(llvm::SmallDenseSet<const CXXMethodDecl *> &CheckDecls,
return false;
for (const CXXMethodDecl *M : ParentClass->methods())
- if (M->getDeclName().isIdentifier() && M->getName().endswith("Check"))
+ if (M->getDeclName().isIdentifier() && M->getName().ends_with("Check"))
CheckDecls.insert(M);
}
diff --git a/clang/lib/Analysis/RetainSummaryManager.cpp b/clang/lib/Analysis/RetainSummaryManager.cpp
index 4cbeb0c..6f50d95 100644
--- a/clang/lib/Analysis/RetainSummaryManager.cpp
+++ b/clang/lib/Analysis/RetainSummaryManager.cpp
@@ -174,7 +174,7 @@ static bool isOSObjectPtr(QualType QT) {
}
static bool isISLObjectRef(QualType Ty) {
- return StringRef(Ty.getAsString()).startswith("isl_");
+ return StringRef(Ty.getAsString()).starts_with("isl_");
}
static bool isOSIteratorSubclass(const Decl *D) {
@@ -255,13 +255,13 @@ RetainSummaryManager::getSummaryForOSObject(const FunctionDecl *FD,
// TODO: Add support for the slightly common *Matching(table) idiom.
// Cf. IOService::nameMatching() etc. - these function have an unusual
// contract of returning at +0 or +1 depending on their last argument.
- if (FName.endswith("Matching")) {
+ if (FName.ends_with("Matching")) {
return getPersistentStopSummary();
}
// All objects returned with functions *not* starting with 'get',
// or iterators, are returned at +1.
- if ((!FName.startswith("get") && !FName.startswith("Get")) ||
+ if ((!FName.starts_with("get") && !FName.starts_with("Get")) ||
isOSIteratorSubclass(PD)) {
return getOSSummaryCreateRule(FD);
} else {
@@ -392,9 +392,9 @@ const RetainSummary *RetainSummaryManager::getSummaryForObjCOrCFObject(
return getPersistentSummary(RetEffect::MakeNoRet(),
ScratchArgs,
ArgEffect(DoNothing), ArgEffect(DoNothing));
- } else if (FName.startswith("NSLog")) {
+ } else if (FName.starts_with("NSLog")) {
return getDoNothingSummary();
- } else if (FName.startswith("NS") && FName.contains("Insert")) {
+ } else if (FName.starts_with("NS") && FName.contains("Insert")) {
// Allowlist NSXXInsertXX, for example NSMapInsertIfAbsent, since they can
// be deallocated by NSMapRemove.
ScratchArgs = AF.add(ScratchArgs, 1, ArgEffect(StopTracking));
@@ -453,9 +453,9 @@ const RetainSummary *RetainSummaryManager::getSummaryForObjCOrCFObject(
// Check for release functions, the only kind of functions that we care
// about that don't return a pointer type.
- if (FName.startswith("CG") || FName.startswith("CF")) {
+ if (FName.starts_with("CG") || FName.starts_with("CF")) {
// Test for 'CGCF'.
- FName = FName.substr(FName.startswith("CGCF") ? 4 : 2);
+ FName = FName.substr(FName.starts_with("CGCF") ? 4 : 2);
if (isRelease(FD, FName))
return getUnarySummary(FT, DecRef);
diff --git a/clang/lib/Basic/Attributes.cpp b/clang/lib/Basic/Attributes.cpp
index bb49521..44a4f18 100644
--- a/clang/lib/Basic/Attributes.cpp
+++ b/clang/lib/Basic/Attributes.cpp
@@ -33,7 +33,7 @@ int clang::hasAttribute(AttributeCommonInfo::Syntax Syntax,
const TargetInfo &Target, const LangOptions &LangOpts) {
StringRef Name = Attr->getName();
// Normalize the attribute name, __foo__ becomes foo.
- if (Name.size() >= 4 && Name.startswith("__") && Name.endswith("__"))
+ if (Name.size() >= 4 && Name.starts_with("__") && Name.ends_with("__"))
Name = Name.substr(2, Name.size() - 4);
// Normalize the scope name, but only for gnu and clang attributes.
@@ -103,8 +103,8 @@ static StringRef normalizeAttrName(const IdentifierInfo *Name,
(NormalizedScopeName.empty() || NormalizedScopeName == "gnu" ||
NormalizedScopeName == "clang"));
StringRef AttrName = Name->getName();
- if (ShouldNormalize && AttrName.size() >= 4 && AttrName.startswith("__") &&
- AttrName.endswith("__"))
+ if (ShouldNormalize && AttrName.size() >= 4 && AttrName.starts_with("__") &&
+ AttrName.ends_with("__"))
AttrName = AttrName.slice(2, AttrName.size() - 2);
return AttrName;
diff --git a/clang/lib/Basic/DiagnosticIDs.cpp b/clang/lib/Basic/DiagnosticIDs.cpp
index e5667d5..6c7bd50 100644
--- a/clang/lib/Basic/DiagnosticIDs.cpp
+++ b/clang/lib/Basic/DiagnosticIDs.cpp
@@ -853,5 +853,5 @@ bool DiagnosticIDs::isUnrecoverable(unsigned DiagID) const {
bool DiagnosticIDs::isARCDiagnostic(unsigned DiagID) {
unsigned cat = getCategoryNumberForDiag(DiagID);
- return DiagnosticIDs::getCategoryNameFromID(cat).startswith("ARC ");
+ return DiagnosticIDs::getCategoryNameFromID(cat).starts_with("ARC ");
}
diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp
index 38150d1..5902c6d 100644
--- a/clang/lib/Basic/IdentifierTable.cpp
+++ b/clang/lib/Basic/IdentifierTable.cpp
@@ -604,7 +604,7 @@ LLVM_DUMP_METHOD void Selector::dump() const { print(llvm::errs()); }
static bool startsWithWord(StringRef name, StringRef word) {
if (name.size() < word.size()) return false;
return ((name.size() == word.size() || !isLowercase(name[word.size()])) &&
- name.startswith(word));
+ name.starts_with(word));
}
ObjCMethodFamily Selector::getMethodFamilyImpl(Selector sel) {
@@ -742,7 +742,7 @@ SelectorTable::constructSetterSelector(IdentifierTable &Idents,
std::string SelectorTable::getPropertyNameFromSetterSelector(Selector Sel) {
StringRef Name = Sel.getNameForSlot(0);
- assert(Name.startswith("set") && "invalid setter name");
+ assert(Name.starts_with("set") && "invalid setter name");
return (Twine(toLowercase(Name[3])) + Name.drop_front(4)).str();
}
diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp
index 7523e50..9252174 100644
--- a/clang/lib/Basic/Module.cpp
+++ b/clang/lib/Basic/Module.cpp
@@ -166,7 +166,8 @@ bool Module::isForBuilding(const LangOptions &LangOpts) const {
// for either.
if (!LangOpts.isCompilingModule() && getTopLevelModule()->IsFramework &&
CurrentModule == LangOpts.ModuleName &&
- !CurrentModule.endswith("_Private") && TopLevelName.endswith("_Private"))
+ !CurrentModule.ends_with("_Private") &&
+ TopLevelName.ends_with("_Private"))
TopLevelName = TopLevelName.drop_back(8);
return TopLevelName == CurrentModule;
diff --git a/clang/lib/Basic/Sarif.cpp b/clang/lib/Basic/Sarif.cpp
index 3476103..1cae7b9 100644
--- a/clang/lib/Basic/Sarif.cpp
+++ b/clang/lib/Basic/Sarif.cpp
@@ -74,7 +74,7 @@ static std::string fileNameToURI(StringRef Filename) {
// Get the root name to see if it has a URI authority.
StringRef Root = sys::path::root_name(Filename);
- if (Root.startswith("//")) {
+ if (Root.starts_with("//")) {
// There is an authority, so add it to the URI.
Ret += Root.drop_front(2).str();
} else if (!Root.empty()) {
diff --git a/clang/lib/Basic/TargetInfo.cpp b/clang/lib/Basic/TargetInfo.cpp
index 6cd5d61..96b3ad9 100644
--- a/clang/lib/Basic/TargetInfo.cpp
+++ b/clang/lib/Basic/TargetInfo.cpp
@@ -551,26 +551,26 @@ ParsedTargetAttr TargetInfo::parseTargetAttr(StringRef Features) const {
// TODO: Support the fpmath option. It will require checking
// overall feature validity for the function with the rest of the
// attributes on the function.
- if (Feature.startswith("fpmath="))
+ if (Feature.starts_with("fpmath="))
continue;
- if (Feature.startswith("branch-protection=")) {
+ if (Feature.starts_with("branch-protection=")) {
Ret.BranchProtection = Feature.split('=').second.trim();
continue;
}
// While we're here iterating check for a different target cpu.
- if (Feature.startswith("arch=")) {
+ if (Feature.starts_with("arch=")) {
if (!Ret.CPU.empty())
Ret.Duplicate = "arch=";
else
Ret.CPU = Feature.split("=").second.trim();
- } else if (Feature.startswith("tune=")) {
+ } else if (Feature.starts_with("tune=")) {
if (!Ret.Tune.empty())
Ret.Duplicate = "tune=";
else
Ret.Tune = Feature.split("=").second.trim();
- } else if (Feature.startswith("no-"))
+ } else if (Feature.starts_with("no-"))
Ret.Features.push_back("-" + Feature.split("-").second.str());
else
Ret.Features.push_back("+" + Feature.str());
diff --git a/clang/lib/Basic/Targets/AArch64.cpp b/clang/lib/Basic/Targets/AArch64.cpp
index e3e08b5..def16c0 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -1062,7 +1062,7 @@ ParsedTargetAttr AArch64TargetInfo::parseTargetAttr(StringRef Features) const {
else
// Pushing the original feature string to give a sema error later on
// when they get checked.
- if (Feature.startswith("no"))
+ if (Feature.starts_with("no"))
Features.push_back("-" + Feature.drop_front(2).str());
else
Features.push_back("+" + Feature.str());
@@ -1071,15 +1071,15 @@ ParsedTargetAttr AArch64TargetInfo::parseTargetAttr(StringRef Features) const {
for (auto &Feature : AttrFeatures) {
Feature = Feature.trim();
- if (Feature.startswith("fpmath="))
+ if (Feature.starts_with("fpmath="))
continue;
- if (Feature.startswith("branch-protection=")) {
+ if (Feature.starts_with("branch-protection=")) {
Ret.BranchProtection = Feature.split('=').second.trim();
continue;
}
- if (Feature.startswith("arch=")) {
+ if (Feature.starts_with("arch=")) {
if (FoundArch)
Ret.Duplicate = "arch=";
FoundArch = true;
@@ -1095,7 +1095,7 @@ ParsedTargetAttr AArch64TargetInfo::parseTargetAttr(StringRef Features) const {
Ret.Features.push_back(AI->ArchFeature.str());
// Add any extra features, after the +
SplitAndAddFeatures(Split.second, Ret.Features);
- } else if (Feature.startswith("cpu=")) {
+ } else if (Feature.starts_with("cpu=")) {
if (!Ret.CPU.empty())
Ret.Duplicate = "cpu=";
else {
@@ -1106,14 +1106,14 @@ ParsedTargetAttr AArch64TargetInfo::parseTargetAttr(StringRef Features) const {
Ret.CPU = Split.first;
SplitAndAddFeatures(Split.second, Ret.Features);
}
- } else if (Feature.startswith("tune=")) {
+ } else if (Feature.starts_with("tune=")) {
if (!Ret.Tune.empty())
Ret.Duplicate = "tune=";
else
Ret.Tune = Feature.split("=").second.trim();
- } else if (Feature.startswith("+")) {
+ } else if (Feature.starts_with("+")) {
SplitAndAddFeatures(Feature, Ret.Features);
- } else if (Feature.startswith("no-")) {
+ } else if (Feature.starts_with("no-")) {
StringRef FeatureName =
llvm::AArch64::getArchExtFeature(Feature.split("-").second);
if (!FeatureName.empty())
diff --git a/clang/lib/Basic/Targets/AMDGPU.cpp b/clang/lib/Basic/Targets/AMDGPU.cpp
index 719fc51..b064ec2 100644
--- a/clang/lib/Basic/Targets/AMDGPU.cpp
+++ b/clang/lib/Basic/Targets/AMDGPU.cpp
@@ -279,7 +279,7 @@ void AMDGPUTargetInfo::getTargetDefines(const LangOptions &Opts,
Builder.defineMacro(Twine("__") + Twine(CanonName) + Twine("__"));
// Emit macros for gfx family e.g. gfx906 -> __GFX9__, gfx1030 -> __GFX10___
if (isAMDGCN(getTriple())) {
- assert(CanonName.startswith("gfx") && "Invalid amdgcn canonical name");
+ assert(CanonName.starts_with("gfx") && "Invalid amdgcn canonical name");
Builder.defineMacro(Twine("__") + Twine(CanonName.drop_back(2).upper()) +
Twine("__"));
}
diff --git a/clang/lib/Basic/Targets/Mips.cpp b/clang/lib/Basic/Targets/Mips.cpp
index bc90d1b..3a65f53 100644
--- a/clang/lib/Basic/Targets/Mips.cpp
+++ b/clang/lib/Basic/Targets/Mips.cpp
@@ -196,7 +196,7 @@ void MipsTargetInfo::getTargetDefines(const LangOptions &Opts,
else
Builder.defineMacro("_MIPS_ARCH_" + StringRef(CPU).upper());
- if (StringRef(CPU).startswith("octeon"))
+ if (StringRef(CPU).starts_with("octeon"))
Builder.defineMacro("__OCTEON__");
if (CPU != "mips1") {
diff --git a/clang/lib/Basic/Targets/NVPTX.cpp b/clang/lib/Basic/Targets/NVPTX.cpp
index 5c60181..c0b5db7 100644
--- a/clang/lib/Basic/Targets/NVPTX.cpp
+++ b/clang/lib/Basic/Targets/NVPTX.cpp
@@ -42,7 +42,7 @@ NVPTXTargetInfo::NVPTXTargetInfo(const llvm::Triple &Triple,
PTXVersion = 32;
for (const StringRef Feature : Opts.FeaturesAsWritten) {
int PTXV;
- if (!Feature.startswith("+ptx") ||
+ if (!Feature.starts_with("+ptx") ||
Feature.drop_front(4).getAsInteger(10, PTXV))
continue;
PTXVersion = PTXV; // TODO: should it be max(PTXVersion, PTXV)?
diff --git a/clang/lib/Basic/Targets/RISCV.cpp b/clang/lib/Basic/Targets/RISCV.cpp
index 45d2302..60a4e0e 100644
--- a/clang/lib/Basic/Targets/RISCV.cpp
+++ b/clang/lib/Basic/Targets/RISCV.cpp
@@ -434,14 +434,14 @@ ParsedTargetAttr RISCVTargetInfo::parseTargetAttr(StringRef Features) const {
Feature = Feature.trim();
StringRef AttrString = Feature.split("=").second.trim();
- if (Feature.startswith("arch=")) {
+ if (Feature.starts_with("arch=")) {
// Override last features
Ret.Features.clear();
if (FoundArch)
Ret.Duplicate = "arch=";
FoundArch = true;
- if (AttrString.startswith("+")) {
+ if (AttrString.starts_with("+")) {
// EXTENSION like arch=+v,+zbb
SmallVector<StringRef, 1> Exts;
AttrString.split(Exts, ",");
@@ -461,7 +461,7 @@ ParsedTargetAttr RISCVTargetInfo::parseTargetAttr(StringRef Features) const {
// full-arch-string like arch=rv64gcv
handleFullArchString(AttrString, Ret.Features);
}
- } else if (Feature.startswith("cpu=")) {
+ } else if (Feature.starts_with("cpu=")) {
if (!Ret.CPU.empty())
Ret.Duplicate = "cpu=";
@@ -475,7 +475,7 @@ ParsedTargetAttr RISCVTargetInfo::parseTargetAttr(StringRef Features) const {
handleFullArchString(MarchFromCPU, Ret.Features);
}
}
- } else if (Feature.startswith("tune=")) {
+ } else if (Feature.starts_with("tune=")) {
if (!Ret.Tune.empty())
Ret.Duplicate = "tune=";
diff --git a/clang/lib/Basic/Warnings.cpp b/clang/lib/Basic/Warnings.cpp
index cc8c138..cb23d84 100644
--- a/clang/lib/Basic/Warnings.cpp
+++ b/clang/lib/Basic/Warnings.cpp
@@ -97,7 +97,7 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags,
// Check to see if this warning starts with "no-", if so, this is a
// negative form of the option.
bool isPositive = true;
- if (Opt.startswith("no-")) {
+ if (Opt.starts_with("no-")) {
isPositive = false;
Opt = Opt.substr(3);
}
@@ -133,7 +133,7 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags,
// table. It also has the "specifier" form of -Werror=foo. GCC supports
// the deprecated -Werror-implicit-function-declaration which is used by
// a few projects.
- if (Opt.startswith("error")) {
+ if (Opt.starts_with("error")) {
StringRef Specifier;
if (Opt.size() > 5) { // Specifier must be present.
if (Opt[5] != '=' &&
@@ -162,7 +162,7 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags,
}
// -Wfatal-errors is yet another special case.
- if (Opt.startswith("fatal-errors")) {
+ if (Opt.starts_with("fatal-errors")) {
StringRef Specifier;
if (Opt.size() != 12) {
if ((Opt[12] != '=' && Opt[12] != '-') || Opt.size() == 13) {
@@ -204,7 +204,7 @@ void clang::ProcessWarningOptions(DiagnosticsEngine &Diags,
// Check to see if this warning starts with "no-", if so, this is a
// negative form of the option.
- bool IsPositive = !Opt.startswith("no-");
+ bool IsPositive = !Opt.starts_with("no-");
if (!IsPositive) Opt = Opt.substr(3);
auto Severity = IsPositive ? diag::Severity::Remark
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp
index a24aeea..51a43b5 100644
--- a/clang/lib/CodeGen/CGCall.cpp
+++ b/clang/lib/CodeGen/CGCall.cpp
@@ -5609,7 +5609,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
EmitBlock(Cont);
}
if (CI->getCalledFunction() && CI->getCalledFunction()->hasName() &&
- CI->getCalledFunction()->getName().startswith("_Z4sqrt")) {
+ CI->getCalledFunction()->getName().starts_with("_Z4sqrt")) {
SetSqrtFPAccuracy(CI);
}
if (callOrInvoke)
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 37d7a67..236d53b 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -637,7 +637,8 @@ void CGDebugInfo::CreateCompileUnit() {
Sysroot = CGM.getHeaderSearchOpts().Sysroot;
auto B = llvm::sys::path::rbegin(Sysroot);
auto E = llvm::sys::path::rend(Sysroot);
- auto It = std::find_if(B, E, [](auto SDK) { return SDK.endswith(".sdk"); });
+ auto It =
+ std::find_if(B, E, [](auto SDK) { return SDK.ends_with(".sdk"); });
if (It != E)
SDK = *It;
}
@@ -2885,7 +2886,7 @@ llvm::DIModule *CGDebugInfo::getOrCreateModuleRef(ASTSourceDescriptor Mod,
// clang::Module object, but it won't actually be built or imported; it will
// be textual.
if (CreateSkeletonCU && IsRootModule && Mod.getASTFile().empty() && M)
- assert(StringRef(M->Name).startswith(CGM.getLangOpts().ModuleName) &&
+ assert(StringRef(M->Name).starts_with(CGM.getLangOpts().ModuleName) &&
"clang module without ASTFile must be specified by -fmodule-name");
// Return a StringRef to the remapped Path.
@@ -4249,7 +4250,7 @@ void CGDebugInfo::emitFunctionStart(GlobalDecl GD, SourceLocation Loc,
Flags |= llvm::DINode::FlagPrototyped;
}
- if (Name.startswith("\01"))
+ if (Name.starts_with("\01"))
Name = Name.substr(1);
assert((!D || !isa<VarDecl>(D) ||
diff --git a/clang/lib/CodeGen/CGException.cpp b/clang/lib/CodeGen/CGException.cpp
index bae8bab..0d507da 100644
--- a/clang/lib/CodeGen/CGException.cpp
+++ b/clang/lib/CodeGen/CGException.cpp
@@ -277,7 +277,7 @@ static bool LandingPadHasOnlyCXXUses(llvm::LandingPadInst *LPI) {
if (llvm::GlobalVariable *GV = dyn_cast<llvm::GlobalVariable>(Val))
// ObjC EH selector entries are always global variables with
// names starting like this.
- if (GV->getName().startswith("OBJC_EHTYPE"))
+ if (GV->getName().starts_with("OBJC_EHTYPE"))
return false;
} else {
// Check if any of the filter values have the ObjC prefix.
@@ -288,7 +288,7 @@ static bool LandingPadHasOnlyCXXUses(llvm::LandingPadInst *LPI) {
cast<llvm::GlobalVariable>((*II)->stripPointerCasts()))
// ObjC EH selector entries are always global variables with
// names starting like this.
- if (GV->getName().startswith("OBJC_EHTYPE"))
+ if (GV->getName().starts_with("OBJC_EHTYPE"))
return false;
}
}
@@ -1917,7 +1917,7 @@ void CodeGenFunction::EmitCapturedLocals(CodeGenFunction &ParentCGF,
const VarDecl *D = cast<VarDecl>(I.first);
if (isa<ImplicitParamDecl>(D) &&
D->getType() == getContext().VoidPtrTy) {
- assert(D->getName().startswith("frame_pointer"));
+ assert(D->getName().starts_with("frame_pointer"));
FramePtrAddrAlloca = cast<llvm::AllocaInst>(I.second.getPointer());
break;
}
diff --git a/clang/lib/CodeGen/CGExpr.cpp b/clang/lib/CodeGen/CGExpr.cpp
index 69cf7f76..ed9aaa2 100644
--- a/clang/lib/CodeGen/CGExpr.cpp
+++ b/clang/lib/CodeGen/CGExpr.cpp
@@ -431,7 +431,7 @@ static Address createReferenceTemporary(CodeGenFunction &CGF,
/// Helper method to check if the underlying ABI is AAPCS
static bool isAAPCS(const TargetInfo &TargetInfo) {
- return TargetInfo.getABI().startswith("aapcs");
+ return TargetInfo.getABI().starts_with("aapcs");
}
LValue CodeGenFunction::
@@ -3156,7 +3156,7 @@ LValue CodeGenFunction::EmitPredefinedLValue(const PredefinedExpr *E) {
auto SL = E->getFunctionName();
assert(SL != nullptr && "No StringLiteral name in PredefinedExpr");
StringRef FnName = CurFn->getName();
- if (FnName.startswith("\01"))
+ if (FnName.starts_with("\01"))
FnName = FnName.substr(1);
StringRef NameItems[] = {
PredefinedExpr::getIdentKindName(E->getIdentKind()), FnName};
diff --git a/clang/lib/CodeGen/CGObjCMac.cpp b/clang/lib/CodeGen/CGObjCMac.cpp
index ba52b23..517f7cd 100644
--- a/clang/lib/CodeGen/CGObjCMac.cpp
+++ b/clang/lib/CodeGen/CGObjCMac.cpp
@@ -1850,7 +1850,7 @@ static bool hasObjCExceptionAttribute(ASTContext &Context,
static llvm::GlobalValue::LinkageTypes
getLinkageTypeForObjCMetadata(CodeGenModule &CGM, StringRef Section) {
if (CGM.getTriple().isOSBinFormatMachO() &&
- (Section.empty() || Section.startswith("__DATA")))
+ (Section.empty() || Section.starts_with("__DATA")))
return llvm::GlobalValue::InternalLinkage;
return llvm::GlobalValue::PrivateLinkage;
}
@@ -6162,7 +6162,7 @@ void CGObjCNonFragileABIMac::AddModuleClassList(
// Section name is obtained by calling GetSectionName, which returns
// sections in the __DATA segment on MachO.
assert((!CGM.getTriple().isOSBinFormatMachO() ||
- SectionName.startswith("__DATA")) &&
+ SectionName.starts_with("__DATA")) &&
"SectionName expected to start with __DATA on MachO");
llvm::GlobalVariable *GV = new llvm::GlobalVariable(
CGM.getModule(), Init->getType(), false,
diff --git a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
index cbfa79e..868ef81 100644
--- a/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
+++ b/clang/lib/CodeGen/CGRecordLayoutBuilder.cpp
@@ -111,7 +111,7 @@ struct CGRecordLowering {
/// Helper function to check if we are targeting AAPCS.
bool isAAPCS() const {
- return Context.getTargetInfo().getABI().startswith("aapcs");
+ return Context.getTargetInfo().getABI().starts_with("aapcs");
}
/// Helper function to check if the target machine is BigEndian.
diff --git a/clang/lib/CodeGen/CGStmt.cpp b/clang/lib/CodeGen/CGStmt.cpp
index a5cb806..0f79a2e 100644
--- a/clang/lib/CodeGen/CGStmt.cpp
+++ b/clang/lib/CodeGen/CGStmt.cpp
@@ -2548,7 +2548,7 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) {
ResultRegQualTys.push_back(QTy);
ResultRegDests.push_back(Dest);
- bool IsFlagReg = llvm::StringRef(OutputConstraint).startswith("{@cc");
+ bool IsFlagReg = llvm::StringRef(OutputConstraint).starts_with("{@cc");
ResultRegIsFlagReg.push_back(IsFlagReg);
llvm::Type *Ty = ConvertTypeForMem(QTy);
diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp
index bb6b1a3..753a8fd 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -1139,7 +1139,7 @@ CodeGenAction::loadModule(MemoryBufferRef MBRef) {
// Strip off a leading diagnostic code if there is one.
StringRef Msg = Err.getMessage();
- if (Msg.startswith("error: "))
+ if (Msg.starts_with("error: "))
Msg = Msg.substr(7);
unsigned DiagID =
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp
index b931a81..7ad26ac 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -225,9 +225,9 @@ createTargetCodeGenInfo(CodeGenModule &CGM) {
StringRef ABIStr = Target.getABI();
unsigned XLen = Target.getPointerWidth(LangAS::Default);
unsigned ABIFLen = 0;
- if (ABIStr.endswith("f"))
+ if (ABIStr.ends_with("f"))
ABIFLen = 32;
- else if (ABIStr.endswith("d"))
+ else if (ABIStr.ends_with("d"))
ABIFLen = 64;
return createRISCVTargetCodeGenInfo(CGM, XLen, ABIFLen);
}
@@ -308,9 +308,9 @@ createTargetCodeGenInfo(CodeGenModule &CGM) {
case llvm::Triple::loongarch64: {
StringRef ABIStr = Target.getABI();
unsigned ABIFRLen = 0;
- if (ABIStr.endswith("f"))
+ if (ABIStr.ends_with("f"))
ABIFRLen = 32;
- else if (ABIStr.endswith("d"))
+ else if (ABIStr.ends_with("d"))
ABIFRLen = 64;
return createLoongArchTargetCodeGenInfo(
CGM, Target.getPointerWidth(LangAS::Default), ABIFRLen);
@@ -1715,7 +1715,7 @@ static void AppendTargetMangling(const CodeGenModule &CGM,
llvm::sort(Info.Features, [&Target](StringRef LHS, StringRef RHS) {
// Multiversioning doesn't allow "no-${feature}", so we can
// only have "+" prefixes here.
- assert(LHS.startswith("+") && RHS.startswith("+") &&
+ assert(LHS.starts_with("+") && RHS.starts_with("+") &&
"Features should always have a prefix.");
return Target.multiVersionSortPriority(LHS.substr(1)) >
Target.multiVersionSortPriority(RHS.substr(1));
@@ -1769,7 +1769,7 @@ static void AppendTargetClonesMangling(const CodeGenModule &CGM,
} else {
Out << '.';
StringRef FeatureStr = Attr->getFeatureStr(VersionIndex);
- if (FeatureStr.startswith("arch="))
+ if (FeatureStr.starts_with("arch="))
Out << "arch_" << FeatureStr.substr(sizeof("arch=") - 1);
else
Out << FeatureStr;
@@ -3828,7 +3828,7 @@ namespace {
if (!BuiltinID || !BI.isLibFunction(BuiltinID))
return false;
StringRef BuiltinName = BI.getName(BuiltinID);
- if (BuiltinName.startswith("__builtin_") &&
+ if (BuiltinName.starts_with("__builtin_") &&
Name == BuiltinName.slice(strlen("__builtin_"), StringRef::npos)) {
return true;
}
@@ -4164,7 +4164,7 @@ void CodeGenModule::emitMultiVersionFunctions() {
Feature.push_back(CurFeat.trim());
}
} else {
- if (Version.startswith("arch="))
+ if (Version.starts_with("arch="))
Architecture = Version.drop_front(sizeof("arch=") - 1);
else if (Version != "default")
Feature.push_back(Version);
diff --git a/clang/lib/CodeGen/Targets/SPIR.cpp b/clang/lib/CodeGen/Targets/SPIR.cpp
index 8bacba6..cf068cb 100644
--- a/clang/lib/CodeGen/Targets/SPIR.cpp
+++ b/clang/lib/CodeGen/Targets/SPIR.cpp
@@ -146,14 +146,14 @@ static llvm::Type *getSPIRVImageType(llvm::LLVMContext &Ctx, StringRef BaseType,
// Choose the dimension of the image--this corresponds to the Dim enum in
// SPIR-V (first integer parameter of OpTypeImage).
- if (OpenCLName.startswith("image2d"))
+ if (OpenCLName.starts_with("image2d"))
IntParams[0] = 1; // 1D
- else if (OpenCLName.startswith("image3d"))
+ else if (OpenCLName.starts_with("image3d"))
IntParams[0] = 2; // 2D
else if (OpenCLName == "image1d_buffer")
IntParams[0] = 5; // Buffer
else
- assert(OpenCLName.startswith("image1d") && "Unknown image type");
+ assert(OpenCLName.starts_with("image1d") && "Unknown image type");
// Set the other integer parameters of OpTypeImage if necessary. Note that the
// OpenCL image types don't provide any information for the Sampled or
diff --git a/clang/lib/Driver/Distro.cpp b/clang/lib/Driver/Distro.cpp
index 36f828f..a7e7f16 100644
--- a/clang/lib/Driver/Distro.cpp
+++ b/clang/lib/Driver/Distro.cpp
@@ -34,7 +34,7 @@ static Distro::DistroType DetectOsRelease(llvm::vfs::FileSystem &VFS) {
// Obviously this can be improved a lot.
for (StringRef Line : Lines)
- if (Version == Distro::UnknownDistro && Line.startswith("ID="))
+ if (Version == Distro::UnknownDistro && Line.starts_with("ID="))
Version = llvm::StringSwitch<Distro::DistroType>(Line.substr(3))
.Case("alpine", Distro::AlpineLinux)
.Case("fedora", Distro::Fedora)
@@ -60,7 +60,7 @@ static Distro::DistroType DetectLsbRelease(llvm::vfs::FileSystem &VFS) {
for (StringRef Line : Lines)
if (Version == Distro::UnknownDistro &&
- Line.startswith("DISTRIB_CODENAME="))
+ Line.starts_with("DISTRIB_CODENAME="))
Version = llvm::StringSwitch<Distro::DistroType>(Line.substr(17))
.Case("hardy", Distro::UbuntuHardy)
.Case("intrepid", Distro::UbuntuIntrepid)
@@ -119,10 +119,10 @@ static Distro::DistroType DetectDistro(llvm::vfs::FileSystem &VFS) {
if (File) {
StringRef Data = File.get()->getBuffer();
- if (Data.startswith("Fedora release"))
+ if (Data.starts_with("Fedora release"))
return Distro::Fedora;
- if (Data.startswith("Red Hat Enterprise Linux") ||
- Data.startswith("CentOS") || Data.startswith("Scientific Linux")) {
+ if (Data.starts_with("Red Hat Enterprise Linux") ||
+ Data.starts_with("CentOS") || Data.starts_with("Scientific Linux")) {
if (Data.contains("release 7"))
return Distro::RHEL7;
else if (Data.contains("release 6"))
@@ -182,7 +182,7 @@ static Distro::DistroType DetectDistro(llvm::vfs::FileSystem &VFS) {
SmallVector<StringRef, 8> Lines;
Data.split(Lines, "\n");
for (const StringRef &Line : Lines) {
- if (!Line.trim().startswith("VERSION"))
+ if (!Line.trim().starts_with("VERSION"))
continue;
std::pair<StringRef, StringRef> SplitLine = Line.split('=');
// Old versions have split VERSION and PATCHLEVEL
diff --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index f392f67..ff95c89 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1451,7 +1451,7 @@ Compilation *Driver::BuildCompilation(ArrayRef<const char *> ArgList) {
case llvm::Triple::aarch64:
case llvm::Triple::aarch64_be:
case llvm::Triple::aarch64_32:
- if (TC.getTriple().getEnvironmentName().startswith("eabi")) {
+ if (TC.getTriple().getEnvironmentName().starts_with("eabi")) {
Diag(diag::warn_target_unrecognized_env)
<< TargetTriple
<< (TC.getTriple().getArchName().str() + "-none-elf");
@@ -1540,7 +1540,7 @@ bool Driver::getCrashDiagnosticFile(StringRef ReproCrashFilename,
for (fs::directory_iterator File(CrashDiagDir, EC), FileEnd;
File != FileEnd && !EC; File.increment(EC)) {
StringRef FileName = path::filename(File->path());
- if (!FileName.startswith(Name))
+ if (!FileName.starts_with(Name))
continue;
if (fs::status(File->path(), FileStatus))
continue;
@@ -1551,7 +1551,7 @@ bool Driver::getCrashDiagnosticFile(StringRef ReproCrashFilename,
// The first line should start with "Process:", otherwise this isn't a real
// .crash file.
StringRef Data = CrashFile.get()->getBuffer();
- if (!Data.startswith("Process:"))
+ if (!Data.starts_with("Process:"))
continue;
// Parse parent process pid line, e.g: "Parent Process: clang-4.0 [79141]"
size_t ParentProcPos = Data.find("Parent Process:");
@@ -1780,7 +1780,7 @@ void Driver::generateCompilationDiagnostics(
ReproCrashFilename = TempFile;
llvm::sys::path::replace_extension(ReproCrashFilename, ".crash");
}
- if (StringRef(TempFile).endswith(".cache")) {
+ if (StringRef(TempFile).ends_with(".cache")) {
// In some cases (modules) we'll dump extra data to help with reproducing
// the crash into a directory next to the output.
VFS = llvm::sys::path::filename(TempFile);
@@ -2001,7 +2001,7 @@ void Driver::HandleAutocompletions(StringRef PassedFlags) const {
// Distinguish "--autocomplete=-someflag" and "--autocomplete=-someflag,"
// because the latter indicates that the user put space before pushing tab
// which should end up in a file completion.
- const bool HasSpace = PassedFlags.endswith(",");
+ const bool HasSpace = PassedFlags.ends_with(",");
// Parse PassedFlags by "," as all the command-line flags are passed to this
// function separated by ","
@@ -2041,7 +2041,7 @@ void Driver::HandleAutocompletions(StringRef PassedFlags) const {
// When flag ends with '=' and there was no value completion, return empty
// string and fall back to the file autocompletion.
- if (SuggestedCompletions.empty() && !Cur.endswith("=")) {
+ if (SuggestedCompletions.empty() && !Cur.ends_with("=")) {
// If the flag is in the form of "--autocomplete=-foo",
// we were requested to print out all option names that start with "-foo".
// For example, "--autocomplete=-fsyn" is expanded to "-fsyntax-only".
@@ -2053,7 +2053,7 @@ void Driver::HandleAutocompletions(StringRef PassedFlags) const {
// TODO: Find a good way to add them to OptTable instead and them remove
// this code.
for (StringRef S : DiagnosticIDs::getDiagnosticFlags())
- if (S.startswith(Cur))
+ if (S.starts_with(Cur))
SuggestedCompletions.push_back(std::string(S));
}
@@ -2535,7 +2535,7 @@ bool Driver::DiagnoseInputExistence(const DerivedArgList &Args, StringRef Value,
// so we can't downgrade diagnostics for `/GR-` from an error to a warning
// in cc mode. (We can in cl mode because cl.exe itself only warns on
// unknown flags.)
- if (IsCLMode() && Ty == types::TY_Object && !Value.startswith("/"))
+ if (IsCLMode() && Ty == types::TY_Object && !Value.starts_with("/"))
return true;
Diag(clang::diag::err_drv_no_such_file) << Value;
@@ -6565,7 +6565,7 @@ llvm::StringRef clang::driver::getDriverMode(StringRef ProgName,
getDriverOptTable().getOption(options::OPT_driver_mode).getPrefixedName();
llvm::StringRef Opt;
for (StringRef Arg : Args) {
- if (!Arg.startswith(OptName))
+ if (!Arg.starts_with(OptName))
continue;
Opt = Arg;
}
@@ -6606,7 +6606,7 @@ llvm::Error driver::expandResponseFiles(SmallVectorImpl<const char *> &Args,
else
Tokenizer = &llvm::cl::TokenizeGNUCommandLine;
- if (MarkEOLs && Args.size() > 1 && StringRef(Args[1]).startswith("-cc1"))
+ if (MarkEOLs && Args.size() > 1 && StringRef(Args[1]).starts_with("-cc1"))
MarkEOLs = false;
llvm::cl::ExpansionContext ECtx(Alloc, Tokenizer);
@@ -6620,7 +6620,7 @@ llvm::Error driver::expandResponseFiles(SmallVectorImpl<const char *> &Args,
// If -cc1 came from a response file, remove the EOL sentinels.
auto FirstArg = llvm::find_if(llvm::drop_begin(Args),
[](const char *A) { return A != nullptr; });
- if (FirstArg != Args.end() && StringRef(*FirstArg).startswith("-cc1")) {
+ if (FirstArg != Args.end() && StringRef(*FirstArg).starts_with("-cc1")) {
// If -cc1 came from a response file, remove the EOL sentinels.
if (MarkEOLs) {
auto newEnd = std::remove(Args.begin(), Args.end(), nullptr);
diff --git a/clang/lib/Driver/Job.cpp b/clang/lib/Driver/Job.cpp
index 2034004..a6c1581 100644
--- a/clang/lib/Driver/Job.cpp
+++ b/clang/lib/Driver/Job.cpp
@@ -95,10 +95,10 @@ static bool skipArgs(const char *Flag, bool HaveCrashVFS, int &SkipNum,
// These flags are treated as a single argument (e.g., -F<Dir>).
StringRef FlagRef(Flag);
- IsInclude = FlagRef.startswith("-F") || FlagRef.startswith("-I");
+ IsInclude = FlagRef.starts_with("-F") || FlagRef.starts_with("-I");
if (IsInclude)
return !HaveCrashVFS;
- if (FlagRef.startswith("-fmodules-cache-path="))
+ if (FlagRef.starts_with("-fmodules-cache-path="))
return true;
SkipNum = 0;
@@ -185,8 +185,8 @@ rewriteIncludes(const llvm::ArrayRef<const char *> &Args, size_t Idx,
SmallString<128> NewInc;
if (NumArgs == 1) {
StringRef FlagRef(Args[Idx + NumArgs - 1]);
- assert((FlagRef.startswith("-F") || FlagRef.startswith("-I")) &&
- "Expecting -I or -F");
+ assert((FlagRef.starts_with("-F") || FlagRef.starts_with("-I")) &&
+ "Expecting -I or -F");
StringRef Inc = FlagRef.slice(2, StringRef::npos);
if (getAbsPath(Inc, NewInc)) {
SmallString<128> NewArg(FlagRef.slice(0, 2));
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index ab19166..96a5792 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -315,7 +315,7 @@ static const DriverSuffix *FindDriverSuffix(StringRef ProgName, size_t &Pos) {
for (const auto &DS : DriverSuffixes) {
StringRef Suffix(DS.Suffix);
- if (ProgName.endswith(Suffix)) {
+ if (ProgName.ends_with(Suffix)) {
Pos = ProgName.size() - Suffix.size();
return &DS;
}
@@ -345,7 +345,7 @@ static const DriverSuffix *parseDriverSuffix(StringRef ProgName, size_t &Pos) {
// added via -target as implicit first argument.
const DriverSuffix *DS = FindDriverSuffix(ProgName, Pos);
- if (!DS && ProgName.endswith(".exe")) {
+ if (!DS && ProgName.ends_with(".exe")) {
// Try again after stripping the executable suffix:
// clang++.exe -> clang++
ProgName = ProgName.drop_back(StringRef(".exe").size());
diff --git a/clang/lib/Driver/ToolChains/AIX.cpp b/clang/lib/Driver/ToolChains/AIX.cpp
index aed8734..f9670ea 100644
--- a/clang/lib/Driver/ToolChains/AIX.cpp
+++ b/clang/lib/Driver/ToolChains/AIX.cpp
@@ -88,7 +88,7 @@ static bool hasExportListLinkerOpts(const ArgStringList &CmdArgs) {
for (size_t i = 0, Size = CmdArgs.size(); i < Size; ++i) {
llvm::StringRef ArgString(CmdArgs[i]);
- if (ArgString.startswith("-bE:") || ArgString.startswith("-bexport:") ||
+ if (ArgString.starts_with("-bE:") || ArgString.starts_with("-bexport:") ||
ArgString == "-bexpall" || ArgString == "-bexpfull")
return true;
@@ -96,8 +96,8 @@ static bool hasExportListLinkerOpts(const ArgStringList &CmdArgs) {
if (ArgString == "-b" && i + 1 < Size) {
++i;
llvm::StringRef ArgNextString(CmdArgs[i]);
- if (ArgNextString.startswith("E:") ||
- ArgNextString.startswith("export:") || ArgNextString == "expall" ||
+ if (ArgNextString.starts_with("E:") ||
+ ArgNextString.starts_with("export:") || ArgNextString == "expall" ||
ArgNextString == "expfull")
return true;
}
diff --git a/clang/lib/Driver/ToolChains/AMDGPU.cpp b/clang/lib/Driver/ToolChains/AMDGPU.cpp
index cad206e..56f06fc 100644
--- a/clang/lib/Driver/ToolChains/AMDGPU.cpp
+++ b/clang/lib/Driver/ToolChains/AMDGPU.cpp
@@ -49,7 +49,7 @@ RocmInstallationDetector::findSPACKPackage(const Candidate &Cand,
FileEnd;
File != FileEnd && !EC; File.increment(EC)) {
llvm::StringRef FileName = llvm::sys::path::filename(File->path());
- if (FileName.startswith(Prefix)) {
+ if (FileName.starts_with(Prefix)) {
SubDirs.push_back(FileName);
if (SubDirs.size() > 1)
break;
@@ -84,13 +84,13 @@ void RocmInstallationDetector::scanLibDevicePath(llvm::StringRef Path) {
!EC && LI != LE; LI = LI.increment(EC)) {
StringRef FilePath = LI->path();
StringRef FileName = llvm::sys::path::filename(FilePath);
- if (!FileName.endswith(Suffix))
+ if (!FileName.ends_with(Suffix))
continue;
StringRef BaseName;
- if (FileName.endswith(Suffix2))
+ if (FileName.ends_with(Suffix2))
BaseName = FileName.drop_back(Suffix2.size());
- else if (FileName.endswith(Suffix))
+ else if (FileName.ends_with(Suffix))
BaseName = FileName.drop_back(Suffix.size());
const StringRef ABIVersionPrefix = "oclc_abi_version_";
@@ -124,7 +124,7 @@ void RocmInstallationDetector::scanLibDevicePath(llvm::StringRef Path) {
WavefrontSize64.On = FilePath;
} else if (BaseName == "oclc_wavefrontsize64_off") {
WavefrontSize64.Off = FilePath;
- } else if (BaseName.startswith(ABIVersionPrefix)) {
+ } else if (BaseName.starts_with(ABIVersionPrefix)) {
unsigned ABIVersionNumber;
if (BaseName.drop_front(ABIVersionPrefix.size())
.getAsInteger(/*Redex=*/0, ABIVersionNumber))
@@ -134,7 +134,7 @@ void RocmInstallationDetector::scanLibDevicePath(llvm::StringRef Path) {
// Process all bitcode filenames that look like
// ocl_isa_version_XXX.amdgcn.bc
const StringRef DeviceLibPrefix = "oclc_isa_version_";
- if (!BaseName.startswith(DeviceLibPrefix))
+ if (!BaseName.starts_with(DeviceLibPrefix))
continue;
StringRef IsaVersionNumber =
@@ -230,7 +230,7 @@ RocmInstallationDetector::getInstallationPathCandidates() {
// <rocm_root>/llvm-amdgpu-<rocm_release_string>-<hash>/bin directory.
// We only consider the parent directory of llvm-amdgpu package as ROCm
// installation candidate for SPACK.
- if (ParentName.startswith("llvm-amdgpu-")) {
+ if (ParentName.starts_with("llvm-amdgpu-")) {
auto SPACKPostfix =
ParentName.drop_front(strlen("llvm-amdgpu-")).split('-');
auto SPACKReleaseStr = SPACKPostfix.first;
@@ -243,7 +243,7 @@ RocmInstallationDetector::getInstallationPathCandidates() {
// Some versions of the rocm llvm package install to /opt/rocm/llvm/bin
// Some versions of the aomp package install to /opt/rocm/aomp/bin
- if (ParentName == "llvm" || ParentName.startswith("aomp"))
+ if (ParentName == "llvm" || ParentName.starts_with("aomp"))
ParentDir = llvm::sys::path::parent_path(ParentDir);
return Candidate(ParentDir.str(), /*StrictChecking=*/true);
@@ -292,7 +292,7 @@ RocmInstallationDetector::getInstallationPathCandidates() {
FileEnd;
File != FileEnd && !EC; File.increment(EC)) {
llvm::StringRef FileName = llvm::sys::path::filename(File->path());
- if (!FileName.startswith("rocm-"))
+ if (!FileName.starts_with("rocm-"))
continue;
if (LatestROCm.empty()) {
LatestROCm = FileName.str();
diff --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 097258b..912df79 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -228,7 +228,7 @@ getAArch64MicroArchFeaturesFromMtune(const Driver &D, StringRef Mtune,
if (MtuneLowerCase == "native")
MtuneLowerCase = std::string(llvm::sys::getHostCPUName());
if (MtuneLowerCase == "cyclone" ||
- StringRef(MtuneLowerCase).startswith("apple")) {
+ StringRef(MtuneLowerCase).starts_with("apple")) {
Features.push_back("+zcm");
Features.push_back("+zcz");
}
@@ -262,7 +262,7 @@ void aarch64::getAArch64TargetFeatures(const Driver &D,
for (const auto *A :
Args.filtered(options::OPT_Wa_COMMA, options::OPT_Xassembler))
for (StringRef Value : A->getValues())
- if (Value.startswith("-march="))
+ if (Value.starts_with("-march="))
WaMArch = Value.substr(7);
// Call getAArch64ArchFeaturesFromMarch only if "-Wa,-march=" or
// "-Xassembler -march" is detected. Otherwise it may return false
diff --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index f1d7aeb..25470db 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -67,9 +67,9 @@ void arm::getARMArchCPUFromArgs(const ArgList &Args, llvm::StringRef &Arch,
// Use getValues because -Wa can have multiple arguments
// e.g. -Wa,-mcpu=foo,-mcpu=bar
for (StringRef Value : A->getValues()) {
- if (Value.startswith("-mcpu="))
+ if (Value.starts_with("-mcpu="))
CPU = Value.substr(6);
- if (Value.startswith("-march="))
+ if (Value.starts_with("-march="))
Arch = Value.substr(7);
}
}
@@ -285,9 +285,9 @@ void arm::setArchNameInTriple(const Driver &D, const ArgList &Args,
// There is no assembler equivalent of -mno-thumb, -marm, or -mno-arm.
if (Value == "-mthumb")
IsThumb = true;
- else if (Value.startswith("-march="))
+ else if (Value.starts_with("-march="))
WaMArch = Value.substr(7);
- else if (Value.startswith("-mcpu="))
+ else if (Value.starts_with("-mcpu="))
WaMCPU = Value.substr(6);
}
}
@@ -528,13 +528,13 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver &D,
// We use getValues here because you can have many options per -Wa
// We will keep the last one we find for each of these
for (StringRef Value : A->getValues()) {
- if (Value.startswith("-mfpu=")) {
+ if (Value.starts_with("-mfpu=")) {
WaFPU = std::make_pair(A, Value.substr(6));
- } else if (Value.startswith("-mcpu=")) {
+ } else if (Value.starts_with("-mcpu=")) {
WaCPU = std::make_pair(A, Value.substr(6));
- } else if (Value.startswith("-mhwdiv=")) {
+ } else if (Value.starts_with("-mhwdiv=")) {
WaHDiv = std::make_pair(A, Value.substr(8));
- } else if (Value.startswith("-march=")) {
+ } else if (Value.starts_with("-march=")) {
WaArch = std::make_pair(A, Value.substr(7));
}
}
@@ -796,7 +796,7 @@ fp16_fml_fallthrough:
// Propagate frame-chain model selection
if (Arg *A = Args.getLastArg(options::OPT_mframe_chain)) {
StringRef FrameChainOption = A->getValue();
- if (FrameChainOption.startswith("aapcs"))
+ if (FrameChainOption.starts_with("aapcs"))
Features.push_back("+aapcs-frame-chain");
if (FrameChainOption == "aapcs+leaf")
Features.push_back("+aapcs-frame-chain-leaf");
diff --git a/clang/lib/Driver/ToolChains/Arch/X86.cpp b/clang/lib/Driver/ToolChains/Arch/X86.cpp
index 3e51b2b..fef0522 100644
--- a/clang/lib/Driver/ToolChains/Arch/X86.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/X86.cpp
@@ -234,15 +234,15 @@ void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
A->claim();
// Skip over "-m".
- assert(Name.startswith("m") && "Invalid feature name.");
+ assert(Name.starts_with("m") && "Invalid feature name.");
Name = Name.substr(1);
- bool IsNegative = Name.startswith("no-");
+ bool IsNegative = Name.starts_with("no-");
if (IsNegative)
Name = Name.substr(3);
#ifndef NDEBUG
- assert(Name.startswith("avx10.") && "Invalid AVX10 feature name.");
+ assert(Name.starts_with("avx10.") && "Invalid AVX10 feature name.");
StringRef Version, Width;
std::tie(Version, Width) = Name.substr(6).split('-');
assert(Version == "1" && "Invalid AVX10 feature name.");
@@ -260,7 +260,7 @@ void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
A->claim();
// Skip over "-m".
- assert(Name.startswith("m") && "Invalid feature name.");
+ assert(Name.starts_with("m") && "Invalid feature name.");
Name = Name.substr(1);
// Replace -mgeneral-regs-only with -x87, -mmx, -sse
@@ -269,7 +269,7 @@ void x86::getX86TargetFeatures(const Driver &D, const llvm::Triple &Triple,
continue;
}
- bool IsNegative = Name.startswith("no-");
+ bool IsNegative = Name.starts_with("no-");
if (A->getOption().matches(options::OPT_mapx_features_EQ) ||
A->getOption().matches(options::OPT_mno_apx_features_EQ)) {
diff --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index dd893c2..de9fd5e 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -223,7 +223,7 @@ static void ParseMRecip(const Driver &D, const ArgList &Args,
for (unsigned i = 0; i != NumOptions; ++i) {
StringRef Val = A->getValue(i);
- bool IsDisabled = Val.startswith(DisabledPrefixIn);
+ bool IsDisabled = Val.starts_with(DisabledPrefixIn);
// Ignore the disablement token for string matching.
if (IsDisabled)
Val = Val.substr(1);
@@ -433,7 +433,7 @@ static void addDebugObjectName(const ArgList &Args, ArgStringList &CmdArgs,
const char *OutputFileName) {
// No need to generate a value for -object-file-name if it was provided.
for (auto *Arg : Args.filtered(options::OPT_Xclang))
- if (StringRef(Arg->getValue()).startswith("-object-file-name"))
+ if (StringRef(Arg->getValue()).starts_with("-object-file-name"))
return;
if (Args.hasArg(options::OPT_object_file_name_EQ))
@@ -940,7 +940,7 @@ static void handleAMDGPUCodeObjectVersionOptions(const Driver &D,
static bool hasClangPchSignature(const Driver &D, StringRef Path) {
if (llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> MemBuf =
D.getVFS().getBufferForFile(Path))
- return (*MemBuf)->getBuffer().startswith("CPCH");
+ return (*MemBuf)->getBuffer().starts_with("CPCH");
return false;
}
@@ -1715,7 +1715,7 @@ void Clang::AddAArch64TargetArgs(const ArgList &Args,
Val.equals("256+") || Val.equals("512+") || Val.equals("1024+") ||
Val.equals("2048+")) {
unsigned Bits = 0;
- if (Val.endswith("+"))
+ if (Val.ends_with("+"))
Val = Val.substr(0, Val.size() - 1);
else {
bool Invalid = Val.getAsInteger(10, Bits); (void)Invalid;
@@ -2503,7 +2503,7 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
case llvm::Triple::thumbeb:
case llvm::Triple::arm:
case llvm::Triple::armeb:
- if (Value.startswith("-mimplicit-it=")) {
+ if (Value.starts_with("-mimplicit-it=")) {
// Only store the value; the last value set takes effect.
ImplicitIt = Value.split("=").second;
if (CheckARMImplicitITArg(ImplicitIt))
@@ -2528,12 +2528,12 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
CmdArgs.push_back("-use-tcc-in-div");
continue;
}
- if (Value.startswith("-msoft-float")) {
+ if (Value.starts_with("-msoft-float")) {
CmdArgs.push_back("-target-feature");
CmdArgs.push_back("+soft-float");
continue;
}
- if (Value.startswith("-mhard-float")) {
+ if (Value.starts_with("-mhard-float")) {
CmdArgs.push_back("-target-feature");
CmdArgs.push_back("-soft-float");
continue;
@@ -2570,8 +2570,8 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
CmdArgs.push_back("-massembler-no-warn");
} else if (Value == "--noexecstack") {
UseNoExecStack = true;
- } else if (Value.startswith("-compress-debug-sections") ||
- Value.startswith("--compress-debug-sections") ||
+ } else if (Value.starts_with("-compress-debug-sections") ||
+ Value.starts_with("--compress-debug-sections") ||
Value == "-nocompress-debug-sections" ||
Value == "--nocompress-debug-sections") {
CmdArgs.push_back(Value.data());
@@ -2581,13 +2581,13 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
} else if (Value == "-mrelax-relocations=no" ||
Value == "--mrelax-relocations=no") {
UseRelaxRelocations = false;
- } else if (Value.startswith("-I")) {
+ } else if (Value.starts_with("-I")) {
CmdArgs.push_back(Value.data());
// We need to consume the next argument if the current arg is a plain
// -I. The next arg will be the include directory.
if (Value == "-I")
TakeNextArg = true;
- } else if (Value.startswith("-gdwarf-")) {
+ } else if (Value.starts_with("-gdwarf-")) {
// "-gdwarf-N" options are not cc1as options.
unsigned DwarfVersion = DwarfVersionNum(Value);
if (DwarfVersion == 0) { // Send it onward, and let cc1as complain.
@@ -2597,30 +2597,30 @@ static void CollectArgsForIntegratedAssembler(Compilation &C,
llvm::codegenoptions::DebugInfoConstructor,
DwarfVersion, llvm::DebuggerKind::Default);
}
- } else if (Value.startswith("-mcpu") || Value.startswith("-mfpu") ||
- Value.startswith("-mhwdiv") || Value.startswith("-march")) {
+ } else if (Value.starts_with("-mcpu") || Value.starts_with("-mfpu") ||
+ Value.starts_with("-mhwdiv") || Value.starts_with("-march")) {
// Do nothing, we'll validate it later.
} else if (Value == "-defsym") {
- if (A->getNumValues() != 2) {
- D.Diag(diag::err_drv_defsym_invalid_format) << Value;
- break;
- }
- const char *S = A->getValue(1);
- auto Pair = StringRef(S).split('=');
- auto Sym = Pair.first;
- auto SVal = Pair.second;
-
- if (Sym.empty() || SVal.empty()) {
- D.Diag(diag::err_drv_defsym_invalid_format) << S;
- break;
- }
- int64_t IVal;
- if (SVal.getAsInteger(0, IVal)) {
- D.Diag(diag::err_drv_defsym_invalid_symval) << SVal;
- break;
- }
- CmdArgs.push_back(Value.data());
- TakeNextArg = true;
+ if (A->getNumValues() != 2) {
+ D.Diag(diag::err_drv_defsym_invalid_format) << Value;
+ break;
+ }
+ const char *S = A->getValue(1);
+ auto Pair = StringRef(S).split('=');
+ auto Sym = Pair.first;
+ auto SVal = Pair.second;
+
+ if (Sym.empty() || SVal.empty()) {
+ D.Diag(diag::err_drv_defsym_invalid_format) << S;
+ break;
+ }
+ int64_t IVal;
+ if (SVal.getAsInteger(0, IVal)) {
+ D.Diag(diag::err_drv_defsym_invalid_symval) << SVal;
+ break;
+ }
+ CmdArgs.push_back(Value.data());
+ TakeNextArg = true;
} else if (Value == "-fdebug-compilation-dir") {
CmdArgs.push_back("-fdebug-compilation-dir");
TakeNextArg = true;
@@ -3331,7 +3331,7 @@ static void RenderSSPOptions(const Driver &D, const ToolChain &TC,
// --param ssp-buffer-size=
for (const Arg *A : Args.filtered(options::OPT__param)) {
StringRef Str(A->getValue());
- if (Str.startswith("ssp-buffer-size=")) {
+ if (Str.starts_with("ssp-buffer-size=")) {
if (StackProtectorLevel) {
CmdArgs.push_back("-stack-protector-buffer-size");
// FIXME: Verify the argument is a valid integer.
@@ -5886,7 +5886,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
StringRef Val = A->getValue();
if (Triple.isX86() && Triple.isOSBinFormatELF()) {
if (Val != "all" && Val != "labels" && Val != "none" &&
- !Val.startswith("list="))
+ !Val.starts_with("list="))
D.Diag(diag::err_drv_invalid_value)
<< A->getAsString(Args) << A->getValue();
else
@@ -8382,14 +8382,14 @@ void ClangAs::ConstructJob(Compilation &C, const JobAction &JA,
continue;
auto &JArgs = J.getArguments();
for (unsigned I = 0; I < JArgs.size(); ++I) {
- if (StringRef(JArgs[I]).startswith("-object-file-name=") &&
+ if (StringRef(JArgs[I]).starts_with("-object-file-name=") &&
Output.isFilename()) {
- ArgStringList NewArgs(JArgs.begin(), JArgs.begin() + I);
- addDebugObjectName(Args, NewArgs, DebugCompilationDir,
- Output.getFilename());
- NewArgs.append(JArgs.begin() + I + 1, JArgs.end());
- J.replaceArguments(NewArgs);
- break;
+ ArgStringList NewArgs(JArgs.begin(), JArgs.begin() + I);
+ addDebugObjectName(Args, NewArgs, DebugCompilationDir,
+ Output.getFilename());
+ NewArgs.append(JArgs.begin() + I + 1, JArgs.end());
+ J.replaceArguments(NewArgs);
+ break;
}
}
}
@@ -8653,7 +8653,7 @@ void OffloadPackager::ConstructJob(Compilation &C, const JobAction &JA,
getTargetFeatures(TC->getDriver(), TC->getTriple(), TCArgs, Features,
false);
llvm::copy_if(Features, std::back_inserter(FeatureArgs),
- [](StringRef Arg) { return !Arg.startswith("-target"); });
+ [](StringRef Arg) { return !Arg.starts_with("-target"); });
if (TC->getTriple().isAMDGPU()) {
for (StringRef Feature : llvm::split(Arch.split(':').second, ':')) {
diff --git a/clang/lib/Driver/ToolChains/CommonArgs.cpp b/clang/lib/Driver/ToolChains/CommonArgs.cpp
index 31e7d68..01fb071 100644
--- a/clang/lib/Driver/ToolChains/CommonArgs.cpp
+++ b/clang/lib/Driver/ToolChains/CommonArgs.cpp
@@ -303,7 +303,7 @@ void tools::handleTargetFeaturesGroup(const Driver &D,
A->claim();
// Skip over "-m".
- assert(Name.startswith("m") && "Invalid feature name.");
+ assert(Name.starts_with("m") && "Invalid feature name.");
Name = Name.substr(1);
auto Proc = getCPUName(D, Args, Triple);
@@ -317,7 +317,7 @@ void tools::handleTargetFeaturesGroup(const Driver &D,
continue;
}
- bool IsNegative = Name.startswith("no-");
+ bool IsNegative = Name.starts_with("no-");
if (IsNegative)
Name = Name.substr(3);
@@ -2336,20 +2336,20 @@ static void GetSDLFromOffloadArchive(
llvm::Triple Triple(D.getTargetTriple());
bool IsMSVC = Triple.isWindowsMSVCEnvironment();
auto Ext = IsMSVC ? ".lib" : ".a";
- if (!Lib.startswith(":") && !Lib.startswith("-l")) {
+ if (!Lib.starts_with(":") && !Lib.starts_with("-l")) {
if (llvm::sys::fs::exists(Lib)) {
ArchiveOfBundles = Lib;
FoundAOB = true;
}
} else {
- if (Lib.startswith("-l"))
+ if (Lib.starts_with("-l"))
Lib = Lib.drop_front(2);
for (auto LPath : LibraryPaths) {
ArchiveOfBundles.clear();
- auto LibFile =
- (Lib.startswith(":") ? Lib.drop_front()
- : IsMSVC ? Lib + Ext : "lib" + Lib + Ext)
- .str();
+ auto LibFile = (Lib.starts_with(":") ? Lib.drop_front()
+ : IsMSVC ? Lib + Ext
+ : "lib" + Lib + Ext)
+ .str();
for (auto Prefix : {"/libdevice/", "/"}) {
auto AOB = Twine(LPath + Prefix + LibFile).str();
if (llvm::sys::fs::exists(AOB)) {
diff --git a/clang/lib/Driver/ToolChains/Cuda.cpp b/clang/lib/Driver/ToolChains/Cuda.cpp
index ef1e779..f7a2085 100644
--- a/clang/lib/Driver/ToolChains/Cuda.cpp
+++ b/clang/lib/Driver/ToolChains/Cuda.cpp
@@ -238,7 +238,7 @@ CudaInstallationDetector::CudaInstallationDetector(
// Process all bitcode filenames that look like
// libdevice.compute_XX.YY.bc
const StringRef LibDeviceName = "libdevice.";
- if (!(FileName.startswith(LibDeviceName) && FileName.endswith(".bc")))
+ if (!(FileName.starts_with(LibDeviceName) && FileName.ends_with(".bc")))
continue;
StringRef GpuArch = FileName.slice(
LibDeviceName.size(), FileName.find('.', LibDeviceName.size()));
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index 692b3a3..65846ca 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1010,13 +1010,13 @@ static const char *ArmMachOArchNameCPU(StringRef CPU) {
// FIXME: Make sure this MachO triple mangling is really necessary.
// ARMv5* normalises to ARMv5.
- if (Arch.startswith("armv5"))
+ if (Arch.starts_with("armv5"))
Arch = Arch.substr(0, 5);
// ARMv6*, except ARMv6M, normalises to ARMv6.
- else if (Arch.startswith("armv6") && !Arch.endswith("6m"))
+ else if (Arch.starts_with("armv6") && !Arch.ends_with("6m"))
Arch = Arch.substr(0, 5);
// ARMv7A normalises to ARMv7.
- else if (Arch.endswith("v7a"))
+ else if (Arch.ends_with("v7a"))
Arch = Arch.substr(0, 5);
return Arch.data();
}
@@ -1319,8 +1319,8 @@ StringRef Darwin::getSDKName(StringRef isysroot) {
auto EndSDK = llvm::sys::path::rend(isysroot);
for (auto IT = BeginSDK; IT != EndSDK; ++IT) {
StringRef SDK = *IT;
- if (SDK.endswith(".sdk"))
- return SDK.slice(0, SDK.size() - 4);
+ if (SDK.ends_with(".sdk"))
+ return SDK.slice(0, SDK.size() - 4);
}
return "";
}
@@ -1959,22 +1959,23 @@ inferDeploymentTargetFromSDK(DerivedArgList &Args,
auto CreatePlatformFromSDKName =
[&](StringRef SDK) -> std::optional<DarwinPlatform> {
- if (SDK.startswith("iPhoneOS") || SDK.startswith("iPhoneSimulator"))
+ if (SDK.starts_with("iPhoneOS") || SDK.starts_with("iPhoneSimulator"))
return DarwinPlatform::createFromSDK(
Darwin::IPhoneOS, Version,
- /*IsSimulator=*/SDK.startswith("iPhoneSimulator"));
- else if (SDK.startswith("MacOSX"))
+ /*IsSimulator=*/SDK.starts_with("iPhoneSimulator"));
+ else if (SDK.starts_with("MacOSX"))
return DarwinPlatform::createFromSDK(Darwin::MacOS,
getSystemOrSDKMacOSVersion(Version));
- else if (SDK.startswith("WatchOS") || SDK.startswith("WatchSimulator"))
+ else if (SDK.starts_with("WatchOS") || SDK.starts_with("WatchSimulator"))
return DarwinPlatform::createFromSDK(
Darwin::WatchOS, Version,
- /*IsSimulator=*/SDK.startswith("WatchSimulator"));
- else if (SDK.startswith("AppleTVOS") || SDK.startswith("AppleTVSimulator"))
+ /*IsSimulator=*/SDK.starts_with("WatchSimulator"));
+ else if (SDK.starts_with("AppleTVOS") ||
+ SDK.starts_with("AppleTVSimulator"))
return DarwinPlatform::createFromSDK(
Darwin::TvOS, Version,
- /*IsSimulator=*/SDK.startswith("AppleTVSimulator"));
- else if (SDK.startswith("DriverKit"))
+ /*IsSimulator=*/SDK.starts_with("AppleTVSimulator"));
+ else if (SDK.starts_with("DriverKit"))
return DarwinPlatform::createFromSDK(Darwin::DriverKit, Version);
return std::nullopt;
};
@@ -2339,8 +2340,8 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
if (SDK.size() > 0) {
size_t StartVer = SDK.find_first_of("0123456789");
StringRef SDKName = SDK.slice(0, StartVer);
- if (!SDKName.startswith(getPlatformFamily()) &&
- !dropSDKNamePrefix(SDKName).startswith(getPlatformFamily()))
+ if (!SDKName.starts_with(getPlatformFamily()) &&
+ !dropSDKNamePrefix(SDKName).starts_with(getPlatformFamily()))
getDriver().Diag(diag::warn_incompatible_sysroot)
<< SDKName << getPlatformFamily();
}
diff --git a/clang/lib/Driver/ToolChains/Flang.cpp b/clang/lib/Driver/ToolChains/Flang.cpp
index 502b9f1..41eaad3 100644
--- a/clang/lib/Driver/ToolChains/Flang.cpp
+++ b/clang/lib/Driver/ToolChains/Flang.cpp
@@ -182,7 +182,7 @@ void Flang::AddAArch64TargetArgs(const ArgList &Args,
Val.equals("256+") || Val.equals("512+") || Val.equals("1024+") ||
Val.equals("2048+")) {
unsigned Bits = 0;
- if (Val.endswith("+"))
+ if (Val.ends_with("+"))
Val = Val.substr(0, Val.size() - 1);
else {
[[maybe_unused]] bool Invalid = Val.getAsInteger(10, Bits);
diff --git a/clang/lib/Driver/ToolChains/Gnu.cpp b/clang/lib/Driver/ToolChains/Gnu.cpp
index b875991..835215a 100644
--- a/clang/lib/Driver/ToolChains/Gnu.cpp
+++ b/clang/lib/Driver/ToolChains/Gnu.cpp
@@ -1084,7 +1084,7 @@ static bool findMipsCsMultilibs(const Multilib::flags_list &Flags,
.FilterOut(NonExistent)
.setIncludeDirsCallback([](const Multilib &M) {
std::vector<std::string> Dirs({"/include"});
- if (StringRef(M.includeSuffix()).startswith("/uclibc"))
+ if (StringRef(M.includeSuffix()).starts_with("/uclibc"))
Dirs.push_back(
"/../../../../mips-linux-gnu/libc/uclibc/usr/include");
else
@@ -1288,7 +1288,7 @@ static bool findMipsMtiMultilibs(const Multilib::flags_list &Flags,
.FilterOut(NonExistent)
.setIncludeDirsCallback([](const Multilib &M) {
std::vector<std::string> Dirs({"/include"});
- if (StringRef(M.includeSuffix()).startswith("/uclibc"))
+ if (StringRef(M.includeSuffix()).starts_with("/uclibc"))
Dirs.push_back("/../../../../sysroot/uclibc/usr/include");
else
Dirs.push_back("/../../../../sysroot/usr/include");
@@ -3055,7 +3055,7 @@ void Generic_GCC::AddMultilibPaths(const Driver &D,
// the cross. Note that GCC does include some of these directories in some
// configurations but this seems somewhere between questionable and simply
// a bug.
- if (StringRef(LibPath).startswith(SysRoot))
+ if (StringRef(LibPath).starts_with(SysRoot))
addPathIfExists(D, LibPath + "/../" + OSLibDir, Paths);
}
}
diff --git a/clang/lib/Driver/ToolChains/Hexagon.cpp b/clang/lib/Driver/ToolChains/Hexagon.cpp
index d0ff7d0..6a2a105 100644
--- a/clang/lib/Driver/ToolChains/Hexagon.cpp
+++ b/clang/lib/Driver/ToolChains/Hexagon.cpp
@@ -54,11 +54,11 @@ static void handleHVXTargetFeatures(const Driver &D, const ArgList &Args,
auto makeFeature = [&Args](Twine T, bool Enable) -> StringRef {
const std::string &S = T.str();
StringRef Opt(S);
- if (Opt.endswith("="))
+ if (Opt.ends_with("="))
Opt = Opt.drop_back(1);
- if (Opt.startswith("mno-"))
+ if (Opt.starts_with("mno-"))
Opt = Opt.drop_front(4);
- else if (Opt.startswith("m"))
+ else if (Opt.starts_with("m"))
Opt = Opt.drop_front(1);
return Args.MakeArgString(Twine(Enable ? "+" : "-") + Twine(Opt));
};
@@ -801,7 +801,7 @@ StringRef HexagonToolChain::GetTargetCPUVersion(const ArgList &Args) {
CpuArg = A;
StringRef CPU = CpuArg ? CpuArg->getValue() : GetDefaultCPU();
- if (CPU.startswith("hexagon"))
+ if (CPU.starts_with("hexagon"))
return CPU.substr(sizeof("hexagon") - 1);
return CPU;
}
diff --git a/clang/lib/Driver/ToolChains/Hurd.cpp b/clang/lib/Driver/ToolChains/Hurd.cpp
index 2dfc90e..7a4c2bb 100644
--- a/clang/lib/Driver/ToolChains/Hurd.cpp
+++ b/clang/lib/Driver/ToolChains/Hurd.cpp
@@ -92,7 +92,7 @@ Hurd::Hurd(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
// those searched.
// FIXME: It's not clear whether we should use the driver's installed
// directory ('Dir' below) or the ResourceDir.
- if (StringRef(D.Dir).startswith(SysRoot)) {
+ if (StringRef(D.Dir).starts_with(SysRoot)) {
addPathIfExists(D, D.Dir + "/../lib/" + MultiarchTriple, Paths);
addPathIfExists(D, D.Dir + "/../" + OSLibDir, Paths);
}
@@ -110,7 +110,7 @@ Hurd::Hurd(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
// searched.
// FIXME: It's not clear whether we should use the driver's installed
// directory ('Dir' below) or the ResourceDir.
- if (StringRef(D.Dir).startswith(SysRoot))
+ if (StringRef(D.Dir).starts_with(SysRoot))
addPathIfExists(D, D.Dir + "/../lib", Paths);
addPathIfExists(D, SysRoot + "/lib", Paths);
diff --git a/clang/lib/Driver/ToolChains/MSP430.cpp b/clang/lib/Driver/ToolChains/MSP430.cpp
index b28d5e4..8dc2352 100644
--- a/clang/lib/Driver/ToolChains/MSP430.cpp
+++ b/clang/lib/Driver/ToolChains/MSP430.cpp
@@ -166,7 +166,7 @@ void MSP430ToolChain::addClangTargetOptions(const ArgList &DriverArgs,
return;
const StringRef MCU = MCUArg->getValue();
- if (MCU.startswith("msp430i")) {
+ if (MCU.starts_with("msp430i")) {
// 'i' should be in lower case as it's defined in TI MSP430-GCC headers
CC1Args.push_back(DriverArgs.MakeArgString(
"-D__MSP430i" + MCU.drop_front(7).upper() + "__"));
diff --git a/clang/lib/Driver/ToolChains/MSVC.cpp b/clang/lib/Driver/ToolChains/MSVC.cpp
index 6d92555..8e1e951 100644
--- a/clang/lib/Driver/ToolChains/MSVC.cpp
+++ b/clang/lib/Driver/ToolChains/MSVC.cpp
@@ -302,7 +302,7 @@ void visualstudio::Linker::ConstructJob(Compilation &C, const JobAction &JA,
if (A.getOption().matches(options::OPT_l)) {
StringRef Lib = A.getValue();
const char *LinkLibArg;
- if (Lib.endswith(".lib"))
+ if (Lib.ends_with(".lib"))
LinkLibArg = Args.MakeArgString(Lib);
else
LinkLibArg = Args.MakeArgString(Lib + ".lib");
diff --git a/clang/lib/Driver/ToolChains/MinGW.cpp b/clang/lib/Driver/ToolChains/MinGW.cpp
index 5d7f867..65512f1 100644
--- a/clang/lib/Driver/ToolChains/MinGW.cpp
+++ b/clang/lib/Driver/ToolChains/MinGW.cpp
@@ -86,9 +86,9 @@ void tools::MinGW::Linker::AddLibGCC(const ArgList &Args,
CmdArgs.push_back("-lmoldname");
CmdArgs.push_back("-lmingwex");
for (auto Lib : Args.getAllArgValues(options::OPT_l))
- if (StringRef(Lib).startswith("msvcr") ||
- StringRef(Lib).startswith("ucrt") ||
- StringRef(Lib).startswith("crtdll"))
+ if (StringRef(Lib).starts_with("msvcr") ||
+ StringRef(Lib).starts_with("ucrt") ||
+ StringRef(Lib).starts_with("crtdll"))
return;
CmdArgs.push_back("-lmsvcrt");
}
diff --git a/clang/lib/Driver/ToolChains/PPCLinux.cpp b/clang/lib/Driver/ToolChains/PPCLinux.cpp
index bdbecae..0ed0f91 100644
--- a/clang/lib/Driver/ToolChains/PPCLinux.cpp
+++ b/clang/lib/Driver/ToolChains/PPCLinux.cpp
@@ -31,10 +31,10 @@ static bool GlibcSupportsFloat128(const std::string &Linker) {
// Since glibc 2.34, the installed .so file is not symlink anymore. But we can
// still safely assume it's newer than 2.32.
- if (LinkerName.startswith("ld64.so"))
+ if (LinkerName.starts_with("ld64.so"))
return true;
- if (!LinkerName.startswith("ld-2."))
+ if (!LinkerName.starts_with("ld-2."))
return false;
unsigned Minor = (LinkerName[5] - '0') * 10 + (LinkerName[6] - '0');
if (Minor < 32)
diff --git a/clang/lib/Driver/ToolChains/Solaris.cpp b/clang/lib/Driver/ToolChains/Solaris.cpp
index 485730d..9a9792d 100644
--- a/clang/lib/Driver/ToolChains/Solaris.cpp
+++ b/clang/lib/Driver/ToolChains/Solaris.cpp
@@ -328,7 +328,7 @@ Solaris::Solaris(const Driver &D, const llvm::Triple &Triple,
// If we are currently running Clang inside of the requested system root,
// add its parent library path to those searched.
- if (StringRef(D.Dir).startswith(D.SysRoot))
+ if (StringRef(D.Dir).starts_with(D.SysRoot))
addPathIfExists(D, D.Dir + "/../lib", Paths);
addPathIfExists(D, D.SysRoot + "/usr/lib" + LibSuffix, Paths);
diff --git a/clang/lib/Driver/ToolChains/WebAssembly.cpp b/clang/lib/Driver/ToolChains/WebAssembly.cpp
index f131b6c..57f4600 100644
--- a/clang/lib/Driver/ToolChains/WebAssembly.cpp
+++ b/clang/lib/Driver/ToolChains/WebAssembly.cpp
@@ -328,7 +328,7 @@ void WebAssembly::addClangTargetOptions(const ArgList &DriverArgs,
for (const Arg *A : DriverArgs.filtered(options::OPT_mllvm)) {
StringRef Opt = A->getValue(0);
- if (Opt.startswith("-emscripten-cxx-exceptions-allowed")) {
+ if (Opt.starts_with("-emscripten-cxx-exceptions-allowed")) {
// '-mllvm -emscripten-cxx-exceptions-allowed' should be used with
// '-mllvm -enable-emscripten-cxx-exceptions'
bool EmEHArgExists = false;
@@ -355,7 +355,7 @@ void WebAssembly::addClangTargetOptions(const ArgList &DriverArgs,
}
}
- if (Opt.startswith("-wasm-enable-sjlj")) {
+ if (Opt.starts_with("-wasm-enable-sjlj")) {
// '-mllvm -wasm-enable-sjlj' is not compatible with
// '-mno-exception-handling'
if (DriverArgs.hasFlag(options::OPT_mno_exception_handing,
diff --git a/clang/lib/Edit/Commit.cpp b/clang/lib/Edit/Commit.cpp
index 7c5aea6..6e785e8 100644
--- a/clang/lib/Edit/Commit.cpp
+++ b/clang/lib/Edit/Commit.cpp
@@ -334,7 +334,7 @@ bool Commit::canReplaceText(SourceLocation loc, StringRef text,
return false;
Len = text.size();
- return file.substr(Offs.getOffset()).startswith(text);
+ return file.substr(Offs.getOffset()).starts_with(text);
}
bool Commit::isAtStartOfMacroExpansion(SourceLocation loc,
diff --git a/clang/lib/Edit/RewriteObjCFoundationAPI.cpp b/clang/lib/Edit/RewriteObjCFoundationAPI.cpp
index adb34eb..d5bf553 100644
--- a/clang/lib/Edit/RewriteObjCFoundationAPI.cpp
+++ b/clang/lib/Edit/RewriteObjCFoundationAPI.cpp
@@ -697,7 +697,7 @@ static bool getLiteralInfo(SourceRange literalRange,
struct Suff {
static bool has(StringRef suff, StringRef &text) {
- if (text.endswith(suff)) {
+ if (text.ends_with(suff)) {
text = text.substr(0, text.size()-suff.size());
return true;
}
@@ -739,9 +739,9 @@ static bool getLiteralInfo(SourceRange literalRange,
Info.F = UpperF ? "F" : "f";
Info.Hex = Info.Octal = false;
- if (text.startswith("0x"))
+ if (text.starts_with("0x"))
Info.Hex = true;
- else if (!isFloat && !isIntZero && text.startswith("0"))
+ else if (!isFloat && !isIntZero && text.starts_with("0"))
Info.Octal = true;
SourceLocation B = literalRange.getBegin();
diff --git a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
index fe282df..fd62d84 100644
--- a/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
+++ b/clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
@@ -105,10 +105,10 @@ std::optional<std::string> getRelativeIncludeName(const CompilerInstance &CI,
// Special case Apple .sdk folders since the search path is typically a
// symlink like `iPhoneSimulator14.5.sdk` while the file is instead
// located in `iPhoneSimulator.sdk` (the real folder).
- if (NI->endswith(".sdk") && DI->endswith(".sdk")) {
+ if (NI->ends_with(".sdk") && DI->ends_with(".sdk")) {
StringRef NBasename = path::stem(*NI);
StringRef DBasename = path::stem(*DI);
- if (DBasename.startswith(NBasename))
+ if (DBasename.starts_with(NBasename))
continue;
}
diff --git a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
index d9675b0..53b2229 100644
--- a/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
+++ b/clang/lib/ExtractAPI/Serialization/SymbolGraphSerializer.cpp
@@ -743,7 +743,7 @@ bool SymbolGraphSerializer::shouldSkip(const APIRecord &Record) const {
// Filter out symbols prefixed with an underscored as they are understood to
// be symbols clients should not use.
- if (Record.Name.startswith("_"))
+ if (Record.Name.starts_with("_"))
return true;
return false;
diff --git a/clang/lib/Format/BreakableToken.cpp b/clang/lib/Format/BreakableToken.cpp
index 954eeb9..473908e 100644
--- a/clang/lib/Format/BreakableToken.cpp
+++ b/clang/lib/Format/BreakableToken.cpp
@@ -55,7 +55,7 @@ static StringRef getLineCommentIndentPrefix(StringRef Comment,
}));
for (StringRef KnownPrefix : KnownPrefixes) {
- if (Comment.startswith(KnownPrefix)) {
+ if (Comment.starts_with(KnownPrefix)) {
const auto PrefixLength =
Comment.find_first_not_of(' ', KnownPrefix.size());
return Comment.substr(0, PrefixLength);
@@ -220,8 +220,8 @@ bool switchesFormatting(const FormatToken &Token) {
assert((Token.is(TT_BlockComment) || Token.is(TT_LineComment)) &&
"formatting regions are switched by comment tokens");
StringRef Content = Token.TokenText.substr(2).ltrim();
- return Content.startswith("clang-format on") ||
- Content.startswith("clang-format off");
+ return Content.starts_with("clang-format on") ||
+ Content.starts_with("clang-format off");
}
unsigned
@@ -271,7 +271,7 @@ BreakableStringLiteral::BreakableStringLiteral(
: BreakableToken(Tok, InPPDirective, Encoding, Style),
StartColumn(StartColumn), Prefix(Prefix), Postfix(Postfix),
UnbreakableTailLength(UnbreakableTailLength) {
- assert(Tok.TokenText.startswith(Prefix) && Tok.TokenText.endswith(Postfix));
+ assert(Tok.TokenText.starts_with(Prefix) && Tok.TokenText.ends_with(Postfix));
Line = Tok.TokenText.substr(
Prefix.size(), Tok.TokenText.size() - Prefix.size() - Postfix.size());
}
@@ -454,7 +454,7 @@ static bool mayReflowContent(StringRef Content) {
bool hasSpecialMeaningPrefix = false;
for (StringRef Prefix :
{"@", "TODO", "FIXME", "XXX", "-# ", "- ", "+ ", "* "}) {
- if (Content.startswith(Prefix)) {
+ if (Content.starts_with(Prefix)) {
hasSpecialMeaningPrefix = true;
break;
}
@@ -471,7 +471,7 @@ static bool mayReflowContent(StringRef Content) {
// characters and either the first or second character must be
// non-punctuation.
return Content.size() >= 2 && !hasSpecialMeaningPrefix &&
- !Content.endswith("\\") &&
+ !Content.ends_with("\\") &&
// Note that this is UTF-8 safe, since if isPunctuation(Content[0]) is
// true, then the first code point must be 1 byte long.
(!isPunctuation(Content[0]) || !isPunctuation(Content[1]));
@@ -488,7 +488,7 @@ BreakableBlockComment::BreakableBlockComment(
"block comment section must start with a block comment");
StringRef TokenText(Tok.TokenText);
- assert(TokenText.startswith("/*") && TokenText.endswith("*/"));
+ assert(TokenText.starts_with("/*") && TokenText.ends_with("*/"));
TokenText.substr(2, TokenText.size() - 4)
.split(Lines, UseCRLF ? "\r\n" : "\n");
@@ -511,7 +511,7 @@ BreakableBlockComment::BreakableBlockComment(
// /*
// ** blah blah blah
// */
- if (Lines.size() >= 2 && Content[1].startswith("**") &&
+ if (Lines.size() >= 2 && Content[1].starts_with("**") &&
static_cast<unsigned>(ContentColumn[1]) == StartColumn) {
DecorationColumn = StartColumn;
}
@@ -531,10 +531,10 @@ BreakableBlockComment::BreakableBlockComment(
// If the last line is empty, the closing "*/" will have a star.
if (Text.empty())
break;
- } else if (!Text.empty() && Decoration.startswith(Text)) {
+ } else if (!Text.empty() && Decoration.starts_with(Text)) {
continue;
}
- while (!Text.startswith(Decoration))
+ while (!Text.starts_with(Decoration))
Decoration = Decoration.drop_back(1);
}
@@ -562,13 +562,13 @@ BreakableBlockComment::BreakableBlockComment(
// The last line excludes the star if LastLineNeedsDecoration is false.
// For all other lines, adjust the line to exclude the star and
// (optionally) the first whitespace.
- unsigned DecorationSize = Decoration.startswith(Content[i])
+ unsigned DecorationSize = Decoration.starts_with(Content[i])
? Content[i].size()
: Decoration.size();
if (DecorationSize)
ContentColumn[i] = DecorationColumn + DecorationSize;
Content[i] = Content[i].substr(DecorationSize);
- if (!Decoration.startswith(Content[i])) {
+ if (!Decoration.starts_with(Content[i])) {
IndentAtLineBreak =
std::min<int>(IndentAtLineBreak, std::max(0, ContentColumn[i]));
}
@@ -577,10 +577,10 @@ BreakableBlockComment::BreakableBlockComment(
// Detect a multiline jsdoc comment and set DelimitersOnNewline in that case.
if (Style.isJavaScript() || Style.Language == FormatStyle::LK_Java) {
- if ((Lines[0] == "*" || Lines[0].startswith("* ")) && Lines.size() > 1) {
+ if ((Lines[0] == "*" || Lines[0].starts_with("* ")) && Lines.size() > 1) {
// This is a multiline jsdoc comment.
DelimitersOnNewline = true;
- } else if (Lines[0].startswith("* ") && Lines.size() == 1) {
+ } else if (Lines[0].starts_with("* ") && Lines.size() == 1) {
// Detect a long single-line comment, like:
// /** long long long */
// Below, '2' is the width of '*/'.
@@ -612,7 +612,7 @@ BreakableToken::Split BreakableBlockComment::getSplit(
return Split(StringRef::npos, 0);
return getCommentSplit(Content[LineIndex].substr(TailOffset),
ContentStartColumn, ColumnLimit, Style.TabWidth,
- Encoding, Style, Decoration.endswith("*"));
+ Encoding, Style, Decoration.ends_with("*"));
}
void BreakableBlockComment::adjustWhitespace(unsigned LineIndex,
@@ -623,7 +623,7 @@ void BreakableBlockComment::adjustWhitespace(unsigned LineIndex,
// trimming the trailing whitespace. The backslash will be re-added later when
// inserting a line break.
size_t EndOfPreviousLine = Lines[LineIndex - 1].size();
- if (InPPDirective && Lines[LineIndex - 1].endswith("\\"))
+ if (InPPDirective && Lines[LineIndex - 1].ends_with("\\"))
--EndOfPreviousLine;
// Calculate the end of the non-whitespace text in the previous line.
@@ -672,7 +672,7 @@ unsigned BreakableBlockComment::getRemainingLength(unsigned LineIndex,
// We never need a decoration when breaking just the trailing "*/" postfix.
bool HasRemainingText = Offset < Content[LineIndex].size();
if (!HasRemainingText) {
- bool HasDecoration = Lines[LineIndex].ltrim().startswith(Decoration);
+ bool HasDecoration = Lines[LineIndex].ltrim().starts_with(Decoration);
if (HasDecoration)
LineLength -= Decoration.size();
}
@@ -700,7 +700,7 @@ unsigned BreakableBlockComment::getContentIndent(unsigned LineIndex) const {
// /** line 0 */
// is "* line 0", so we need to skip over the decoration in that case.
StringRef ContentWithNoDecoration = Content[LineIndex];
- if (LineIndex == 0 && ContentWithNoDecoration.startswith("*"))
+ if (LineIndex == 0 && ContentWithNoDecoration.starts_with("*"))
ContentWithNoDecoration = ContentWithNoDecoration.substr(1).ltrim(Blanks);
StringRef FirstWord = ContentWithNoDecoration.substr(
0, ContentWithNoDecoration.find_first_of(Blanks));
@@ -853,7 +853,7 @@ bool BreakableBlockComment::mayReflow(
// Content[LineIndex] may exclude the indent after the '*' decoration. In that
// case, we compute the start of the comment pragma manually.
StringRef IndentContent = Content[LineIndex];
- if (Lines[LineIndex].ltrim(Blanks).startswith("*"))
+ if (Lines[LineIndex].ltrim(Blanks).starts_with("*"))
IndentContent = Lines[LineIndex].ltrim(Blanks).substr(1);
return LineIndex > 0 && !CommentPragmasRegex.match(IndentContent) &&
mayReflowContent(Content[LineIndex]) && !Tok.Finalized &&
@@ -876,7 +876,7 @@ BreakableLineCommentSection::BreakableLineCommentSection(
CurrentTok = CurrentTok->Next) {
LastLineTok = LineTok;
StringRef TokenText(CurrentTok->TokenText);
- assert((TokenText.startswith("//") || TokenText.startswith("#")) &&
+ assert((TokenText.starts_with("//") || TokenText.starts_with("#")) &&
"unsupported line comment prefix, '//' and '#' are supported");
size_t FirstLineIndex = Lines.size();
TokenText.split(Lines, "\n");
@@ -913,7 +913,7 @@ BreakableLineCommentSection::BreakableLineCommentSection(
// #########
// # section
// #########
- if (FirstCommentChar == '#' && !TokenText.startswith("#"))
+ if (FirstCommentChar == '#' && !TokenText.starts_with("#"))
return false;
return FirstCommentChar == '\\' || isPunctuation(FirstCommentChar) ||
isHorizontalWhitespace(FirstCommentChar);
@@ -1152,7 +1152,7 @@ bool BreakableLineCommentSection::mayReflow(
// Line comments have the indent as part of the prefix, so we need to
// recompute the start of the line.
StringRef IndentContent = Content[LineIndex];
- if (Lines[LineIndex].startswith("//"))
+ if (Lines[LineIndex].starts_with("//"))
IndentContent = Lines[LineIndex].substr(2);
// FIXME: Decide whether we want to reflow non-regular indents:
// Currently, we only reflow when the OriginalPrefix[LineIndex] matches the
diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp
index 9e4e939..bd319f2 100644
--- a/clang/lib/Format/ContinuationIndenter.cpp
+++ b/clang/lib/Format/ContinuationIndenter.cpp
@@ -161,7 +161,7 @@ static bool opensProtoMessageField(const FormatToken &LessTok,
// string. For example, the delimiter of R"deli(cont)deli" is deli.
static std::optional<StringRef> getRawStringDelimiter(StringRef TokenText) {
if (TokenText.size() < 5 // The smallest raw string possible is 'R"()"'.
- || !TokenText.startswith("R\"") || !TokenText.endswith("\"")) {
+ || !TokenText.starts_with("R\"") || !TokenText.ends_with("\"")) {
return std::nullopt;
}
@@ -177,7 +177,7 @@ static std::optional<StringRef> getRawStringDelimiter(StringRef TokenText) {
size_t RParenPos = TokenText.size() - Delimiter.size() - 2;
if (TokenText[RParenPos] != ')')
return std::nullopt;
- if (!TokenText.substr(RParenPos + 1).startswith(Delimiter))
+ if (!TokenText.substr(RParenPos + 1).starts_with(Delimiter))
return std::nullopt;
return Delimiter;
}
@@ -608,7 +608,7 @@ bool ContinuationIndenter::mustBreak(const LineState &State) {
if (Current.is(tok::lessless) &&
((Previous.is(tok::identifier) && Previous.TokenText == "endl") ||
- (Previous.Tok.isLiteral() && (Previous.TokenText.endswith("\\n\"") ||
+ (Previous.Tok.isLiteral() && (Previous.TokenText.ends_with("\\n\"") ||
Previous.TokenText == "\'\\n\'")))) {
return true;
}
@@ -2293,12 +2293,13 @@ ContinuationIndenter::createBreakableToken(const FormatToken &Current,
if (Style.isVerilog() || Style.Language == FormatStyle::LK_Java ||
Style.isJavaScript() || Style.isCSharp()) {
BreakableStringLiteralUsingOperators::QuoteStyleType QuoteStyle;
- if (Style.isJavaScript() && Text.startswith("'") && Text.endswith("'")) {
+ if (Style.isJavaScript() && Text.starts_with("'") &&
+ Text.ends_with("'")) {
QuoteStyle = BreakableStringLiteralUsingOperators::SingleQuotes;
- } else if (Style.isCSharp() && Text.startswith("@\"") &&
- Text.endswith("\"")) {
+ } else if (Style.isCSharp() && Text.starts_with("@\"") &&
+ Text.ends_with("\"")) {
QuoteStyle = BreakableStringLiteralUsingOperators::AtDoubleQuotes;
- } else if (Text.startswith("\"") && Text.endswith("\"")) {
+ } else if (Text.starts_with("\"") && Text.ends_with("\"")) {
QuoteStyle = BreakableStringLiteralUsingOperators::DoubleQuotes;
} else {
return nullptr;
@@ -2315,12 +2316,14 @@ ContinuationIndenter::createBreakableToken(const FormatToken &Current,
// FIXME: Store Prefix and Suffix (or PrefixLength and SuffixLength to
// reduce the overhead) for each FormatToken, which is a string, so that we
// don't run multiple checks here on the hot path.
- if ((Text.endswith(Postfix = "\"") &&
- (Text.startswith(Prefix = "@\"") || Text.startswith(Prefix = "\"") ||
- Text.startswith(Prefix = "u\"") || Text.startswith(Prefix = "U\"") ||
- Text.startswith(Prefix = "u8\"") ||
- Text.startswith(Prefix = "L\""))) ||
- (Text.startswith(Prefix = "_T(\"") && Text.endswith(Postfix = "\")"))) {
+ if ((Text.ends_with(Postfix = "\"") &&
+ (Text.starts_with(Prefix = "@\"") || Text.starts_with(Prefix = "\"") ||
+ Text.starts_with(Prefix = "u\"") ||
+ Text.starts_with(Prefix = "U\"") ||
+ Text.starts_with(Prefix = "u8\"") ||
+ Text.starts_with(Prefix = "L\""))) ||
+ (Text.starts_with(Prefix = "_T(\"") &&
+ Text.ends_with(Postfix = "\")"))) {
return std::make_unique<BreakableStringLiteral>(
Current, StartColumn, Prefix, Postfix, UnbreakableTailLength,
State.Line->InPPDirective, Encoding, Style);
@@ -2342,7 +2345,7 @@ ContinuationIndenter::createBreakableToken(const FormatToken &Current,
bool RegularComments = [&]() {
for (const FormatToken *T = &Current; T && T->is(TT_LineComment);
T = T->Next) {
- if (!(T->TokenText.startswith("//") || T->TokenText.startswith("#")))
+ if (!(T->TokenText.starts_with("//") || T->TokenText.starts_with("#")))
return false;
}
return true;
@@ -2754,7 +2757,7 @@ bool ContinuationIndenter::nextIsMultilineString(const LineState &State) {
// We never consider raw string literals "multiline" for the purpose of
// AlwaysBreakBeforeMultilineStrings implementation as they are special-cased
// (see TokenAnnotator::mustBreakBefore().
- if (Current.TokenText.startswith("R\""))
+ if (Current.TokenText.starts_with("R\""))
return false;
if (Current.IsMultiline)
return true;
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 8feee74..668e959 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -2346,9 +2346,9 @@ private:
// NB: testing for not starting with a double quote to avoid
// breaking `template strings`.
(Style.JavaScriptQuotes == FormatStyle::JSQS_Single &&
- !Input.startswith("\"")) ||
+ !Input.starts_with("\"")) ||
(Style.JavaScriptQuotes == FormatStyle::JSQS_Double &&
- !Input.startswith("\'"))) {
+ !Input.starts_with("\'"))) {
continue;
}
@@ -2932,7 +2932,7 @@ private:
};
for (auto *Line : AnnotatedLines) {
- if (Line->First && (Line->First->TokenText.startswith("#") ||
+ if (Line->First && (Line->First->TokenText.starts_with("#") ||
Line->First->TokenText == "__pragma" ||
Line->First->TokenText == "_Pragma")) {
continue;
@@ -3217,7 +3217,7 @@ tooling::Replacements sortCppIncludes(const FormatStyle &Style, StringRef Code,
Style.IncludeStyle.IncludeBlocks ==
tooling::IncludeStyle::IBS_Regroup);
- bool MergeWithNextLine = Trimmed.endswith("\\");
+ bool MergeWithNextLine = Trimmed.ends_with("\\");
if (!FormattingOff && !MergeWithNextLine) {
if (tooling::HeaderIncludes::IncludeRegex.match(Line, &Matches)) {
StringRef IncludeName = Matches[2];
@@ -3243,7 +3243,7 @@ tooling::Replacements sortCppIncludes(const FormatStyle &Style, StringRef Code,
sortCppIncludes(Style, IncludesInBlock, Ranges, FileName, Code,
Replaces, Cursor);
IncludesInBlock.clear();
- if (Trimmed.startswith("#pragma hdrstop")) // Precompiled headers.
+ if (Trimmed.starts_with("#pragma hdrstop")) // Precompiled headers.
FirstIncludeBlock = true;
else
FirstIncludeBlock = false;
@@ -3271,7 +3271,7 @@ static unsigned findJavaImportGroup(const FormatStyle &Style,
unsigned LongestMatchLength = 0;
for (unsigned I = 0; I < Style.JavaImportGroups.size(); I++) {
const std::string &GroupPrefix = Style.JavaImportGroups[I];
- if (ImportIdentifier.startswith(GroupPrefix) &&
+ if (ImportIdentifier.starts_with(GroupPrefix) &&
GroupPrefix.length() > LongestMatchLength) {
LongestMatchIndex = I;
LongestMatchLength = GroupPrefix.length();
@@ -3426,7 +3426,7 @@ bool isMpegTS(StringRef Code) {
return Code.size() > 188 && Code[0] == 0x47 && Code[188] == 0x47;
}
-bool isLikelyXml(StringRef Code) { return Code.ltrim().startswith("<"); }
+bool isLikelyXml(StringRef Code) { return Code.ltrim().starts_with("<"); }
tooling::Replacements sortIncludes(const FormatStyle &Style, StringRef Code,
ArrayRef<tooling::Range> Ranges,
@@ -3538,7 +3538,7 @@ fixCppIncludeInsertions(StringRef Code, const tooling::Replacements &Replaces,
for (const auto &Header : HeadersToDelete) {
tooling::Replacements Replaces =
- Includes.remove(Header.trim("\"<>"), Header.startswith("<"));
+ Includes.remove(Header.trim("\"<>"), Header.starts_with("<"));
for (const auto &R : Replaces) {
auto Err = Result.add(R);
if (Err) {
@@ -3560,7 +3560,7 @@ fixCppIncludeInsertions(StringRef Code, const tooling::Replacements &Replaces,
(void)Matched;
auto IncludeName = Matches[2];
auto Replace =
- Includes.insert(IncludeName.trim("\"<>"), IncludeName.startswith("<"),
+ Includes.insert(IncludeName.trim("\"<>"), IncludeName.starts_with("<"),
tooling::IncludeDirective::Include);
if (Replace) {
auto Err = Result.add(*Replace);
@@ -3882,14 +3882,14 @@ const char *StyleOptionHelpDescription =
" --style=\"{BasedOnStyle: llvm, IndentWidth: 8}\"";
static FormatStyle::LanguageKind getLanguageByFileName(StringRef FileName) {
- if (FileName.endswith(".java"))
+ if (FileName.ends_with(".java"))
return FormatStyle::LK_Java;
if (FileName.ends_with_insensitive(".js") ||
FileName.ends_with_insensitive(".mjs") ||
FileName.ends_with_insensitive(".ts")) {
return FormatStyle::LK_JavaScript; // (module) JavaScript or TypeScript.
}
- if (FileName.endswith(".m") || FileName.endswith(".mm"))
+ if (FileName.ends_with(".m") || FileName.ends_with(".mm"))
return FormatStyle::LK_ObjC;
if (FileName.ends_with_insensitive(".proto") ||
FileName.ends_with_insensitive(".protodevel")) {
@@ -3963,7 +3963,7 @@ llvm::Expected<FormatStyle> getStyle(StringRef StyleName, StringRef FileName,
llvm::SmallVector<std::unique_ptr<llvm::MemoryBuffer>, 1>
ChildFormatTextToApply;
- if (StyleName.startswith("{")) {
+ if (StyleName.starts_with("{")) {
// Parse YAML/JSON style from the command line.
StringRef Source = "<command-line>";
if (std::error_code ec =
@@ -4123,7 +4123,7 @@ static bool isClangFormatOnOff(StringRef Comment, bool On) {
static const char ClangFormatOff[] = "// clang-format off";
const unsigned Size = (On ? sizeof ClangFormatOn : sizeof ClangFormatOff) - 1;
- return Comment.startswith(On ? ClangFormatOn : ClangFormatOff) &&
+ return Comment.starts_with(On ? ClangFormatOn : ClangFormatOff) &&
(Comment.size() == Size || Comment[Size] == ':');
}
diff --git a/clang/lib/Format/FormatToken.h b/clang/lib/Format/FormatToken.h
index 14a3c21..3f9664f 100644
--- a/clang/lib/Format/FormatToken.h
+++ b/clang/lib/Format/FormatToken.h
@@ -667,7 +667,7 @@ public:
/// Returns whether \p Tok is ([{ or an opening < of a template or in
/// protos.
bool opensScope() const {
- if (is(TT_TemplateString) && TokenText.endswith("${"))
+ if (is(TT_TemplateString) && TokenText.ends_with("${"))
return true;
if (is(TT_DictLiteral) && is(tok::less))
return true;
@@ -677,7 +677,7 @@ public:
/// Returns whether \p Tok is )]} or a closing > of a template or in
/// protos.
bool closesScope() const {
- if (is(TT_TemplateString) && TokenText.startswith("}"))
+ if (is(TT_TemplateString) && TokenText.starts_with("}"))
return true;
if (is(TT_DictLiteral) && is(tok::greater))
return true;
@@ -743,9 +743,9 @@ public:
if (isNot(tok::string_literal))
return false;
StringRef Content = TokenText;
- if (Content.startswith("\"") || Content.startswith("'"))
+ if (Content.starts_with("\"") || Content.starts_with("'"))
Content = Content.drop_front(1);
- if (Content.endswith("\"") || Content.endswith("'"))
+ if (Content.ends_with("\"") || Content.ends_with("'"))
Content = Content.drop_back(1);
Content = Content.trim();
return Content.size() > 1 &&
@@ -1823,7 +1823,7 @@ private:
};
inline bool isLineComment(const FormatToken &FormatTok) {
- return FormatTok.is(tok::comment) && !FormatTok.TokenText.startswith("/*");
+ return FormatTok.is(tok::comment) && !FormatTok.TokenText.starts_with("/*");
}
// Checks if \p FormatTok is a line comment that continues the line comment
diff --git a/clang/lib/Format/FormatTokenLexer.cpp b/clang/lib/Format/FormatTokenLexer.cpp
index e4e32e2..6143028 100644
--- a/clang/lib/Format/FormatTokenLexer.cpp
+++ b/clang/lib/Format/FormatTokenLexer.cpp
@@ -711,12 +711,12 @@ void FormatTokenLexer::handleCSharpVerbatimAndInterpolatedStrings() {
bool Verbatim = false;
bool Interpolated = false;
- if (TokenText.startswith(R"($@")") || TokenText.startswith(R"(@$")")) {
+ if (TokenText.starts_with(R"($@")") || TokenText.starts_with(R"(@$")")) {
Verbatim = true;
Interpolated = true;
- } else if (TokenText.startswith(R"(@")")) {
+ } else if (TokenText.starts_with(R"(@")")) {
Verbatim = true;
- } else if (TokenText.startswith(R"($")")) {
+ } else if (TokenText.starts_with(R"($")")) {
Interpolated = true;
}
@@ -1110,7 +1110,7 @@ FormatToken *FormatTokenLexer::getNextToken() {
// the comment token at the backslash, and resets the lexer to restart behind
// the backslash.
if ((Style.isJavaScript() || Style.Language == FormatStyle::LK_Java) &&
- FormatTok->is(tok::comment) && FormatTok->TokenText.startswith("//")) {
+ FormatTok->is(tok::comment) && FormatTok->TokenText.starts_with("//")) {
size_t BackslashPos = FormatTok->TokenText.find('\\');
while (BackslashPos != StringRef::npos) {
if (BackslashPos + 1 < FormatTok->TokenText.size() &&
diff --git a/clang/lib/Format/SortJavaScriptImports.cpp b/clang/lib/Format/SortJavaScriptImports.cpp
index 8c6722e..1a6a1b1 100644
--- a/clang/lib/Format/SortJavaScriptImports.cpp
+++ b/clang/lib/Format/SortJavaScriptImports.cpp
@@ -468,10 +468,10 @@ private:
// URL = TokenText without the quotes.
Reference.URL =
Current->TokenText.substr(1, Current->TokenText.size() - 2);
- if (Reference.URL.startswith("..")) {
+ if (Reference.URL.starts_with("..")) {
Reference.Category =
JsModuleReference::ReferenceCategory::RELATIVE_PARENT;
- } else if (Reference.URL.startswith(".")) {
+ } else if (Reference.URL.starts_with(".")) {
Reference.Category = JsModuleReference::ReferenceCategory::RELATIVE;
} else {
Reference.Category = JsModuleReference::ReferenceCategory::ABSOLUTE;
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index eaccb58..febd683 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -1307,7 +1307,7 @@ private:
if (Previous->isOneOf(TT_BinaryOperator, TT_UnaryOperator, tok::comma,
tok::star, tok::arrow, tok::amp, tok::ampamp) ||
// User defined literal.
- Previous->TokenText.startswith("\"\"")) {
+ Previous->TokenText.starts_with("\"\"")) {
Previous->setType(TT_OverloadedOperator);
if (CurrentToken->isOneOf(tok::less, tok::greater))
break;
@@ -1466,7 +1466,7 @@ private:
// Mark tokens up to the trailing line comments as implicit string
// literals.
if (CurrentToken->isNot(tok::comment) &&
- !CurrentToken->TokenText.startswith("//")) {
+ !CurrentToken->TokenText.starts_with("//")) {
CurrentToken->setType(TT_ImplicitStringLiteral);
}
next();
@@ -2077,8 +2077,8 @@ private:
}
Current.setType(TT_BinaryOperator);
} else if (Current.is(tok::comment)) {
- if (Current.TokenText.startswith("/*")) {
- if (Current.TokenText.endswith("*/")) {
+ if (Current.TokenText.starts_with("/*")) {
+ if (Current.TokenText.ends_with("*/")) {
Current.setType(TT_BlockComment);
} else {
// The lexer has for some reason determined a comment here. But we
@@ -3724,8 +3724,8 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
return 100;
if (Left.is(TT_JsTypeColon))
return 35;
- if ((Left.is(TT_TemplateString) && Left.TokenText.endswith("${")) ||
- (Right.is(TT_TemplateString) && Right.TokenText.startswith("}"))) {
+ if ((Left.is(TT_TemplateString) && Left.TokenText.ends_with("${")) ||
+ (Right.is(TT_TemplateString) && Right.TokenText.starts_with("}"))) {
return 100;
}
// Prefer breaking call chains (".foo") over empty "{}", "[]" or "()".
@@ -4224,7 +4224,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
}
if (Left.is(TT_BlockComment)) {
// No whitespace in x(/*foo=*/1), except for JavaScript.
- return Style.isJavaScript() || !Left.TokenText.endswith("=*/");
+ return Style.isJavaScript() || !Left.TokenText.ends_with("=*/");
}
// Space between template and attribute.
@@ -4572,8 +4572,8 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
if (Next && Next->is(TT_FatArrow))
return true;
}
- if ((Left.is(TT_TemplateString) && Left.TokenText.endswith("${")) ||
- (Right.is(TT_TemplateString) && Right.TokenText.startswith("}"))) {
+ if ((Left.is(TT_TemplateString) && Left.TokenText.ends_with("${")) ||
+ (Right.is(TT_TemplateString) && Right.TokenText.starts_with("}"))) {
return false;
}
// In tagged template literals ("html`bar baz`"), there is no space between
@@ -5212,7 +5212,7 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
Left.is(TT_InheritanceComma)) {
return true;
}
- if (Right.is(tok::string_literal) && Right.TokenText.startswith("R\"")) {
+ if (Right.is(tok::string_literal) && Right.TokenText.starts_with("R\"")) {
// Multiline raw string literals are special wrt. line breaks. The author
// has made a deliberate choice and might have aligned the contents of the
// string literal accordingly. Thus, we try keep existing line breaks.
diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp
index 57126b8..c38b4c8 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -1333,7 +1333,7 @@ bool UnwrappedLineParser::parseModuleImport() {
// Mark tokens up to the trailing line comments as implicit string
// literals.
if (FormatTok->isNot(tok::comment) &&
- !FormatTok->TokenText.startswith("//")) {
+ !FormatTok->TokenText.starts_with("//")) {
FormatTok->setFinalizedType(TT_ImplicitStringLiteral);
}
nextToken();
@@ -1371,7 +1371,7 @@ void UnwrappedLineParser::readTokenWithJavaScriptASI() {
bool PreviousMustBeValue = mustBeJSIdentOrValue(Keywords, Previous);
bool PreviousStartsTemplateExpr =
- Previous->is(TT_TemplateString) && Previous->TokenText.endswith("${");
+ Previous->is(TT_TemplateString) && Previous->TokenText.ends_with("${");
if (PreviousMustBeValue || Previous->is(tok::r_paren)) {
// If the line contains an '@' sign, the previous token might be an
// annotation, which can precede another identifier/value.
@@ -1385,7 +1385,7 @@ void UnwrappedLineParser::readTokenWithJavaScriptASI() {
return addUnwrappedLine();
bool NextMustBeValue = mustBeJSIdentOrValue(Keywords, Next);
bool NextEndsTemplateExpr =
- Next->is(TT_TemplateString) && Next->TokenText.startswith("}");
+ Next->is(TT_TemplateString) && Next->TokenText.starts_with("}");
if (NextMustBeValue && !NextEndsTemplateExpr && !PreviousStartsTemplateExpr &&
(PreviousMustBeValue ||
Previous->isOneOf(tok::r_square, tok::r_paren, tok::plusplus,
@@ -4459,8 +4459,8 @@ continuesLineCommentSection(const FormatToken &FormatTok,
return false;
StringRef IndentContent = FormatTok.TokenText;
- if (FormatTok.TokenText.startswith("//") ||
- FormatTok.TokenText.startswith("/*")) {
+ if (FormatTok.TokenText.starts_with("//") ||
+ FormatTok.TokenText.starts_with("/*")) {
IndentContent = FormatTok.TokenText.substr(2);
}
if (CommentPragmasRegex.match(IndentContent))
diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp
index b33bdad..11f3f2c 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2829,7 +2829,7 @@ static bool ParseFrontendArgs(FrontendOptions &Opts, ArgList &Args,
"-interface-stub-version=ifs-v1"
<< ErrorMessage;
ProgramAction = frontend::ParseSyntaxOnly;
- } else if (!ArgStr.startswith("ifs-")) {
+ } else if (!ArgStr.starts_with("ifs-")) {
std::string ErrorMessage =
"Invalid interface stub format: " + ArgStr.str() + ".";
Diags.Report(diag::err_drv_invalid_value)
@@ -4106,13 +4106,13 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args,
// Check the version number is valid: either 3.x (0 <= x <= 9) or
// y or y.0 (4 <= y <= current version).
- if (!VerParts.first.startswith("0") &&
- !VerParts.first.getAsInteger(10, Major) &&
- 3 <= Major && Major <= CLANG_VERSION_MAJOR &&
- (Major == 3 ? VerParts.second.size() == 1 &&
- !VerParts.second.getAsInteger(10, Minor)
- : VerParts.first.size() == Ver.size() ||
- VerParts.second == "0")) {
+ if (!VerParts.first.starts_with("0") &&
+ !VerParts.first.getAsInteger(10, Major) && 3 <= Major &&
+ Major <= CLANG_VERSION_MAJOR &&
+ (Major == 3
+ ? VerParts.second.size() == 1 &&
+ !VerParts.second.getAsInteger(10, Minor)
+ : VerParts.first.size() == Ver.size() || VerParts.second == "0")) {
// Got a valid version number.
if (Major == 3 && Minor <= 8)
Opts.setClangABICompat(LangOptions::ClangABI::Ver3_8);
diff --git a/clang/lib/Frontend/DependencyGraph.cpp b/clang/lib/Frontend/DependencyGraph.cpp
index 6aad043..e96669f 100644
--- a/clang/lib/Frontend/DependencyGraph.cpp
+++ b/clang/lib/Frontend/DependencyGraph.cpp
@@ -110,7 +110,7 @@ void DependencyGraphCallback::OutputGraphFile() {
writeNodeReference(OS, AllFiles[I]);
OS << " [ shape=\"box\", label=\"";
StringRef FileName = AllFiles[I].getName();
- if (FileName.startswith(SysRoot))
+ if (FileName.starts_with(SysRoot))
FileName = FileName.substr(SysRoot.size());
OS << DOT::EscapeString(std::string(FileName)) << "\"];\n";
diff --git a/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp b/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
index 2c3a253..b6b3746 100644
--- a/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
+++ b/clang/lib/Frontend/Rewrite/InclusionRewriter.cpp
@@ -307,7 +307,7 @@ void InclusionRewriter::OutputContentUpTo(const MemoryBufferRef &FromFile,
Rest = Rest.substr(Idx);
}
}
- if (EnsureNewline && !TextToWrite.endswith(LocalEOL))
+ if (EnsureNewline && !TextToWrite.ends_with(LocalEOL))
OS << MainEOL;
WriteFrom = WriteTo;
diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
index ab8174f..09c1460 100644
--- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
+++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
@@ -226,10 +226,10 @@ public:
P = C;
while (P < End) {
StringRef S(P, End - P);
- if (S.startswith(OpenBrace)) {
+ if (S.starts_with(OpenBrace)) {
++Depth;
P += OpenBrace.size();
- } else if (S.startswith(CloseBrace)) {
+ } else if (S.starts_with(CloseBrace)) {
--Depth;
if (Depth == 0) {
PEnd = P + CloseBrace.size();
@@ -445,7 +445,7 @@ static bool ParseDirective(StringRef S, ExpectedData *ED, SourceManager &SM,
// others.
// Regex in initial directive token: -re
- if (DToken.endswith("-re")) {
+ if (DToken.ends_with("-re")) {
D.RegexKind = true;
KindStr = "regex";
DToken = DToken.substr(0, DToken.size()-3);
@@ -454,20 +454,19 @@ static bool ParseDirective(StringRef S, ExpectedData *ED, SourceManager &SM,
// Type in initial directive token: -{error|warning|note|no-diagnostics}
bool NoDiag = false;
StringRef DType;
- if (DToken.endswith(DType="-error"))
+ if (DToken.ends_with(DType = "-error"))
D.DL = ED ? &ED->Errors : nullptr;
- else if (DToken.endswith(DType="-warning"))
+ else if (DToken.ends_with(DType = "-warning"))
D.DL = ED ? &ED->Warnings : nullptr;
- else if (DToken.endswith(DType="-remark"))
+ else if (DToken.ends_with(DType = "-remark"))
D.DL = ED ? &ED->Remarks : nullptr;
- else if (DToken.endswith(DType="-note"))
+ else if (DToken.ends_with(DType = "-note"))
D.DL = ED ? &ED->Notes : nullptr;
- else if (DToken.endswith(DType="-no-diagnostics")) {
+ else if (DToken.ends_with(DType = "-no-diagnostics")) {
NoDiag = true;
if (D.RegexKind)
continue;
- }
- else
+ } else
continue;
DToken = DToken.substr(0, DToken.size()-DType.size());
@@ -1145,7 +1144,7 @@ std::unique_ptr<Directive> Directive::create(bool RegexKind,
std::string RegexStr;
StringRef S = Text;
while (!S.empty()) {
- if (S.startswith("{{")) {
+ if (S.starts_with("{{")) {
S = S.drop_front(2);
size_t RegexMatchLength = S.find("}}");
assert(RegexMatchLength != StringRef::npos);
diff --git a/clang/lib/Index/IndexSymbol.cpp b/clang/lib/Index/IndexSymbol.cpp
index c67810a..0f79694 100644
--- a/clang/lib/Index/IndexSymbol.cpp
+++ b/clang/lib/Index/IndexSymbol.cpp
@@ -36,7 +36,7 @@ static bool isUnitTest(const ObjCMethodDecl *D) {
return false;
if (!D->getReturnType()->isVoidType())
return false;
- if (!D->getSelector().getNameForSlot(0).startswith("test"))
+ if (!D->getSelector().getNameForSlot(0).starts_with("test"))
return false;
return isUnitTestCase(D->getClassInterface());
}
diff --git a/clang/lib/IndexSerialization/SerializablePathCollection.cpp b/clang/lib/IndexSerialization/SerializablePathCollection.cpp
index bd5f861..74ed18a 100644
--- a/clang/lib/IndexSerialization/SerializablePathCollection.cpp
+++ b/clang/lib/IndexSerialization/SerializablePathCollection.cpp
@@ -70,11 +70,11 @@ PathPool::DirPath SerializablePathCollection::tryStoreDirPath(StringRef Dir) {
const std::string OrigDir = Dir.str();
PathPool::RootDirKind Root = PathPool::RootDirKind::Regular;
- if (!SysRoot.empty() && Dir.startswith(SysRoot) &&
+ if (!SysRoot.empty() && Dir.starts_with(SysRoot) &&
llvm::sys::path::is_separator(Dir[SysRoot.size()])) {
Root = PathPool::RootDirKind::SysRoot;
Dir = Dir.drop_front(SysRoot.size());
- } else if (!WorkDir.empty() && Dir.startswith(WorkDir) &&
+ } else if (!WorkDir.empty() && Dir.starts_with(WorkDir) &&
llvm::sys::path::is_separator(Dir[WorkDir.size()])) {
Root = PathPool::RootDirKind::CurrentWorkDir;
Dir = Dir.drop_front(WorkDir.size());
diff --git a/clang/lib/Lex/HeaderSearch.cpp b/clang/lib/Lex/HeaderSearch.cpp
index c03cf19..f24013d 100644
--- a/clang/lib/Lex/HeaderSearch.cpp
+++ b/clang/lib/Lex/HeaderSearch.cpp
@@ -796,7 +796,7 @@ static bool isFrameworkStylePath(StringRef Path, bool &IsPrivateHeader,
} else if (*I == "PrivateHeaders") {
++FoundComp;
IsPrivateHeader = true;
- } else if (I->endswith(".framework")) {
+ } else if (I->ends_with(".framework")) {
StringRef Name = I->drop_back(10); // Drop .framework
// Need to reset the strings and counter to support nested frameworks.
FrameworkName.clear();
@@ -1085,7 +1085,7 @@ OptionalFileEntryRef HeaderSearch::LookupFile(
// If the filename matches a known system header prefix, override
// whether the file is a system header.
for (unsigned j = SystemHeaderPrefixes.size(); j; --j) {
- if (Filename.startswith(SystemHeaderPrefixes[j-1].first)) {
+ if (Filename.starts_with(SystemHeaderPrefixes[j - 1].first)) {
HFI.DirInfo = SystemHeaderPrefixes[j-1].second ? SrcMgr::C_System
: SrcMgr::C_User;
break;
@@ -1694,7 +1694,7 @@ bool HeaderSearch::loadModuleMapFile(FileEntryRef File, bool IsSystem,
StringRef DirName(Dir->getName());
if (llvm::sys::path::filename(DirName) == "Modules") {
DirName = llvm::sys::path::parent_path(DirName);
- if (DirName.endswith(".framework"))
+ if (DirName.ends_with(".framework"))
if (auto MaybeDir = FileMgr.getOptionalDirectoryRef(DirName))
Dir = *MaybeDir;
// FIXME: This assert can fail if there's a race between the above check
@@ -1965,10 +1965,10 @@ std::string HeaderSearch::suggestPathToFileForDiagnostics(
// Special case Apple .sdk folders since the search path is typically a
// symlink like `iPhoneSimulator14.5.sdk` while the file is instead
// located in `iPhoneSimulator.sdk` (the real folder).
- if (NI->endswith(".sdk") && DI->endswith(".sdk")) {
+ if (NI->ends_with(".sdk") && DI->ends_with(".sdk")) {
StringRef NBasename = path::stem(*NI);
StringRef DBasename = path::stem(*DI);
- if (DBasename.startswith(NBasename))
+ if (DBasename.starts_with(NBasename))
continue;
}
diff --git a/clang/lib/Lex/InitHeaderSearch.cpp b/clang/lib/Lex/InitHeaderSearch.cpp
index 5b1b7c8..2218db1 100644
--- a/clang/lib/Lex/InitHeaderSearch.cpp
+++ b/clang/lib/Lex/InitHeaderSearch.cpp
@@ -141,8 +141,8 @@ bool InitHeaderSearch::AddUnmappedPath(const Twine &Path, IncludeDirGroup Group,
StringRef MappedPathStr = Path.toStringRef(MappedPathStorage);
// If use system headers while cross-compiling, emit the warning.
- if (HasSysroot && (MappedPathStr.startswith("/usr/include") ||
- MappedPathStr.startswith("/usr/local/include"))) {
+ if (HasSysroot && (MappedPathStr.starts_with("/usr/include") ||
+ MappedPathStr.starts_with("/usr/local/include"))) {
Headers.getDiags().Report(diag::warn_poison_system_directories)
<< MappedPathStr;
}
diff --git a/clang/lib/Lex/Lexer.cpp b/clang/lib/Lex/Lexer.cpp
index f4f1daa..50b5626 100644
--- a/clang/lib/Lex/Lexer.cpp
+++ b/clang/lib/Lex/Lexer.cpp
@@ -3212,8 +3212,8 @@ bool Lexer::IsStartOfConflictMarker(const char *CurPtr) {
return false;
// Check to see if we have <<<<<<< or >>>>.
- if (!StringRef(CurPtr, BufferEnd - CurPtr).startswith("<<<<<<<") &&
- !StringRef(CurPtr, BufferEnd - CurPtr).startswith(">>>> "))
+ if (!StringRef(CurPtr, BufferEnd - CurPtr).starts_with("<<<<<<<") &&
+ !StringRef(CurPtr, BufferEnd - CurPtr).starts_with(">>>> "))
return false;
// If we have a situation where we don't care about conflict markers, ignore
diff --git a/clang/lib/Lex/ModuleMap.cpp b/clang/lib/Lex/ModuleMap.cpp
index d35c282..ea5d13d 100644
--- a/clang/lib/Lex/ModuleMap.cpp
+++ b/clang/lib/Lex/ModuleMap.cpp
@@ -235,7 +235,7 @@ OptionalFileEntryRef ModuleMap::findHeader(
llvm::sys::path::append(FullPathName, RelativePathName);
auto NormalHdrFile = GetFile(FullPathName);
- if (!NormalHdrFile && Directory->getName().endswith(".framework")) {
+ if (!NormalHdrFile && Directory->getName().ends_with(".framework")) {
// The lack of 'framework' keyword in a module declaration it's a simple
// mistake we can diagnose when the header exists within the proper
// framework style path.
@@ -1034,7 +1034,7 @@ Module *ModuleMap::inferFrameworkModule(DirectoryEntryRef FrameworkDir,
if (inferred == InferredDirectories.end()) {
// We haven't looked here before. Load a module map, if there is
// one.
- bool IsFrameworkDir = Parent.endswith(".framework");
+ bool IsFrameworkDir = Parent.ends_with(".framework");
if (OptionalFileEntryRef ModMapFile =
HeaderInfo.lookupModuleMapFile(*ParentDir, IsFrameworkDir)) {
parseModuleMapFile(*ModMapFile, Attrs.IsSystem, *ParentDir);
@@ -1125,7 +1125,7 @@ Module *ModuleMap::inferFrameworkModule(DirectoryEntryRef FrameworkDir,
Dir = FS.dir_begin(SubframeworksDirName, EC),
DirEnd;
Dir != DirEnd && !EC; Dir.increment(EC)) {
- if (!StringRef(Dir->path()).endswith(".framework"))
+ if (!StringRef(Dir->path()).ends_with(".framework"))
continue;
if (auto SubframeworkDir = FileMgr.getOptionalDirectoryRef(Dir->path())) {
@@ -1337,7 +1337,7 @@ ModuleMap::canonicalizeModuleMapPath(SmallVectorImpl<char> &Path) {
// Modules/ not Versions/A/Modules.
if (llvm::sys::path::filename(Dir) == "Modules") {
StringRef Parent = llvm::sys::path::parent_path(Dir);
- if (Parent.endswith(".framework"))
+ if (Parent.ends_with(".framework"))
Dir = Parent;
}
@@ -2119,8 +2119,8 @@ void ModuleMapParser::parseModuleDecl() {
ActiveModule->Directory = Directory;
StringRef MapFileName(ModuleMapFile.getName());
- if (MapFileName.endswith("module.private.modulemap") ||
- MapFileName.endswith("module_private.map")) {
+ if (MapFileName.ends_with("module.private.modulemap") ||
+ MapFileName.ends_with("module_private.map")) {
ActiveModule->ModuleMapIsPrivate = true;
}
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index 1400348..112bc8d 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -164,13 +164,13 @@ static bool isLanguageDefinedBuiltin(const SourceManager &SourceMgr,
return false;
// C defines macros starting with __STDC, and C++ defines macros starting with
// __STDCPP
- if (MacroName.startswith("__STDC"))
+ if (MacroName.starts_with("__STDC"))
return true;
// C++ defines the __cplusplus macro
if (MacroName == "__cplusplus")
return true;
// C++ defines various feature-test macros starting with __cpp
- if (MacroName.startswith("__cpp"))
+ if (MacroName.starts_with("__cpp"))
return true;
// Anything else isn't language-defined
return false;
@@ -646,7 +646,7 @@ void Preprocessor::SkipExcludedConditionalBlock(SourceLocation HashTokenLoc,
Directive = StringRef(DirectiveBuf, IdLen);
}
- if (Directive.startswith("if")) {
+ if (Directive.starts_with("if")) {
StringRef Sub = Directive.substr(2);
if (Sub.empty() || // "if"
Sub == "def" || // "ifdef"
@@ -2788,14 +2788,14 @@ static bool isConfigurationPattern(Token &MacroName, MacroInfo *MI,
return false;
StringRef ValueText = II->getName();
StringRef TrimmedValue = ValueText;
- if (!ValueText.startswith("__")) {
- if (ValueText.startswith("_"))
+ if (!ValueText.starts_with("__")) {
+ if (ValueText.starts_with("_"))
TrimmedValue = TrimmedValue.drop_front(1);
else
return false;
} else {
TrimmedValue = TrimmedValue.drop_front(2);
- if (TrimmedValue.endswith("__"))
+ if (TrimmedValue.ends_with("__"))
TrimmedValue = TrimmedValue.drop_back(2);
}
return TrimmedValue.equals(MacroText);
diff --git a/clang/lib/Lex/PPExpressions.cpp b/clang/lib/Lex/PPExpressions.cpp
index 269984a..1feb0eb 100644
--- a/clang/lib/Lex/PPExpressions.cpp
+++ b/clang/lib/Lex/PPExpressions.cpp
@@ -267,7 +267,7 @@ static bool EvaluateValue(PPValue &Result, Token &PeekTok, DefinedTracker &DT,
const StringRef IdentifierName = II->getName();
if (llvm::any_of(UndefPrefixes,
[&IdentifierName](const std::string &Prefix) {
- return IdentifierName.startswith(Prefix);
+ return IdentifierName.starts_with(Prefix);
}))
PP.Diag(PeekTok, diag::warn_pp_undef_prefix)
<< AddFlagValue{llvm::join(UndefPrefixes, ",")} << II;
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp b/clang/lib/Lex/PPMacroExpansion.cpp
index 30c4abd..ad02f31 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -1136,7 +1136,8 @@ static bool HasFeature(const Preprocessor &PP, StringRef Feature) {
const LangOptions &LangOpts = PP.getLangOpts();
// Normalize the feature name, __foo__ becomes foo.
- if (Feature.startswith("__") && Feature.endswith("__") && Feature.size() >= 4)
+ if (Feature.starts_with("__") && Feature.ends_with("__") &&
+ Feature.size() >= 4)
Feature = Feature.substr(2, Feature.size() - 4);
#define FEATURE(Name, Predicate) .Case(#Name, Predicate)
@@ -1162,7 +1163,7 @@ static bool HasExtension(const Preprocessor &PP, StringRef Extension) {
const LangOptions &LangOpts = PP.getLangOpts();
// Normalize the extension name, __foo__ becomes foo.
- if (Extension.startswith("__") && Extension.endswith("__") &&
+ if (Extension.starts_with("__") && Extension.ends_with("__") &&
Extension.size() >= 4)
Extension = Extension.substr(2, Extension.size() - 4);
@@ -1691,9 +1692,9 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
// as being "builtin functions", even if the syntax isn't a valid
// function call (for example, because the builtin takes a type
// argument).
- if (II->getName().startswith("__builtin_") ||
- II->getName().startswith("__is_") ||
- II->getName().startswith("__has_"))
+ if (II->getName().starts_with("__builtin_") ||
+ II->getName().starts_with("__is_") ||
+ II->getName().starts_with("__has_"))
return true;
return llvm::StringSwitch<bool>(II->getName())
.Case("__array_rank", true)
diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp
index ece3698..ed006f9 100644
--- a/clang/lib/Parse/ParseDecl.cpp
+++ b/clang/lib/Parse/ParseDecl.cpp
@@ -84,7 +84,7 @@ TypeResult Parser::ParseTypeName(SourceRange *Range, DeclaratorContext Context,
/// Normalizes an attribute name by dropping prefixed and suffixed __.
static StringRef normalizeAttrName(StringRef Name) {
- if (Name.size() >= 4 && Name.startswith("__") && Name.endswith("__"))
+ if (Name.size() >= 4 && Name.starts_with("__") && Name.ends_with("__"))
return Name.drop_front(2).drop_back(2);
return Name;
}
@@ -7854,7 +7854,7 @@ void Parser::ParseTypeofSpecifier(DeclSpec &DS) {
bool IsUnqual = Tok.is(tok::kw_typeof_unqual);
const IdentifierInfo *II = Tok.getIdentifierInfo();
- if (getLangOpts().C23 && !II->getName().startswith("__"))
+ if (getLangOpts().C23 && !II->getName().starts_with("__"))
Diag(Tok.getLocation(), diag::warn_c23_compat_keyword) << Tok.getName();
Token OpTok = Tok;
diff --git a/clang/lib/Parse/Parser.cpp b/clang/lib/Parse/Parser.cpp
index ec67faf..b703c2d 100644
--- a/clang/lib/Parse/Parser.cpp
+++ b/clang/lib/Parse/Parser.cpp
@@ -2645,7 +2645,7 @@ Decl *Parser::ParseModuleImport(SourceLocation AtLoc,
auto &SrcMgr = PP.getSourceManager();
auto FE = SrcMgr.getFileEntryRefForID(SrcMgr.getFileID(AtLoc));
if (FE && llvm::sys::path::parent_path(FE->getDir().getName())
- .endswith(".framework"))
+ .ends_with(".framework"))
Diags.Report(AtLoc, diag::warn_atimport_in_framework_header);
}
diff --git a/clang/lib/Rewrite/Rewriter.cpp b/clang/lib/Rewrite/Rewriter.cpp
index 0896221..0e6ae36 100644
--- a/clang/lib/Rewrite/Rewriter.cpp
+++ b/clang/lib/Rewrite/Rewriter.cpp
@@ -386,7 +386,7 @@ bool Rewriter::IncreaseIndentation(CharSourceRange range,
}
if (parentSpace.size() >= startSpace.size())
return true;
- if (!startSpace.startswith(parentSpace))
+ if (!startSpace.starts_with(parentSpace))
return true;
StringRef indent = startSpace.substr(parentSpace.size());
@@ -399,7 +399,7 @@ bool Rewriter::IncreaseIndentation(CharSourceRange range,
while (isWhitespaceExceptNL(MB[i]))
++i;
StringRef origIndent = MB.substr(offs, i-offs);
- if (origIndent.startswith(startSpace))
+ if (origIndent.starts_with(startSpace))
RB.InsertText(offs, indent, /*InsertAfter=*/false);
}
diff --git a/clang/lib/Sema/CodeCompleteConsumer.cpp b/clang/lib/Sema/CodeCompleteConsumer.cpp
index 9caa1a8..350bd78 100644
--- a/clang/lib/Sema/CodeCompleteConsumer.cpp
+++ b/clang/lib/Sema/CodeCompleteConsumer.cpp
@@ -630,15 +630,16 @@ bool PrintingCodeCompleteConsumer::isResultFilteredOut(
StringRef Filter, CodeCompletionResult Result) {
switch (Result.Kind) {
case CodeCompletionResult::RK_Declaration:
- return !(Result.Declaration->getIdentifier() &&
- Result.Declaration->getIdentifier()->getName().startswith(Filter));
+ return !(
+ Result.Declaration->getIdentifier() &&
+ Result.Declaration->getIdentifier()->getName().starts_with(Filter));
case CodeCompletionResult::RK_Keyword:
- return !StringRef(Result.Keyword).startswith(Filter);
+ return !StringRef(Result.Keyword).starts_with(Filter);
case CodeCompletionResult::RK_Macro:
- return !Result.Macro->getName().startswith(Filter);
+ return !Result.Macro->getName().starts_with(Filter);
case CodeCompletionResult::RK_Pattern:
return !(Result.Pattern->getTypedText() &&
- StringRef(Result.Pattern->getTypedText()).startswith(Filter));
+ StringRef(Result.Pattern->getTypedText()).starts_with(Filter));
}
llvm_unreachable("Unknown code completion result Kind.");
}
diff --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index cdb6e95..254c272 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -1219,7 +1219,7 @@ void Sema::checkFortifiedBuiltinMemoryFunction(FunctionDecl *FD,
if (IsChkVariant) {
FunctionName = FunctionName.drop_front(std::strlen("__builtin___"));
FunctionName = FunctionName.drop_back(std::strlen("_chk"));
- } else if (FunctionName.startswith("__builtin_")) {
+ } else if (FunctionName.starts_with("__builtin_")) {
FunctionName = FunctionName.drop_front(std::strlen("__builtin_"));
}
return FunctionName;
@@ -18270,15 +18270,14 @@ static bool isSetterLikeSelector(Selector sel) {
StringRef str = sel.getNameForSlot(0);
while (!str.empty() && str.front() == '_') str = str.substr(1);
- if (str.startswith("set"))
+ if (str.starts_with("set"))
str = str.substr(3);
- else if (str.startswith("add")) {
+ else if (str.starts_with("add")) {
// Specially allow 'addOperationWithBlock:'.
- if (sel.getNumArgs() == 1 && str.startswith("addOperationWithBlock"))
+ if (sel.getNumArgs() == 1 && str.starts_with("addOperationWithBlock"))
return false;
str = str.substr(3);
- }
- else
+ } else
return false;
if (str.empty()) return true;
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp
index 143968b4..c44be0df 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -9798,7 +9798,7 @@ void Sema::CodeCompleteObjCMethodDeclSelector(
Results.ExitScope();
if (!AtParameterName && !SelIdents.empty() &&
- SelIdents.front()->getName().startswith("init")) {
+ SelIdents.front()->getName().starts_with("init")) {
for (const auto &M : PP.macros()) {
if (M.first->getName() != "NS_DESIGNATED_INITIALIZER")
continue;
@@ -10110,7 +10110,7 @@ void Sema::CodeCompleteIncludedFile(llvm::StringRef Dir, bool Angled) {
}
const StringRef &Dirname = llvm::sys::path::filename(Dir);
- const bool isQt = Dirname.startswith("Qt") || Dirname == "ActiveQt";
+ const bool isQt = Dirname.starts_with("Qt") || Dirname == "ActiveQt";
const bool ExtensionlessHeaders =
IsSystem || isQt || Dir.ends_with(".framework/Headers");
std::error_code EC;
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 6385484..be6a136 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -16005,7 +16005,7 @@ Decl *Sema::ActOnFinishFunctionBody(Decl *dcl, Stmt *Body,
return StartTok.consume_front("const") &&
(StartTok.empty() || isWhitespace(StartTok[0]) ||
- StartTok.startswith("/*") || StartTok.startswith("//"));
+ StartTok.starts_with("/*") || StartTok.starts_with("//"));
};
auto findBeginLoc = [&]() {
@@ -16359,7 +16359,7 @@ NamedDecl *Sema::ImplicitlyDefineFunction(SourceLocation Loc,
// Extension in C99 (defaults to error). Legal in C89, but warn about it.
unsigned diag_id;
- if (II.getName().startswith("__builtin_"))
+ if (II.getName().starts_with("__builtin_"))
diag_id = diag::warn_builtin_unknown;
// OpenCL v2.0 s6.9.u - Implicit function declaration is not supported.
else if (getLangOpts().C99)
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 59e456f..22f291e 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -1809,8 +1809,8 @@ static void handleAssumumptionAttr(Sema &S, Decl *D, const ParsedAttr &AL) {
/// Normalize the attribute, __foo__ becomes foo.
/// Returns true if normalization was applied.
static bool normalizeName(StringRef &AttrName) {
- if (AttrName.size() > 4 && AttrName.startswith("__") &&
- AttrName.endswith("__")) {
+ if (AttrName.size() > 4 && AttrName.starts_with("__") &&
+ AttrName.ends_with("__")) {
AttrName = AttrName.drop_front(2).drop_back(2);
return true;
}
@@ -3605,7 +3605,7 @@ bool Sema::checkTargetClonesAttrString(
}
} else {
// Other targets ( currently X86 )
- if (Cur.startswith("arch=")) {
+ if (Cur.starts_with("arch=")) {
if (!Context.getTargetInfo().isValidCPUName(
Cur.drop_front(sizeof("arch=") - 1)))
return Diag(CurLoc, diag::warn_unsupported_target_attribute)
@@ -3623,7 +3623,7 @@ bool Sema::checkTargetClonesAttrString(
StringsBuffer.push_back(Cur);
}
}
- if (Str.rtrim().endswith(","))
+ if (Str.rtrim().ends_with(","))
return Diag(LiteralLoc, diag::warn_unsupported_target_attribute)
<< Unsupported << None << "" << TargetClones;
return false;
@@ -5819,7 +5819,7 @@ struct IntrinToName {
static bool ArmBuiltinAliasValid(unsigned BuiltinID, StringRef AliasName,
ArrayRef<IntrinToName> Map,
const char *IntrinNames) {
- if (AliasName.startswith("__arm_"))
+ if (AliasName.starts_with("__arm_"))
AliasName = AliasName.substr(6);
const IntrinToName *It =
llvm::lower_bound(Map, BuiltinID, [](const IntrinToName &L, unsigned Id) {
@@ -6663,10 +6663,10 @@ validateSwiftFunctionName(Sema &S, const ParsedAttr &AL, SourceLocation Loc,
// Check whether this will be mapped to a getter or setter of a property.
bool IsGetter = false, IsSetter = false;
- if (Name.startswith("getter:")) {
+ if (Name.starts_with("getter:")) {
IsGetter = true;
Name = Name.substr(7);
- } else if (Name.startswith("setter:")) {
+ } else if (Name.starts_with("setter:")) {
IsSetter = true;
Name = Name.substr(7);
}
@@ -7292,7 +7292,7 @@ static void handleHLSLResourceBindingAttr(Sema &S, Decl *D,
}
}
- if (!Space.startswith("space")) {
+ if (!Space.starts_with("space")) {
S.Diag(SpaceArgLoc, diag::err_hlsl_expected_space) << Space;
return;
}
diff --git a/clang/lib/Sema/SemaDeclObjC.cpp b/clang/lib/Sema/SemaDeclObjC.cpp
index cdfa6ad..c3b95e1 100644
--- a/clang/lib/Sema/SemaDeclObjC.cpp
+++ b/clang/lib/Sema/SemaDeclObjC.cpp
@@ -296,7 +296,7 @@ static void DiagnoseObjCImplementedDeprecations(Sema &S, const NamedDecl *ND,
RealizedPlatform = S.Context.getTargetInfo().getPlatformName();
// Warn about implementing unavailable methods, unless the unavailable
// is for an app extension.
- if (RealizedPlatform.endswith("_app_extension"))
+ if (RealizedPlatform.ends_with("_app_extension"))
return;
S.Diag(ImplLoc, diag::warn_unavailable_def);
S.Diag(ND->getLocation(), diag::note_method_declared_at)
diff --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index d629be0..c7185d5 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -13808,12 +13808,12 @@ static void diagnoseXorMisusedAsPow(Sema &S, const ExprResult &XorLHS,
StringRef RHSStrRef = RHSStr;
// Do not diagnose literals with digit separators, binary, hexadecimal, octal
// literals.
- if (LHSStrRef.startswith("0b") || LHSStrRef.startswith("0B") ||
- RHSStrRef.startswith("0b") || RHSStrRef.startswith("0B") ||
- LHSStrRef.startswith("0x") || LHSStrRef.startswith("0X") ||
- RHSStrRef.startswith("0x") || RHSStrRef.startswith("0X") ||
- (LHSStrRef.size() > 1 && LHSStrRef.startswith("0")) ||
- (RHSStrRef.size() > 1 && RHSStrRef.startswith("0")) ||
+ if (LHSStrRef.starts_with("0b") || LHSStrRef.starts_with("0B") ||
+ RHSStrRef.starts_with("0b") || RHSStrRef.starts_with("0B") ||
+ LHSStrRef.starts_with("0x") || LHSStrRef.starts_with("0X") ||
+ RHSStrRef.starts_with("0x") || RHSStrRef.starts_with("0X") ||
+ (LHSStrRef.size() > 1 && LHSStrRef.starts_with("0")) ||
+ (RHSStrRef.size() > 1 && RHSStrRef.starts_with("0")) ||
LHSStrRef.contains('\'') || RHSStrRef.contains('\''))
return;
@@ -15508,7 +15508,7 @@ static void checkObjCPointerIntrospection(Sema &S, ExprResult &L, ExprResult &R,
if (const ObjCMessageExpr *ME = dyn_cast<ObjCMessageExpr>(Ex)) {
Selector S = ME->getSelector();
StringRef SelArg0 = S.getNameForSlot(0);
- if (SelArg0.startswith("performSelector"))
+ if (SelArg0.starts_with("performSelector"))
Diag = diag::warn_objc_pointer_masking_performSelector;
}
diff --git a/clang/lib/Sema/SemaModule.cpp b/clang/lib/Sema/SemaModule.cpp
index 9282ceb..db0cbd5 100644
--- a/clang/lib/Sema/SemaModule.cpp
+++ b/clang/lib/Sema/SemaModule.cpp
@@ -268,7 +268,7 @@ Sema::ActOnModuleDecl(SourceLocation StartLoc, SourceLocation ModuleLoc,
StringRef FirstComponentName = Path[0].first->getName();
if (!getSourceManager().isInSystemHeader(Path[0].second) &&
(FirstComponentName == "std" ||
- (FirstComponentName.startswith("std") &&
+ (FirstComponentName.starts_with("std") &&
llvm::all_of(FirstComponentName.drop_front(3), &llvm::isDigit))))
Diag(Path[0].second, diag::warn_reserved_module_name) << Path[0].first;
diff --git a/clang/lib/Sema/SemaType.cpp b/clang/lib/Sema/SemaType.cpp
index c8ad8b6..a376f20 100644
--- a/clang/lib/Sema/SemaType.cpp
+++ b/clang/lib/Sema/SemaType.cpp
@@ -5371,7 +5371,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
!(D.getIdentifier() &&
((D.getIdentifier()->getName() == "printf" &&
LangOpts.getOpenCLCompatibleVersion() >= 120) ||
- D.getIdentifier()->getName().startswith("__")))) {
+ D.getIdentifier()->getName().starts_with("__")))) {
S.Diag(D.getIdentifierLoc(), diag::err_opencl_variadic_function);
D.setInvalidType(true);
}
diff --git a/clang/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp b/clang/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
index bd6655c..fedc6db 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp
@@ -1045,8 +1045,8 @@ bool ObjCDeallocChecker::isReleasedByCIFilterDealloc(
StringRef IvarName = PropImpl->getPropertyIvarDecl()->getName();
const char *ReleasePrefix = "input";
- if (!(PropName.startswith(ReleasePrefix) ||
- IvarName.startswith(ReleasePrefix))) {
+ if (!(PropName.starts_with(ReleasePrefix) ||
+ IvarName.starts_with(ReleasePrefix))) {
return false;
}
diff --git a/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp b/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
index dbba12b..afc5e6b 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CheckSecuritySyntaxOnly.cpp
@@ -140,7 +140,7 @@ void WalkAST::VisitCallExpr(CallExpr *CE) {
if (!II) // if no identifier, not a simple C function
return;
StringRef Name = II->getName();
- if (Name.startswith("__builtin_"))
+ if (Name.starts_with("__builtin_"))
Name = Name.substr(10);
// Set the evaluation function by switching on the callee name.
@@ -763,7 +763,7 @@ void WalkAST::checkDeprecatedOrUnsafeBufferHandling(const CallExpr *CE,
enum { DEPR_ONLY = -1, UNKNOWN_CALL = -2 };
StringRef Name = FD->getIdentifier()->getName();
- if (Name.startswith("__builtin_"))
+ if (Name.starts_with("__builtin_"))
Name = Name.substr(10);
int ArgIndex =
diff --git a/clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
index 5f44c94..86f446f 100644
--- a/clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
@@ -183,7 +183,7 @@ public:
// Files autogenerated by DriverKit IIG contain some dead stores that
// we don't want to report.
- if (Data.startswith("/* iig"))
+ if (Data.starts_with("/* iig"))
return true;
return false;
diff --git a/clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp
index 8e02ef7..5637941 100644
--- a/clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/GCDAntipatternChecker.cpp
@@ -73,7 +73,7 @@ decltype(auto) bindAssignmentToDecl(const char *DeclName) {
static bool isTest(const Decl *D) {
if (const auto* ND = dyn_cast<NamedDecl>(D)) {
std::string DeclName = ND->getNameAsString();
- if (StringRef(DeclName).startswith("test"))
+ if (StringRef(DeclName).starts_with("test"))
return true;
}
if (const auto *OD = dyn_cast<ObjCMethodDecl>(D)) {
diff --git a/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
index b77e9bf..70f911f 100644
--- a/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
@@ -817,9 +817,9 @@ void NonLocalizedStringChecker::checkPreObjCMessage(const ObjCMethodCall &msg,
// Handle the case where the receiver is an NSString
// These special NSString methods draw to the screen
- if (!(SelectorName.startswith("drawAtPoint") ||
- SelectorName.startswith("drawInRect") ||
- SelectorName.startswith("drawWithRect")))
+ if (!(SelectorName.starts_with("drawAtPoint") ||
+ SelectorName.starts_with("drawInRect") ||
+ SelectorName.starts_with("drawWithRect")))
return;
SVal svTitle = msg.getReceiverSVal();
diff --git a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
index c5e4add..79ab05f 100644
--- a/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
@@ -3150,16 +3150,16 @@ bool MallocChecker::mayFreeAnyEscapedMemoryOrIsModeledExplicitly(
// transferred. Again, though, we can't be sure that the object will use
// free() to deallocate the memory, so we can't model it explicitly.
StringRef FirstSlot = Msg->getSelector().getNameForSlot(0);
- if (FirstSlot.endswith("NoCopy"))
+ if (FirstSlot.ends_with("NoCopy"))
return true;
// If the first selector starts with addPointer, insertPointer,
// or replacePointer, assume we are dealing with NSPointerArray or similar.
// This is similar to C++ containers (vector); we still might want to check
// that the pointers get freed by following the container itself.
- if (FirstSlot.startswith("addPointer") ||
- FirstSlot.startswith("insertPointer") ||
- FirstSlot.startswith("replacePointer") ||
+ if (FirstSlot.starts_with("addPointer") ||
+ FirstSlot.starts_with("insertPointer") ||
+ FirstSlot.starts_with("replacePointer") ||
FirstSlot.equals("valueWithPointer")) {
return true;
}
@@ -3199,7 +3199,7 @@ bool MallocChecker::mayFreeAnyEscapedMemoryOrIsModeledExplicitly(
// White list the 'XXXNoCopy' CoreFoundation functions.
// We specifically check these before
- if (FName.endswith("NoCopy")) {
+ if (FName.ends_with("NoCopy")) {
// Look for the deallocator argument. We know that the memory ownership
// is not transferred only if the deallocator argument is
// 'kCFAllocatorNull'.
diff --git a/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
index 627b51a..06f1ad0 100644
--- a/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
@@ -890,7 +890,7 @@ void NullabilityChecker::checkPostCall(const CallEvent &Call,
// of CG calls.
const SourceManager &SM = C.getSourceManager();
StringRef FilePath = SM.getFilename(SM.getSpellingLoc(Decl->getBeginLoc()));
- if (llvm::sys::path::filename(FilePath).startswith("CG")) {
+ if (llvm::sys::path::filename(FilePath).starts_with("CG")) {
State = State->set<NullabilityMap>(Region, Nullability::Contradicted);
C.addTransition(State);
return;
@@ -992,7 +992,7 @@ void NullabilityChecker::checkPostObjCMessage(const ObjCMethodCall &M,
// In order to reduce the noise in the diagnostics generated by this checker,
// some framework and programming style based heuristics are used. These
// heuristics are for Cocoa APIs which have NS prefix.
- if (Name.startswith("NS")) {
+ if (Name.starts_with("NS")) {
// Developers rely on dynamic invariants such as an item should be available
// in a collection, or a collection is not empty often. Those invariants can
// not be inferred by any static analysis tool. To not to bother the users
diff --git a/clang/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp
index 4636fd1..08ad687 100644
--- a/clang/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/ObjCPropertyChecker.cpp
@@ -50,7 +50,7 @@ void ObjCPropertyChecker::checkCopyMutable(const ObjCPropertyDecl *D,
const std::string &PropTypeName(T->getPointeeType().getCanonicalType()
.getUnqualifiedType()
.getAsString());
- if (!StringRef(PropTypeName).startswith("NSMutable"))
+ if (!StringRef(PropTypeName).starts_with("NSMutable"))
return;
const ObjCImplDecl *ImplD = nullptr;
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
index 9532254..a253f2b 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporter.cpp
@@ -2139,15 +2139,14 @@ PathSensitiveBugReport::PathSensitiveBugReport(
"checkers to emit warnings, because checkers should depend on "
"*modeling*, not *diagnostics*.");
- assert(
- (bt.getCheckerName().startswith("debug") ||
- !isHidden(ErrorNode->getState()
- ->getAnalysisManager()
- .getCheckerManager()
- ->getCheckerRegistryData(),
- bt.getCheckerName())) &&
- "Hidden checkers musn't emit diagnostics as they are by definition "
- "non-user facing!");
+ assert((bt.getCheckerName().starts_with("debug") ||
+ !isHidden(ErrorNode->getState()
+ ->getAnalysisManager()
+ .getCheckerManager()
+ ->getCheckerRegistryData(),
+ bt.getCheckerName())) &&
+ "Hidden checkers musn't emit diagnostics as they are by definition "
+ "non-user facing!");
}
void PathSensitiveBugReport::addVisitor(
@@ -3064,8 +3063,7 @@ void BugReporter::FlushReport(BugReportEquivClass& EQ) {
// See whether we need to silence the checker/package.
for (const std::string &CheckerOrPackage :
getAnalyzerOptions().SilencedCheckersAndPackages) {
- if (report->getBugType().getCheckerName().startswith(
- CheckerOrPackage))
+ if (report->getBugType().getCheckerName().starts_with(CheckerOrPackage))
return;
}
diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
index 4a9d130..2f99650 100644
--- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
+++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
@@ -3372,7 +3372,7 @@ void LikelyFalsePositiveSuppressionBRVisitor::finalizeVisitor(
FullSourceLoc Loc = BR.getLocation().asLocation();
while (Loc.isMacroID()) {
Loc = Loc.getSpellingLoc();
- if (SM.getFilename(Loc).endswith("sys/queue.h")) {
+ if (SM.getFilename(Loc).ends_with("sys/queue.h")) {
BR.markInvalid(getTag(), nullptr);
return;
}
diff --git a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
index d004c12..0ac1d91 100644
--- a/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -659,17 +659,17 @@ bool AnyFunctionCall::argumentsMayEscape() const {
// - CoreFoundation functions that end with "NoCopy" can free a passed-in
// buffer even if it is const.
- if (FName.endswith("NoCopy"))
+ if (FName.ends_with("NoCopy"))
return true;
// - NSXXInsertXX, for example NSMapInsertIfAbsent, since they can
// be deallocated by NSMapRemove.
- if (FName.startswith("NS") && FName.contains("Insert"))
+ if (FName.starts_with("NS") && FName.contains("Insert"))
return true;
// - Many CF containers allow objects to escape through custom
// allocators/deallocators upon container construction. (PR12101)
- if (FName.startswith("CF") || FName.startswith("CG")) {
+ if (FName.starts_with("CF") || FName.starts_with("CG")) {
return StrInStrNoCase(FName, "InsertValue") != StringRef::npos ||
StrInStrNoCase(FName, "AddValue") != StringRef::npos ||
StrInStrNoCase(FName, "SetValue") != StringRef::npos ||
diff --git a/clang/lib/StaticAnalyzer/Core/CheckerContext.cpp b/clang/lib/StaticAnalyzer/Core/CheckerContext.cpp
index c25165c..d6d4cec 100644
--- a/clang/lib/StaticAnalyzer/Core/CheckerContext.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CheckerContext.cpp
@@ -105,10 +105,11 @@ bool CheckerContext::isCLibraryFunction(const FunctionDecl *FD,
if (FName.equals(Name))
return true;
- if (FName.startswith("__inline") && FName.contains(Name))
+ if (FName.starts_with("__inline") && FName.contains(Name))
return true;
- if (FName.startswith("__") && FName.endswith("_chk") && FName.contains(Name))
+ if (FName.starts_with("__") && FName.ends_with("_chk") &&
+ FName.contains(Name))
return true;
return false;
diff --git a/clang/lib/StaticAnalyzer/Core/CheckerRegistryData.cpp b/clang/lib/StaticAnalyzer/Core/CheckerRegistryData.cpp
index 1b3e8b1..b9c6278 100644
--- a/clang/lib/StaticAnalyzer/Core/CheckerRegistryData.cpp
+++ b/clang/lib/StaticAnalyzer/Core/CheckerRegistryData.cpp
@@ -82,7 +82,7 @@ static constexpr char PackageSeparator = '.';
static bool isInPackage(const CheckerInfo &Checker, StringRef PackageName) {
// Does the checker's full name have the package as a prefix?
- if (!Checker.FullName.startswith(PackageName))
+ if (!Checker.FullName.starts_with(PackageName))
return false;
// Is the package actually just the name of a specific checker?
@@ -158,7 +158,7 @@ void CheckerRegistryData::printCheckerWithDescList(
continue;
}
- if (Checker.FullName.startswith("alpha")) {
+ if (Checker.FullName.starts_with("alpha")) {
if (AnOpts.ShowCheckerHelpAlpha)
Print(Out, Checker,
("(Enable only for development!) " + Checker.Desc).str());
@@ -228,7 +228,7 @@ void CheckerRegistryData::printCheckerOptionList(const AnalyzerOptions &AnOpts,
}
if (Option.DevelopmentStatus == "alpha" ||
- Entry.first.startswith("alpha")) {
+ Entry.first.starts_with("alpha")) {
if (AnOpts.ShowCheckerOptionAlphaList)
Print(Out, FullOption,
llvm::Twine("(Enable only for development!) " + Desc).str());
diff --git a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
index 142acab..b6ef405 100644
--- a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -308,7 +308,7 @@ public:
bool VisitFunctionDecl(FunctionDecl *FD) {
IdentifierInfo *II = FD->getIdentifier();
- if (II && II->getName().startswith("__inline"))
+ if (II && II->getName().starts_with("__inline"))
return true;
// We skip function template definitions, as their semantics is
diff --git a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
index f0d3f43..317df90 100644
--- a/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
+++ b/clang/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
@@ -310,8 +310,8 @@ template <bool IsWeak> void CheckerRegistry::resolveDependencies() {
"Failed to find the dependency of a checker!");
// We do allow diagnostics from unit test/example dependency checkers.
- assert((DependencyIt->FullName.startswith("test") ||
- DependencyIt->FullName.startswith("example") || IsWeak ||
+ assert((DependencyIt->FullName.starts_with("test") ||
+ DependencyIt->FullName.starts_with("example") || IsWeak ||
DependencyIt->IsHidden) &&
"Strong dependencies are modeling checkers, and as such "
"non-user facing! Mark them hidden in Checkers.td!");
diff --git a/clang/lib/Support/RISCVVIntrinsicUtils.cpp b/clang/lib/Support/RISCVVIntrinsicUtils.cpp
index a04694e..bb9f7dc7 100644
--- a/clang/lib/Support/RISCVVIntrinsicUtils.cpp
+++ b/clang/lib/Support/RISCVVIntrinsicUtils.cpp
@@ -464,7 +464,7 @@ PrototypeDescriptor::parsePrototypeDescriptor(
PrototypeDescriptorStr = PrototypeDescriptorStr.drop_back();
// Compute the vector type transformers, it can only appear one time.
- if (PrototypeDescriptorStr.startswith("(")) {
+ if (PrototypeDescriptorStr.starts_with("(")) {
assert(VTM == VectorTypeModifier::NoModifier &&
"VectorTypeModifier should only have one modifier");
size_t Idx = PrototypeDescriptorStr.find(')');
diff --git a/clang/lib/Tooling/ASTDiff/ASTDiff.cpp b/clang/lib/Tooling/ASTDiff/ASTDiff.cpp
index 52e5797..356b4bd 100644
--- a/clang/lib/Tooling/ASTDiff/ASTDiff.cpp
+++ b/clang/lib/Tooling/ASTDiff/ASTDiff.cpp
@@ -371,7 +371,7 @@ SyntaxTree::Impl::getRelativeName(const NamedDecl *ND,
// Strip the qualifier, if Val refers to something in the current scope.
// But leave one leading ':' in place, so that we know that this is a
// relative path.
- if (!ContextPrefix.empty() && StringRef(Val).startswith(ContextPrefix))
+ if (!ContextPrefix.empty() && StringRef(Val).starts_with(ContextPrefix))
Val = Val.substr(ContextPrefix.size() + 1);
return Val;
}
diff --git a/clang/lib/Tooling/ArgumentsAdjusters.cpp b/clang/lib/Tooling/ArgumentsAdjusters.cpp
index e40df62..df4c742 100644
--- a/clang/lib/Tooling/ArgumentsAdjusters.cpp
+++ b/clang/lib/Tooling/ArgumentsAdjusters.cpp
@@ -45,12 +45,12 @@ ArgumentsAdjuster getClangSyntaxOnlyAdjuster() {
StringRef Arg = Args[i];
// Skip output commands.
if (llvm::any_of(OutputCommands, [&Arg](llvm::StringRef OutputCommand) {
- return Arg.startswith(OutputCommand);
+ return Arg.starts_with(OutputCommand);
}))
continue;
- if (!Arg.startswith("-fcolor-diagnostics") &&
- !Arg.startswith("-fdiagnostics-color"))
+ if (!Arg.starts_with("-fcolor-diagnostics") &&
+ !Arg.starts_with("-fdiagnostics-color"))
AdjustedArgs.push_back(Args[i]);
// If we strip a color option, make sure we strip any preceeding `-Xclang`
// option as well.
@@ -73,7 +73,7 @@ ArgumentsAdjuster getClangStripOutputAdjuster() {
CommandLineArguments AdjustedArgs;
for (size_t i = 0, e = Args.size(); i < e; ++i) {
StringRef Arg = Args[i];
- if (!Arg.startswith("-o"))
+ if (!Arg.starts_with("-o"))
AdjustedArgs.push_back(Args[i]);
if (Arg == "-o") {
@@ -102,11 +102,11 @@ ArgumentsAdjuster getClangStripDependencyFileAdjuster() {
// When not using the cl driver mode, dependency file generation options
// begin with -M. These include -MM, -MF, -MG, -MP, -MT, -MQ, -MD, and
// -MMD.
- if (!UsingClDriver && Arg.startswith("-M"))
+ if (!UsingClDriver && Arg.starts_with("-M"))
continue;
// Under MSVC's cl driver mode, dependency file generation is controlled
// using /showIncludes
- if (Arg.startswith("/showIncludes") || Arg.startswith("-showIncludes"))
+ if (Arg.starts_with("/showIncludes") || Arg.starts_with("-showIncludes"))
continue;
AdjustedArgs.push_back(Args[i]);
@@ -159,7 +159,7 @@ ArgumentsAdjuster getStripPluginsAdjuster() {
// -Xclang <arbitrary-argument>
if (I + 4 < E && Args[I] == "-Xclang" &&
(Args[I + 1] == "-load" || Args[I + 1] == "-plugin" ||
- llvm::StringRef(Args[I + 1]).startswith("-plugin-arg-") ||
+ llvm::StringRef(Args[I + 1]).starts_with("-plugin-arg-") ||
Args[I + 1] == "-add-plugin") &&
Args[I + 2] == "-Xclang") {
I += 3;
diff --git a/clang/lib/Tooling/CompilationDatabase.cpp b/clang/lib/Tooling/CompilationDatabase.cpp
index fdf6015..87ad8f2 100644
--- a/clang/lib/Tooling/CompilationDatabase.cpp
+++ b/clang/lib/Tooling/CompilationDatabase.cpp
@@ -204,7 +204,7 @@ public:
// which don't support these options.
struct FilterUnusedFlags {
bool operator() (StringRef S) {
- return (S == "-no-integrated-as") || S.startswith("-Wa,");
+ return (S == "-no-integrated-as") || S.starts_with("-Wa,");
}
};
diff --git a/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp b/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
index 3e53c8f..6f71650 100644
--- a/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ b/clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -290,7 +290,7 @@ DependencyScanningWorkerFilesystem::status(const Twine &Path) {
SmallString<256> OwnedFilename;
StringRef Filename = Path.toStringRef(OwnedFilename);
- if (Filename.endswith(".pcm"))
+ if (Filename.ends_with(".pcm"))
return getUnderlyingFS().status(Path);
llvm::ErrorOr<EntryRef> Result = getOrCreateFileSystemEntry(Filename);
@@ -350,7 +350,7 @@ DependencyScanningWorkerFilesystem::openFileForRead(const Twine &Path) {
SmallString<256> OwnedFilename;
StringRef Filename = Path.toStringRef(OwnedFilename);
- if (Filename.endswith(".pcm"))
+ if (Filename.ends_with(".pcm"))
return getUnderlyingFS().openFileForRead(Path);
llvm::ErrorOr<EntryRef> Result = getOrCreateFileSystemEntry(Filename);
diff --git a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
index f65da41..4a3cd05 100644
--- a/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
+++ b/clang/lib/Tooling/DependencyScanning/ModuleDepCollector.cpp
@@ -530,7 +530,7 @@ ModuleDepCollectorPP::handleTopLevelModule(const Module *M) {
// this file in the proper directory and relies on the rest of Clang to
// handle it like normal. With explicitly built modules we don't need
// to play VFS tricks, so replace it with the correct module map.
- if (StringRef(IFI.Filename).endswith("__inferred_module.map")) {
+ if (StringRef(IFI.Filename).ends_with("__inferred_module.map")) {
MDC.addFileDep(MD, ModuleMap->getName());
return;
}
@@ -548,7 +548,7 @@ ModuleDepCollectorPP::handleTopLevelModule(const Module *M) {
if (!(IFI.TopLevel && IFI.ModuleMap))
return;
if (StringRef(IFI.FilenameAsRequested)
- .endswith("__inferred_module.map"))
+ .ends_with("__inferred_module.map"))
return;
MD.ModuleMapFileDeps.emplace_back(IFI.FilenameAsRequested);
});
diff --git a/clang/lib/Tooling/Inclusions/HeaderAnalysis.cpp b/clang/lib/Tooling/Inclusions/HeaderAnalysis.cpp
index 0b3c4de..52b634e 100644
--- a/clang/lib/Tooling/Inclusions/HeaderAnalysis.cpp
+++ b/clang/lib/Tooling/Inclusions/HeaderAnalysis.cpp
@@ -21,7 +21,7 @@ bool isIf(llvm::StringRef Line) {
if (!Line.consume_front("#"))
return false;
Line = Line.ltrim();
- return Line.startswith("if");
+ return Line.starts_with("if");
}
// Is Line an #error directive mentioning includes?
@@ -30,7 +30,7 @@ bool isErrorAboutInclude(llvm::StringRef Line) {
if (!Line.consume_front("#"))
return false;
Line = Line.ltrim();
- if (!Line.startswith("error"))
+ if (!Line.starts_with("error"))
return false;
return Line.contains_insensitive(
"includ"); // Matches "include" or "including".
@@ -54,7 +54,7 @@ bool isImportLine(llvm::StringRef Line) {
if (!Line.consume_front("#"))
return false;
Line = Line.ltrim();
- return Line.startswith("import");
+ return Line.starts_with("import");
}
llvm::StringRef getFileContents(FileEntryRef FE, const SourceManager &SM) {
diff --git a/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp b/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
index 15a2024..d275222 100644
--- a/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ b/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -196,10 +196,10 @@ IncludeCategoryManager::IncludeCategoryManager(const IncludeStyle &Style,
? llvm::Regex::NoFlags
: llvm::Regex::IgnoreCase);
}
- IsMainFile = FileName.endswith(".c") || FileName.endswith(".cc") ||
- FileName.endswith(".cpp") || FileName.endswith(".c++") ||
- FileName.endswith(".cxx") || FileName.endswith(".m") ||
- FileName.endswith(".mm");
+ IsMainFile = FileName.ends_with(".c") || FileName.ends_with(".cc") ||
+ FileName.ends_with(".cpp") || FileName.ends_with(".c++") ||
+ FileName.ends_with(".cxx") || FileName.ends_with(".m") ||
+ FileName.ends_with(".mm");
if (!Style.IncludeIsMainSourceRegex.empty()) {
llvm::Regex MainFileRegex(Style.IncludeIsMainSourceRegex);
IsMainFile |= MainFileRegex.match(FileName);
@@ -234,7 +234,7 @@ int IncludeCategoryManager::getSortIncludePriority(StringRef IncludeName,
return Ret;
}
bool IncludeCategoryManager::isMainHeader(StringRef IncludeName) const {
- if (!IncludeName.startswith("\""))
+ if (!IncludeName.starts_with("\""))
return false;
IncludeName =
@@ -357,8 +357,8 @@ HeaderIncludes::insert(llvm::StringRef IncludeName, bool IsAngled,
if (It != ExistingIncludes.end()) {
for (const auto &Inc : It->second)
if (Inc.Directive == Directive &&
- ((IsAngled && StringRef(Inc.Name).startswith("<")) ||
- (!IsAngled && StringRef(Inc.Name).startswith("\""))))
+ ((IsAngled && StringRef(Inc.Name).starts_with("<")) ||
+ (!IsAngled && StringRef(Inc.Name).starts_with("\""))))
return std::nullopt;
}
std::string Quoted =
@@ -400,8 +400,8 @@ tooling::Replacements HeaderIncludes::remove(llvm::StringRef IncludeName,
if (Iter == ExistingIncludes.end())
return Result;
for (const auto &Inc : Iter->second) {
- if ((IsAngled && StringRef(Inc.Name).startswith("\"")) ||
- (!IsAngled && StringRef(Inc.Name).startswith("<")))
+ if ((IsAngled && StringRef(Inc.Name).starts_with("\"")) ||
+ (!IsAngled && StringRef(Inc.Name).starts_with("<")))
continue;
llvm::Error Err = Result.add(tooling::Replacement(
FileName, Inc.R.getOffset(), Inc.R.getLength(), ""));
diff --git a/clang/lib/Tooling/Refactoring/AtomicChange.cpp b/clang/lib/Tooling/Refactoring/AtomicChange.cpp
index 7237393..3d5ae2f 100644
--- a/clang/lib/Tooling/Refactoring/AtomicChange.cpp
+++ b/clang/lib/Tooling/Refactoring/AtomicChange.cpp
@@ -150,7 +150,7 @@ createReplacementsForHeaders(llvm::StringRef FilePath, llvm::StringRef Code,
for (const auto &Change : Changes) {
for (llvm::StringRef Header : Change.getInsertedHeaders()) {
std::string EscapedHeader =
- Header.startswith("<") || Header.startswith("\"")
+ Header.starts_with("<") || Header.starts_with("\"")
? Header.str()
: ("\"" + Header + "\"").str();
std::string ReplacementText = "#include " + EscapedHeader;
diff --git a/clang/lib/Tooling/Refactoring/Lookup.cpp b/clang/lib/Tooling/Refactoring/Lookup.cpp
index 9468d4d..52799f1 100644
--- a/clang/lib/Tooling/Refactoring/Lookup.cpp
+++ b/clang/lib/Tooling/Refactoring/Lookup.cpp
@@ -98,7 +98,7 @@ static StringRef getBestNamespaceSubstr(const DeclContext *DeclA,
// from NewName if it has an identical prefix.
std::string NS =
"::" + cast<NamespaceDecl>(DeclA)->getQualifiedNameAsString() + "::";
- if (NewName.startswith(NS))
+ if (NewName.starts_with(NS))
return NewName.substr(NS.size());
// No match yet. Strip of a namespace from the end of the chain and try
@@ -128,9 +128,9 @@ static std::string disambiguateSpellingInScope(StringRef Spelling,
StringRef QName,
const DeclContext &UseContext,
SourceLocation UseLoc) {
- assert(QName.startswith("::"));
- assert(QName.endswith(Spelling));
- if (Spelling.startswith("::"))
+ assert(QName.starts_with("::"));
+ assert(QName.ends_with(Spelling));
+ if (Spelling.starts_with("::"))
return std::string(Spelling);
auto UnspelledSpecifier = QName.drop_back(Spelling.size());
@@ -146,7 +146,7 @@ static std::string disambiguateSpellingInScope(StringRef Spelling,
UseLoc = SM.getSpellingLoc(UseLoc);
auto IsAmbiguousSpelling = [&](const llvm::StringRef CurSpelling) {
- if (CurSpelling.startswith("::"))
+ if (CurSpelling.starts_with("::"))
return false;
// Lookup the first component of Spelling in all enclosing namespaces
// and check if there is any existing symbols with the same name but in
@@ -160,7 +160,7 @@ static std::string disambiguateSpellingInScope(StringRef Spelling,
// ambiguous. For example, a reference in a header file should not be
// affected by a potentially ambiguous name in some file that includes
// the header.
- if (!TrimmedQName.startswith(Res->getQualifiedNameAsString()) &&
+ if (!TrimmedQName.starts_with(Res->getQualifiedNameAsString()) &&
SM.isBeforeInTranslationUnit(
SM.getSpellingLoc(Res->getLocation()), UseLoc))
return true;
@@ -187,7 +187,7 @@ std::string tooling::replaceNestedName(const NestedNameSpecifier *Use,
const DeclContext *UseContext,
const NamedDecl *FromDecl,
StringRef ReplacementString) {
- assert(ReplacementString.startswith("::") &&
+ assert(ReplacementString.starts_with("::") &&
"Expected fully-qualified name!");
// We can do a raw name replacement when we are not inside the namespace for
diff --git a/clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp b/clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
index 9cdeeec..c18f929 100644
--- a/clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
+++ b/clang/lib/Tooling/Refactoring/Rename/USRLocFinder.cpp
@@ -562,8 +562,8 @@ createRenameAtomicChanges(llvm::ArrayRef<std::string> USRs,
ReplacedName = tooling::replaceNestedName(
RenameInfo.Specifier, RenameInfo.Begin,
RenameInfo.Context->getDeclContext(), RenameInfo.FromDecl,
- NewName.startswith("::") ? NewName.str()
- : ("::" + NewName).str());
+ NewName.starts_with("::") ? NewName.str()
+ : ("::" + NewName).str());
} else {
// This fixes the case where type `T` is a parameter inside a function
// type (e.g. `std::function<void(T)>`) and the DeclContext of `T`
@@ -578,13 +578,13 @@ createRenameAtomicChanges(llvm::ArrayRef<std::string> USRs,
SM, TranslationUnitDecl->getASTContext().getLangOpts());
// Add the leading "::" back if the name written in the code contains
// it.
- if (ActualName.startswith("::") && !NewName.startswith("::")) {
+ if (ActualName.starts_with("::") && !NewName.starts_with("::")) {
ReplacedName = "::" + NewName.str();
}
}
}
// If the NewName contains leading "::", add it back.
- if (NewName.startswith("::") && NewName.substr(2) == ReplacedName)
+ if (NewName.starts_with("::") && NewName.substr(2) == ReplacedName)
ReplacedName = NewName.str();
}
Replace(RenameInfo.Begin, RenameInfo.End, ReplacedName);
diff --git a/clang/lib/Tooling/Tooling.cpp b/clang/lib/Tooling/Tooling.cpp
index e292fa7..33bfa8d 100644
--- a/clang/lib/Tooling/Tooling.cpp
+++ b/clang/lib/Tooling/Tooling.cpp
@@ -255,7 +255,7 @@ llvm::Expected<std::string> getAbsolutePath(llvm::vfs::FileSystem &FS,
StringRef File) {
StringRef RelativePath(File);
// FIXME: Should '.\\' be accepted on Win32?
- if (RelativePath.startswith("./")) {
+ if (RelativePath.starts_with("./")) {
RelativePath = RelativePath.substr(strlen("./"));
}
@@ -294,9 +294,9 @@ void addTargetAndModeForProgramName(std::vector<std::string> &CommandLine,
for (auto Token = ++CommandLine.begin(); Token != CommandLine.end();
++Token) {
StringRef TokenRef(*Token);
- ShouldAddTarget = ShouldAddTarget && !TokenRef.startswith(TargetOPT) &&
+ ShouldAddTarget = ShouldAddTarget && !TokenRef.starts_with(TargetOPT) &&
!TokenRef.equals(TargetOPTLegacy);
- ShouldAddMode = ShouldAddMode && !TokenRef.startswith(DriverModeOPT);
+ ShouldAddMode = ShouldAddMode && !TokenRef.starts_with(DriverModeOPT);
}
if (ShouldAddMode) {
CommandLine.insert(++CommandLine.begin(), TargetMode.DriverMode);
@@ -507,7 +507,7 @@ static void injectResourceDir(CommandLineArguments &Args, const char *Argv0,
void *MainAddr) {
// Allow users to override the resource dir.
for (StringRef Arg : Args)
- if (Arg.startswith("-resource-dir"))
+ if (Arg.starts_with("-resource-dir"))
return;
// If there's no override in place add our resource dir.
diff --git a/clang/lib/Tooling/Transformer/SourceCode.cpp b/clang/lib/Tooling/Transformer/SourceCode.cpp
index 3000953..6aae834 100644
--- a/clang/lib/Tooling/Transformer/SourceCode.cpp
+++ b/clang/lib/Tooling/Transformer/SourceCode.cpp
@@ -425,7 +425,7 @@ CharSourceRange tooling::getAssociatedRange(const Decl &Decl,
for (llvm::StringRef Prefix : {"[[", "__attribute__(("}) {
// Handle whitespace between attribute prefix and attribute value.
- if (BeforeAttrStripped.endswith(Prefix)) {
+ if (BeforeAttrStripped.ends_with(Prefix)) {
// Move start to start position of prefix, which is
// length(BeforeAttr) - length(BeforeAttrStripped) + length(Prefix)
// positions to the left.
diff --git a/clang/tools/arcmt-test/arcmt-test.cpp b/clang/tools/arcmt-test/arcmt-test.cpp
index 53229ac..b61f38e 100644
--- a/clang/tools/arcmt-test/arcmt-test.cpp
+++ b/clang/tools/arcmt-test/arcmt-test.cpp
@@ -230,7 +230,7 @@ static bool verifyTransformedFiles(ArrayRef<std::string> resultFiles) {
for (ArrayRef<std::string>::iterator
I = resultFiles.begin(), E = resultFiles.end(); I != E; ++I) {
StringRef fname(*I);
- if (!fname.endswith(".result")) {
+ if (!fname.ends_with(".result")) {
errs() << "error: filename '" << fname
<< "' does not have '.result' extension\n";
return true;
diff --git a/clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp b/clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
index 769727e..c048f33 100644
--- a/clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
+++ b/clang/tools/clang-extdef-mapping/ClangExtDefMapGen.cpp
@@ -181,7 +181,7 @@ static int HandleFiles(ArrayRef<std::string> SourceFiles,
// process them directly in HandleAST, otherwise put them
// on a list for ClangTool to handle.
for (StringRef Src : SourceFiles) {
- if (Src.endswith(".ast")) {
+ if (Src.ends_with(".ast")) {
if (!HandleAST(Src)) {
return 1;
}
diff --git a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
index 5d2fe98..bd2fd02 100644
--- a/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
+++ b/clang/tools/clang-linker-wrapper/ClangLinkerWrapper.cpp
@@ -1151,7 +1151,7 @@ linkAndWrapDeviceFiles(SmallVectorImpl<OffloadFile> &LinkerInputFiles,
std::optional<std::string> findFile(StringRef Dir, StringRef Root,
const Twine &Name) {
SmallString<128> Path;
- if (Dir.startswith("="))
+ if (Dir.starts_with("="))
sys::path::append(Path, Root, Dir.substr(1), Name);
else
sys::path::append(Path, Dir, Name);
@@ -1188,7 +1188,7 @@ searchLibraryBaseName(StringRef Name, StringRef Root,
/// `-lfoo` or `-l:libfoo.a`.
std::optional<std::string> searchLibrary(StringRef Input, StringRef Root,
ArrayRef<StringRef> SearchPaths) {
- if (Input.startswith(":") || Input.ends_with(".lib"))
+ if (Input.starts_with(":") || Input.ends_with(".lib"))
return findFromSearchPaths(Input.drop_front(), Root, SearchPaths);
return searchLibraryBaseName(Input, Root, SearchPaths);
}
diff --git a/clang/tools/clang-refactor/ClangRefactor.cpp b/clang/tools/clang-refactor/ClangRefactor.cpp
index d362eec..175a2b8 100644
--- a/clang/tools/clang-refactor/ClangRefactor.cpp
+++ b/clang/tools/clang-refactor/ClangRefactor.cpp
@@ -146,7 +146,7 @@ private:
std::unique_ptr<SourceSelectionArgument>
SourceSelectionArgument::fromString(StringRef Value) {
- if (Value.startswith("test:")) {
+ if (Value.starts_with("test:")) {
StringRef Filename = Value.drop_front(strlen("test:"));
std::optional<TestSelectionRangesInFile> ParsedTestSelection =
findTestSelectionRanges(Filename);
diff --git a/clang/tools/clang-repl/ClangRepl.cpp b/clang/tools/clang-repl/ClangRepl.cpp
index 5663c2c..b9b2871 100644
--- a/clang/tools/clang-repl/ClangRepl.cpp
+++ b/clang/tools/clang-repl/ClangRepl.cpp
@@ -234,7 +234,7 @@ int main(int argc, const char **argv) {
while (std::optional<std::string> Line = LE.readLine()) {
llvm::StringRef L = *Line;
L = L.trim();
- if (L.endswith("\\")) {
+ if (L.ends_with("\\")) {
// FIXME: Support #ifdef X \ ...
Input += L.drop_back(1);
LE.setPrompt("clang-repl... ");
diff --git a/clang/tools/clang-scan-deps/ClangScanDeps.cpp b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
index f11c933..75aa4ae 100644
--- a/clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ b/clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -830,9 +830,9 @@ int clang_scan_deps_main(int argc, char **argv, const llvm::ToolContext &) {
// Also, clang-cl adds ".obj" extension if none is found.
if ((Arg == "-o" || Arg == "/o") && I != R)
LastO = I[-1]; // Next argument (reverse iterator)
- else if (Arg.startswith("/Fo") || Arg.startswith("-Fo"))
+ else if (Arg.starts_with("/Fo") || Arg.starts_with("-Fo"))
LastO = Arg.drop_front(3).str();
- else if (Arg.startswith("/o") || Arg.startswith("-o"))
+ else if (Arg.starts_with("/o") || Arg.starts_with("-o"))
LastO = Arg.drop_front(2).str();
if (!LastO.empty() && !llvm::sys::path::has_extension(LastO))
diff --git a/clang/tools/diagtool/TreeView.cpp b/clang/tools/diagtool/TreeView.cpp
index 4f5d3fd..eae1624 100644
--- a/clang/tools/diagtool/TreeView.cpp
+++ b/clang/tools/diagtool/TreeView.cpp
@@ -160,7 +160,7 @@ int TreeView::run(unsigned int argc, char **argv, llvm::raw_ostream &out) {
break;
case 1:
RootGroup = argv[0];
- if (RootGroup.startswith("-W"))
+ if (RootGroup.starts_with("-W"))
RootGroup = RootGroup.substr(2);
if (RootGroup == "everything")
ShowAll = true;
diff --git a/clang/tools/driver/driver.cpp b/clang/tools/driver/driver.cpp
index 531b5b4..4adc7f7 100644
--- a/clang/tools/driver/driver.cpp
+++ b/clang/tools/driver/driver.cpp
@@ -122,7 +122,7 @@ static void ApplyOneQAOverride(raw_ostream &OS,
GetStableCStr(SavedStrings, Edit.substr(1));
OS << "### Adding argument " << Str << " at end\n";
Args.push_back(Str);
- } else if (Edit[0] == 's' && Edit[1] == '/' && Edit.endswith("/") &&
+ } else if (Edit[0] == 's' && Edit[1] == '/' && Edit.ends_with("/") &&
Edit.slice(2, Edit.size() - 1).contains('/')) {
StringRef MatchPattern = Edit.substr(2).split('/').first;
StringRef ReplPattern = Edit.substr(2).split('/').second;
@@ -403,7 +403,7 @@ int clang_main(int Argc, char **Argv, const llvm::ToolContext &ToolContext) {
}
// Handle -cc1 integrated tools.
- if (Args.size() >= 2 && StringRef(Args[1]).startswith("-cc1"))
+ if (Args.size() >= 2 && StringRef(Args[1]).starts_with("-cc1"))
return ExecuteCC1Tool(Args, ToolContext);
// Handle options that need handling before the real command line parsing in
diff --git a/clang/tools/libclang/CIndexUSRs.cpp b/clang/tools/libclang/CIndexUSRs.cpp
index 75bb3b0..be7c670 100644
--- a/clang/tools/libclang/CIndexUSRs.cpp
+++ b/clang/tools/libclang/CIndexUSRs.cpp
@@ -28,7 +28,7 @@ using namespace clang::index;
//===----------------------------------------------------------------------===//
static inline StringRef extractUSRSuffix(StringRef s) {
- return s.startswith("c:") ? s.substr(2) : "";
+ return s.starts_with("c:") ? s.substr(2) : "";
}
bool cxcursor::getDeclCursorUSR(const Decl *D, SmallVectorImpl<char> &Buf) {
diff --git a/clang/unittests/Analysis/CloneDetectionTest.cpp b/clang/unittests/Analysis/CloneDetectionTest.cpp
index fe65fab..738f6efd 100644
--- a/clang/unittests/Analysis/CloneDetectionTest.cpp
+++ b/clang/unittests/Analysis/CloneDetectionTest.cpp
@@ -42,7 +42,7 @@ public:
for (const StmtSequence &Arg : {A, B}) {
if (const auto *D =
dyn_cast<const FunctionDecl>(Arg.getContainingDecl())) {
- if (D->getName().startswith("bar"))
+ if (D->getName().starts_with("bar"))
return false;
}
}
diff --git a/clang/unittests/Driver/ModuleCacheTest.cpp b/clang/unittests/Driver/ModuleCacheTest.cpp
index 6a0f68f..4874441 100644
--- a/clang/unittests/Driver/ModuleCacheTest.cpp
+++ b/clang/unittests/Driver/ModuleCacheTest.cpp
@@ -22,6 +22,6 @@ TEST(ModuleCacheTest, GetTargetAndMode) {
Driver::getDefaultModuleCachePath(Buf);
StringRef Path = Buf;
EXPECT_TRUE(Path.find("clang") != Path.npos);
- EXPECT_TRUE(Path.endswith("ModuleCache"));
+ EXPECT_TRUE(Path.ends_with("ModuleCache"));
}
} // end anonymous namespace.
diff --git a/clang/unittests/Driver/MultilibBuilderTest.cpp b/clang/unittests/Driver/MultilibBuilderTest.cpp
index 60fe10a..e23fe7e 100644
--- a/clang/unittests/Driver/MultilibBuilderTest.cpp
+++ b/clang/unittests/Driver/MultilibBuilderTest.cpp
@@ -144,7 +144,7 @@ TEST(MultilibBuilderTest, SetFilterObject) {
<< "Size before filter was incorrect. Contents:\n"
<< MS;
MS.FilterOut([](const Multilib &M) {
- return StringRef(M.gccSuffix()).startswith("/p");
+ return StringRef(M.gccSuffix()).starts_with("/p");
});
ASSERT_EQ((int)MS.size(), 1 /* Default */ + 1 /* orange */ +
1 /* orange/pear */ + 1 /* orange/plum */ +
@@ -152,7 +152,7 @@ TEST(MultilibBuilderTest, SetFilterObject) {
<< "Size after filter was incorrect. Contents:\n"
<< MS;
for (MultilibSet::const_iterator I = MS.begin(), E = MS.end(); I != E; ++I) {
- ASSERT_FALSE(StringRef(I->gccSuffix()).startswith("/p"))
+ ASSERT_FALSE(StringRef(I->gccSuffix()).starts_with("/p"))
<< "The filter should have removed " << *I;
}
}
diff --git a/clang/unittests/Driver/ToolChainTest.cpp b/clang/unittests/Driver/ToolChainTest.cpp
index acbbb87..a9b5f3c 100644
--- a/clang/unittests/Driver/ToolChainTest.cpp
+++ b/clang/unittests/Driver/ToolChainTest.cpp
@@ -531,7 +531,7 @@ TEST(ToolChainTest, CommandOutput) {
const auto &InFile = CmdCompile->getInputInfos().front().getFilename();
EXPECT_STREQ(InFile, "foo.cpp");
auto ObjFile = CmdCompile->getOutputFilenames().front();
- EXPECT_TRUE(StringRef(ObjFile).endswith(".o"));
+ EXPECT_TRUE(StringRef(ObjFile).ends_with(".o"));
const auto &CmdLink = Jobs.getJobs().back();
const auto LinkInFile = CmdLink->getInputInfos().front().getFilename();
diff --git a/clang/unittests/Frontend/OutputStreamTest.cpp b/clang/unittests/Frontend/OutputStreamTest.cpp
index 9cb101e..7d360f6 100644
--- a/clang/unittests/Frontend/OutputStreamTest.cpp
+++ b/clang/unittests/Frontend/OutputStreamTest.cpp
@@ -42,7 +42,7 @@ TEST(FrontendOutputTests, TestOutputStream) {
bool Success = ExecuteCompilerInvocation(&Compiler);
EXPECT_TRUE(Success);
EXPECT_TRUE(!IRBuffer.empty());
- EXPECT_TRUE(StringRef(IRBuffer.data()).startswith("BC"));
+ EXPECT_TRUE(StringRef(IRBuffer.data()).starts_with("BC"));
}
TEST(FrontendOutputTests, TestVerboseOutputStreamShared) {
diff --git a/clang/unittests/Interpreter/IncrementalProcessingTest.cpp b/clang/unittests/Interpreter/IncrementalProcessingTest.cpp
index f43b3dd..accdf68 100644
--- a/clang/unittests/Interpreter/IncrementalProcessingTest.cpp
+++ b/clang/unittests/Interpreter/IncrementalProcessingTest.cpp
@@ -44,7 +44,7 @@ const char TestProgram2[] = "extern \"C\" int funcForProg2() { return 42; }\n"
const Function *getGlobalInit(llvm::Module *M) {
for (const auto &Func : *M)
- if (Func.hasName() && Func.getName().startswith("_GLOBAL__sub_I_"))
+ if (Func.hasName() && Func.getName().starts_with("_GLOBAL__sub_I_"))
return &Func;
return nullptr;
diff --git a/clang/unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp b/clang/unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp
index cd78014..aace4b9 100644
--- a/clang/unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp
+++ b/clang/unittests/StaticAnalyzer/AnalyzerOptionsTest.cpp
@@ -15,10 +15,10 @@ namespace ento {
TEST(StaticAnalyzerOptions, getRegisteredCheckers) {
auto IsDebugChecker = [](StringRef CheckerName) {
- return CheckerName.startswith("debug");
+ return CheckerName.starts_with("debug");
};
auto IsAlphaChecker = [](StringRef CheckerName) {
- return CheckerName.startswith("alpha");
+ return CheckerName.starts_with("alpha");
};
const auto &AllCheckers =
AnalyzerOptions::getRegisteredCheckers(/*IncludeExperimental=*/true);
diff --git a/clang/unittests/Tooling/HeaderIncludesTest.cpp b/clang/unittests/Tooling/HeaderIncludesTest.cpp
index 256aa82..929156a 100644
--- a/clang/unittests/Tooling/HeaderIncludesTest.cpp
+++ b/clang/unittests/Tooling/HeaderIncludesTest.cpp
@@ -23,9 +23,9 @@ protected:
std::string insert(llvm::StringRef Code, llvm::StringRef Header,
IncludeDirective Directive = IncludeDirective::Include) {
HeaderIncludes Includes(FileName, Code, Style);
- assert(Header.startswith("\"") || Header.startswith("<"));
- auto R =
- Includes.insert(Header.trim("\"<>"), Header.startswith("<"), Directive);
+ assert(Header.starts_with("\"") || Header.starts_with("<"));
+ auto R = Includes.insert(Header.trim("\"<>"), Header.starts_with("<"),
+ Directive);
if (!R)
return std::string(Code);
auto Result = applyAllReplacements(Code, Replacements(*R));
@@ -35,8 +35,9 @@ protected:
std::string remove(llvm::StringRef Code, llvm::StringRef Header) {
HeaderIncludes Includes(FileName, Code, Style);
- assert(Header.startswith("\"") || Header.startswith("<"));
- auto Replaces = Includes.remove(Header.trim("\"<>"), Header.startswith("<"));
+ assert(Header.starts_with("\"") || Header.starts_with("<"));
+ auto Replaces =
+ Includes.remove(Header.trim("\"<>"), Header.starts_with("<"));
auto Result = applyAllReplacements(Code, Replaces);
EXPECT_TRUE(static_cast<bool>(Result));
return *Result;
diff --git a/clang/unittests/libclang/LibclangTest.cpp b/clang/unittests/libclang/LibclangTest.cpp
index 60904bc..87075a4 100644
--- a/clang/unittests/libclang/LibclangTest.cpp
+++ b/clang/unittests/libclang/LibclangTest.cpp
@@ -451,8 +451,8 @@ public:
const auto Filename = llvm::sys::path::filename(File->path());
EXPECT_EQ(Filename.size(), std::strlen("preamble-%%%%%%.pch"));
- EXPECT_TRUE(Filename.startswith("preamble-"));
- EXPECT_TRUE(Filename.endswith(".pch"));
+ EXPECT_TRUE(Filename.starts_with("preamble-"));
+ EXPECT_TRUE(Filename.ends_with(".pch"));
const auto Status = File->status();
ASSERT_TRUE(Status);
@@ -659,7 +659,7 @@ TEST_F(LibclangReparseTest, FileName) {
clang_disposeString(cxname);
cxname = clang_File_tryGetRealPathName(cxf);
- ASSERT_TRUE(llvm::StringRef(clang_getCString(cxname)).endswith("main.cpp"));
+ ASSERT_TRUE(llvm::StringRef(clang_getCString(cxname)).ends_with("main.cpp"));
clang_disposeString(cxname);
}
diff --git a/clang/utils/TableGen/ASTTableGen.cpp b/clang/utils/TableGen/ASTTableGen.cpp
index 60f563d..54288ff 100644
--- a/clang/utils/TableGen/ASTTableGen.cpp
+++ b/clang/utils/TableGen/ASTTableGen.cpp
@@ -33,7 +33,7 @@ llvm::StringRef clang::tblgen::HasProperties::getName() const {
static StringRef removeExpectedNodeNameSuffix(Record *node, StringRef suffix) {
StringRef nodeName = node->getName();
- if (!nodeName.endswith(suffix)) {
+ if (!nodeName.ends_with(suffix)) {
PrintFatalError(node->getLoc(),
Twine("name of node doesn't end in ") + suffix);
}
diff --git a/clang/utils/TableGen/MveEmitter.cpp b/clang/utils/TableGen/MveEmitter.cpp
index fae889d..f0bd086 100644
--- a/clang/utils/TableGen/MveEmitter.cpp
+++ b/clang/utils/TableGen/MveEmitter.cpp
@@ -882,7 +882,7 @@ public:
} else if (V->varnameUsed()) {
std::string Type = V->typeName();
OS << V->typeName();
- if (!StringRef(Type).endswith("*"))
+ if (!StringRef(Type).ends_with("*"))
OS << " ";
OS << V->varname() << " = ";
}
@@ -1680,7 +1680,7 @@ void EmitterBase::EmitBuiltinCG(raw_ostream &OS) {
for (size_t i = 0, e = MG.ParamTypes.size(); i < e; ++i) {
StringRef Type = MG.ParamTypes[i];
OS << " " << Type;
- if (!Type.endswith("*"))
+ if (!Type.ends_with("*"))
OS << " ";
OS << " Param" << utostr(i) << ";\n";
}
@@ -1833,7 +1833,7 @@ void MveEmitter::EmitHeader(raw_ostream &OS) {
// prototype.
std::string RetTypeName = Int.returnType()->cName();
- if (!StringRef(RetTypeName).endswith("*"))
+ if (!StringRef(RetTypeName).ends_with("*"))
RetTypeName += " ";
std::vector<std::string> ArgTypeNames;
@@ -2078,7 +2078,7 @@ void CdeEmitter::EmitHeader(raw_ostream &OS) {
// Make strings for the types involved in the function's
// prototype.
std::string RetTypeName = Int.returnType()->cName();
- if (!StringRef(RetTypeName).endswith("*"))
+ if (!StringRef(RetTypeName).ends_with("*"))
RetTypeName += " ";
std::vector<std::string> ArgTypeNames;