[clang-tools-extra] [flang] [lld] [llvm] Use StringRef::operator== instead of StringRef::equals (NFC) (PR #91864)
https://github.com/kazutakahirata closed https://github.com/llvm/llvm-project/pull/91864 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [flang] [lld] [llvm] Use StringRef::operator== instead of StringRef::equals (NFC) (PR #91864)
https://github.com/kuhar approved this pull request. https://github.com/llvm/llvm-project/pull/91864 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [flang] [lld] [llvm] Use StringRef::operator== instead of StringRef::equals (NFC) (PR #91864)
https://github.com/aaupov approved this pull request. BOLT changes LGTM https://github.com/llvm/llvm-project/pull/91864 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[clang-tools-extra] [flang] [lld] [llvm] Use StringRef::operator== instead of StringRef::equals (NFC) (PR #91864)
llvmbot wrote: @llvm/pr-subscribers-lld @llvm/pr-subscribers-platform-windows @llvm/pr-subscribers-flang-driver Author: Kazu Hirata (kazutakahirata) Changes I'm planning to remove StringRef::equals in favor of StringRef::operator==. - StringRef::operator==/!= outnumber StringRef::equals by a factor of 276 under llvm-project/ 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". --- Full diff: https://github.com/llvm/llvm-project/pull/91864.diff 19 Files Affected: - (modified) bolt/lib/Profile/DataAggregator.cpp (+1-1) - (modified) bolt/lib/Profile/DataReader.cpp (+1-2) - (modified) bolt/lib/Rewrite/DWARFRewriter.cpp (+5-5) - (modified) bolt/lib/Rewrite/SDTRewriter.cpp (+1-1) - (modified) clang-tools-extra/clang-tidy/ClangTidyCheck.cpp (+1-1) - (modified) clang-tools-extra/clang-tidy/bugprone/ForwardingReferenceOverloadCheck.cpp (+2-2) - (modified) clang-tools-extra/clang-tidy/modernize/LoopConvertCheck.cpp (+1-1) - (modified) clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp (+1-1) - (modified) clang-tools-extra/clang-tidy/readability/SuspiciousCallArgumentCheck.cpp (+2-2) - (modified) clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp (+1-2) - (modified) clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp (+1-1) - (modified) flang/lib/Frontend/CompilerInvocation.cpp (+2-2) - (modified) flang/lib/Optimizer/Builder/IntrinsicCall.cpp (+1-1) - (modified) flang/lib/Optimizer/CodeGen/CodeGen.cpp (+4-4) - (modified) lld/COFF/DebugTypes.cpp (+1-1) - (modified) lld/ELF/InputSection.cpp (+1-1) - (modified) lld/ELF/Writer.cpp (+1-1) - (modified) lld/MachO/Driver.cpp (+1-1) - (modified) lld/wasm/InputChunks.cpp (+2-2) ``diff diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp index 2f6380e186e1d..f199d499a180f 100644 --- a/bolt/lib/Profile/DataAggregator.cpp +++ b/bolt/lib/Profile/DataAggregator.cpp @@ -1999,7 +1999,7 @@ std::error_code DataAggregator::parseMMapEvents() { std::pair FileMMapInfo = FileMMapInfoRes.get(); if (FileMMapInfo.second.PID == -1) continue; -if (FileMMapInfo.first.equals("(deleted)")) +if (FileMMapInfo.first == "(deleted)") continue; // Consider only the first mapping of the file for any given PID diff --git a/bolt/lib/Profile/DataReader.cpp b/bolt/lib/Profile/DataReader.cpp index 67f357fe4d3f0..b2511ba103998 100644 --- a/bolt/lib/Profile/DataReader.cpp +++ b/bolt/lib/Profile/DataReader.cpp @@ -1205,8 +1205,7 @@ std::error_code DataReader::parse() { // Add entry data for branches to another function or branches // to entry points (including recursive calls) -if (BI.To.IsSymbol && -(!BI.From.Name.equals(BI.To.Name) || BI.To.Offset == 0)) { +if (BI.To.IsSymbol && (BI.From.Name != BI.To.Name || BI.To.Offset == 0)) { I = GetOrCreateFuncEntry(BI.To.Name); I->second.EntryData.emplace_back(std::move(BI)); } diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp index 26e4889faadac..9d4297f913f3a 100644 --- a/bolt/lib/Rewrite/DWARFRewriter.cpp +++ b/bolt/lib/Rewrite/DWARFRewriter.cpp @@ -1550,7 +1550,7 @@ CUOffsetMap DWARFRewriter::finalizeTypeSections(DIEBuilder , for (const SectionRef : Obj->sections()) { StringRef Contents = cantFail(Section.getContents()); StringRef Name = cantFail(Section.getName()); -if (Name.equals(".debug_types")) +if (Name == ".debug_types") BC.registerOrUpdateNoteSection(".debug_types", copyByteArray(Contents), Contents.size()); } @@ -1633,10 +1633,10 @@ void DWARFRewriter::finalizeDebugSections( for (const SectionRef : Obj->sections()) { StringRef Contents = cantFail(Secs.getContents()); StringRef Name = cantFail(Secs.getName()); -if (Name.equals(".debug_abbrev")) { +if (Name == ".debug_abbrev") { BC.registerOrUpdateNoteSection(".debug_abbrev", copyByteArray(Contents), Contents.size()); -} else if (Name.equals(".debug_info")) { +} else if (Name == ".debug_info") { BC.registerOrUpdateNoteSection(".debug_info", copyByteArray(Contents), Contents.size()); } @@ -1771,7 +1771,7 @@ std::optional updateDebugData( }; switch (SectionIter->second.second) { default: { -if (!SectionName.equals("debug_str.dwo")) +if (SectionName != "debug_str.dwo") errs() << "BOLT-WARNING: unsupported debug section: " << SectionName << "\n"; return SectionContents; @@ -1959,7 +1959,7 @@ void DWARFRewriter::updateDWP(DWARFUnit , continue; } -if (SectionName.equals("debug_str.dwo")) { +if (SectionName
[clang-tools-extra] [flang] [lld] [llvm] Use StringRef::operator== instead of StringRef::equals (NFC) (PR #91864)
https://github.com/kazutakahirata created https://github.com/llvm/llvm-project/pull/91864 I'm planning to remove StringRef::equals in favor of StringRef::operator==. - StringRef::operator==/!= outnumber StringRef::equals by a factor of 276 under llvm-project/ 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". >From 2beeb9267a23341ff8c313ee52b1ffc36a889ab2 Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Fri, 26 Jan 2024 00:05:21 -0800 Subject: [PATCH] Use StringRef::operator== instead of StringRef::equals (NFC) I'm planning to remove StringRef::equals in favor of StringRef::operator==. - StringRef::operator==/!= outnumber StringRef::equals by a factor of 276 under llvm-project/ 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". --- bolt/lib/Profile/DataAggregator.cpp| 2 +- bolt/lib/Profile/DataReader.cpp| 3 +-- bolt/lib/Rewrite/DWARFRewriter.cpp | 10 +- bolt/lib/Rewrite/SDTRewriter.cpp | 2 +- clang-tools-extra/clang-tidy/ClangTidyCheck.cpp| 2 +- .../bugprone/ForwardingReferenceOverloadCheck.cpp | 4 ++-- .../clang-tidy/modernize/LoopConvertCheck.cpp | 2 +- .../clang-tidy/readability/IdentifierNamingCheck.cpp | 2 +- .../readability/SuspiciousCallArgumentCheck.cpp| 4 ++-- clang-tools-extra/clang-tidy/utils/IncludeSorter.cpp | 3 +-- .../clang-tidy/utils/RenamerClangTidyCheck.cpp | 2 +- flang/lib/Frontend/CompilerInvocation.cpp | 4 ++-- flang/lib/Optimizer/Builder/IntrinsicCall.cpp | 2 +- flang/lib/Optimizer/CodeGen/CodeGen.cpp| 8 lld/COFF/DebugTypes.cpp| 2 +- lld/ELF/InputSection.cpp | 2 +- lld/ELF/Writer.cpp | 2 +- lld/MachO/Driver.cpp | 2 +- lld/wasm/InputChunks.cpp | 4 ++-- 19 files changed, 30 insertions(+), 32 deletions(-) diff --git a/bolt/lib/Profile/DataAggregator.cpp b/bolt/lib/Profile/DataAggregator.cpp index 2f6380e186e1d..f199d499a180f 100644 --- a/bolt/lib/Profile/DataAggregator.cpp +++ b/bolt/lib/Profile/DataAggregator.cpp @@ -1999,7 +1999,7 @@ std::error_code DataAggregator::parseMMapEvents() { std::pair FileMMapInfo = FileMMapInfoRes.get(); if (FileMMapInfo.second.PID == -1) continue; -if (FileMMapInfo.first.equals("(deleted)")) +if (FileMMapInfo.first == "(deleted)") continue; // Consider only the first mapping of the file for any given PID diff --git a/bolt/lib/Profile/DataReader.cpp b/bolt/lib/Profile/DataReader.cpp index 67f357fe4d3f0..b2511ba103998 100644 --- a/bolt/lib/Profile/DataReader.cpp +++ b/bolt/lib/Profile/DataReader.cpp @@ -1205,8 +1205,7 @@ std::error_code DataReader::parse() { // Add entry data for branches to another function or branches // to entry points (including recursive calls) -if (BI.To.IsSymbol && -(!BI.From.Name.equals(BI.To.Name) || BI.To.Offset == 0)) { +if (BI.To.IsSymbol && (BI.From.Name != BI.To.Name || BI.To.Offset == 0)) { I = GetOrCreateFuncEntry(BI.To.Name); I->second.EntryData.emplace_back(std::move(BI)); } diff --git a/bolt/lib/Rewrite/DWARFRewriter.cpp b/bolt/lib/Rewrite/DWARFRewriter.cpp index 26e4889faadac..9d4297f913f3a 100644 --- a/bolt/lib/Rewrite/DWARFRewriter.cpp +++ b/bolt/lib/Rewrite/DWARFRewriter.cpp @@ -1550,7 +1550,7 @@ CUOffsetMap DWARFRewriter::finalizeTypeSections(DIEBuilder , for (const SectionRef : Obj->sections()) { StringRef Contents = cantFail(Section.getContents()); StringRef Name = cantFail(Section.getName()); -if (Name.equals(".debug_types")) +if (Name == ".debug_types") BC.registerOrUpdateNoteSection(".debug_types", copyByteArray(Contents), Contents.size()); } @@ -1633,10 +1633,10 @@ void DWARFRewriter::finalizeDebugSections( for (const SectionRef : Obj->sections()) { StringRef Contents = cantFail(Secs.getContents()); StringRef Name = cantFail(Secs.getName()); -if (Name.equals(".debug_abbrev")) { +if (Name == ".debug_abbrev") { BC.registerOrUpdateNoteSection(".debug_abbrev", copyByteArray(Contents), Contents.size()); -} else if (Name.equals(".debug_info")) { +} else if (Name == ".debug_info") { BC.registerOrUpdateNoteSection(".debug_info",