-
Notifications
You must be signed in to change notification settings - Fork 11.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[llvm] Use operator==(StringRef, StringRef) (NFC) #92705
Merged
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_StringRef_compare_llvm
May 19, 2024
Merged
[llvm] Use operator==(StringRef, StringRef) (NFC) #92705
kazutakahirata
merged 1 commit into
llvm:main
from
kazutakahirata:cleanup_StringRef_compare_llvm
May 19, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@llvm/pr-subscribers-backend-spir-v @llvm/pr-subscribers-backend-x86 Author: Kazu Hirata (kazutakahirata) ChangesFull diff: https://github.com/llvm/llvm-project/pull/92705.diff 4 Files Affected:
diff --git a/llvm/lib/Option/OptTable.cpp b/llvm/lib/Option/OptTable.cpp
index b8b6b90c253f2..3eceb0fbdfc47 100644
--- a/llvm/lib/Option/OptTable.cpp
+++ b/llvm/lib/Option/OptTable.cpp
@@ -197,7 +197,7 @@ OptTable::suggestValueCompletions(StringRef Option, StringRef Arg) const {
std::vector<std::string> Result;
for (StringRef Val : Candidates)
- if (Val.starts_with(Arg) && Arg.compare(Val))
+ if (Val.starts_with(Arg) && Arg != Val)
Result.push_back(std::string(Val));
return Result;
}
diff --git a/llvm/lib/ProfileData/InstrProfCorrelator.cpp b/llvm/lib/ProfileData/InstrProfCorrelator.cpp
index cf80a58f43bd9..44e2aeb00d8cc 100644
--- a/llvm/lib/ProfileData/InstrProfCorrelator.cpp
+++ b/llvm/lib/ProfileData/InstrProfCorrelator.cpp
@@ -350,16 +350,14 @@ void DwarfInstrProfCorrelator<IntPtrT>::correlateProfileDataImpl(
continue;
}
StringRef AnnotationName = *AnnotationNameOrErr;
- if (AnnotationName.compare(
- InstrProfCorrelator::FunctionNameAttributeName) == 0) {
+ if (AnnotationName == InstrProfCorrelator::FunctionNameAttributeName) {
if (auto EC =
AnnotationFormValue->getAsCString().moveInto(FunctionName))
consumeError(std::move(EC));
- } else if (AnnotationName.compare(
- InstrProfCorrelator::CFGHashAttributeName) == 0) {
+ } else if (AnnotationName == InstrProfCorrelator::CFGHashAttributeName) {
CFGHash = AnnotationFormValue->getAsUnsignedConstant();
- } else if (AnnotationName.compare(
- InstrProfCorrelator::NumCountersAttributeName) == 0) {
+ } else if (AnnotationName ==
+ InstrProfCorrelator::NumCountersAttributeName) {
NumCounters = AnnotationFormValue->getAsUnsignedConstant();
}
}
diff --git a/llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp b/llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
index 727e4e584c053..f4daab7d06eb5 100644
--- a/llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVCallLowering.cpp
@@ -171,9 +171,9 @@ getArgAccessQual(const Function &F, unsigned ArgIdx) {
if (!ArgAttribute)
return SPIRV::AccessQualifier::ReadWrite;
- if (ArgAttribute->getString().compare("read_only") == 0)
+ if (ArgAttribute->getString() == "read_only")
return SPIRV::AccessQualifier::ReadOnly;
- if (ArgAttribute->getString().compare("write_only") == 0)
+ if (ArgAttribute->getString() == "write_only")
return SPIRV::AccessQualifier::WriteOnly;
return SPIRV::AccessQualifier::ReadWrite;
}
@@ -181,7 +181,7 @@ getArgAccessQual(const Function &F, unsigned ArgIdx) {
static std::vector<SPIRV::Decoration::Decoration>
getKernelArgTypeQual(const Function &F, unsigned ArgIdx) {
MDString *ArgAttribute = getOCLKernelArgTypeQual(F, ArgIdx);
- if (ArgAttribute && ArgAttribute->getString().compare("volatile") == 0)
+ if (ArgAttribute && ArgAttribute->getString() == "volatile")
return {SPIRV::Decoration::Volatile};
return {};
}
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index 62b4a9278954c..6623106109316 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -1802,7 +1802,7 @@ bool X86AsmParser::ParseIntelNamedOperator(StringRef Name,
bool &ParseError, SMLoc &End) {
// A named operator should be either lower or upper case, but not a mix...
// except in MASM, which uses full case-insensitivity.
- if (Name.compare(Name.lower()) && Name.compare(Name.upper()) &&
+ if (Name != Name.lower() && Name != Name.upper() &&
!getParser().isParsingMasm())
return false;
if (Name.equals_insensitive("not")) {
|
MaskRay
approved these changes
May 19, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
No description provided.