aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaDecl.cpp
diff options
context:
space:
mode:
authorKazu Hirata <kazu@google.com>2024-05-11 11:38:52 -0700
committerGitHub <noreply@github.com>2024-05-11 11:38:52 -0700
commitdeffae5da123b32098914d8346bf4358a6792bdc (patch)
tree3a630538c5cfebe966c39361c602095424c4d656 /clang/lib/Sema/SemaDecl.cpp
parent379b77773cf653352f30f8c7cca393f4df9389be (diff)
downloadllvm-deffae5da123b32098914d8346bf4358a6792bdc.zip
llvm-deffae5da123b32098914d8346bf4358a6792bdc.tar.gz
llvm-deffae5da123b32098914d8346bf4358a6792bdc.tar.bz2
[clang] Use StringRef::operator== instead of StringRef::equals (NFC) (#91844)
I'm planning to remove StringRef::equals in favor of StringRef::operator==. - StringRef::operator==/!= outnumber StringRef::equals by a factor of 24 under clang/ in terms of their usage. - The elimination of StringRef::equals brings StringRef closer to std::string_view, which has operator== but not equals. - S == "foo" is more readable than S.equals("foo"), especially for !Long.Expression.equals("str") vs Long.Expression != "str".
Diffstat (limited to 'clang/lib/Sema/SemaDecl.cpp')
-rw-r--r--clang/lib/Sema/SemaDecl.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index 590f378..fb91303 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -735,8 +735,8 @@ void Sema::DiagnoseUnknownTypeName(IdentifierInfo *&II,
<< II, CanRecover);
} else if (DeclContext *DC = computeDeclContext(*SS, false)) {
std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
- bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
- II->getName().equals(CorrectedStr);
+ bool DroppedSpecifier =
+ Corrected.WillReplaceSpecifier() && II->getName() == CorrectedStr;
diagnoseTypo(Corrected,
PDiag(IsTemplateName
? diag::err_no_member_template_suggest
@@ -1007,7 +1007,7 @@ Corrected:
} else {// FIXME: is this even reachable? Test it.
std::string CorrectedStr(Corrected.getAsString(getLangOpts()));
bool DroppedSpecifier = Corrected.WillReplaceSpecifier() &&
- Name->getName().equals(CorrectedStr);
+ Name->getName() == CorrectedStr;
diagnoseTypo(Corrected, PDiag(QualifiedDiag)
<< Name << computeDeclContext(SS, false)
<< DroppedSpecifier << SS.getRange());
@@ -16076,7 +16076,7 @@ static void diagnoseImplicitlyRetainedSelf(Sema &S) {
static bool methodHasName(const FunctionDecl *FD, StringRef Name) {
return isa<CXXMethodDecl>(FD) && FD->param_empty() &&
- FD->getDeclName().isIdentifier() && FD->getName().equals(Name);
+ FD->getDeclName().isIdentifier() && FD->getName() == Name;
}
bool Sema::CanBeGetReturnObject(const FunctionDecl *FD) {