[clang] 4567c11 - [clang] Use llvm::binary_search (NFC) (#140216)
via cfe-commits
cfe-commits at lists.llvm.org
Fri May 16 07:32:48 PDT 2025
Author: Kazu Hirata
Date: 2025-05-16T07:32:44-07:00
New Revision: 4567c11d284fe404df80fb3293dac3e2aa85b79e
URL: https://github.com/llvm/llvm-project/commit/4567c11d284fe404df80fb3293dac3e2aa85b79e
DIFF: https://github.com/llvm/llvm-project/commit/4567c11d284fe404df80fb3293dac3e2aa85b79e.diff
LOG: [clang] Use llvm::binary_search (NFC) (#140216)
Added:
Modified:
clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
clang/lib/Format/Format.cpp
clang/lib/Format/FormatToken.cpp
clang/lib/Frontend/DiagnosticRenderer.cpp
clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
clang/lib/Lex/PPDirectives.cpp
Removed:
################################################################################
diff --git a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
index 543ac8ab2ab12..7d0c2d8658f35 100644
--- a/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ b/clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -311,8 +311,7 @@ class AnalyzerOptions {
return AnalyzerConfigCmdFlags;
}();
- return !std::binary_search(AnalyzerConfigCmdFlags.begin(),
- AnalyzerConfigCmdFlags.end(), Name);
+ return !llvm::binary_search(AnalyzerConfigCmdFlags, Name);
}
AnalyzerOptions()
diff --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 20b5352b83a9e..7e32d2084d5ab 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -3091,9 +3091,8 @@ class ObjCHeaderStyleGuesser : public TokenAnalyzer {
FormatTok->isOneOf(tok::numeric_constant, tok::l_square,
tok::l_brace))) ||
(FormatTok->Tok.isAnyIdentifier() &&
- std::binary_search(std::begin(FoundationIdentifiers),
- std::end(FoundationIdentifiers),
- FormatTok->TokenText)) ||
+ llvm::binary_search(FoundationIdentifiers,
+ FormatTok->TokenText)) ||
FormatTok->is(TT_ObjCStringLiteral) ||
FormatTok->isOneOf(Keywords.kw_NS_CLOSED_ENUM, Keywords.kw_NS_ENUM,
Keywords.kw_NS_ERROR_ENUM,
diff --git a/clang/lib/Format/FormatToken.cpp b/clang/lib/Format/FormatToken.cpp
index 1d49d787f9cc9..e0867f6dcce06 100644
--- a/clang/lib/Format/FormatToken.cpp
+++ b/clang/lib/Format/FormatToken.cpp
@@ -45,8 +45,7 @@ bool FormatToken::isTypeName(const LangOptions &LangOpts) const {
if (is(TT_TypeName) || Tok.isSimpleTypeSpecifier(LangOpts))
return true;
return (LangOpts.CXXOperatorNames || LangOpts.C11) && is(tok::identifier) &&
- std::binary_search(CppNonKeywordTypes.begin(),
- CppNonKeywordTypes.end(), TokenText);
+ llvm::binary_search(CppNonKeywordTypes, TokenText);
}
bool FormatToken::isTypeOrIdentifier(const LangOptions &LangOpts) const {
diff --git a/clang/lib/Frontend/DiagnosticRenderer.cpp b/clang/lib/Frontend/DiagnosticRenderer.cpp
index b11806637efda..3b120abbc3a7a 100644
--- a/clang/lib/Frontend/DiagnosticRenderer.cpp
+++ b/clang/lib/Frontend/DiagnosticRenderer.cpp
@@ -272,8 +272,7 @@ retrieveMacroLocation(SourceLocation Loc, FileID MacroFileID,
if (SM->isMacroArgExpansion(Loc)) {
// Only look at the immediate spelling location of this macro argument if
// the other location in the source range is also present in that expansion.
- if (std::binary_search(CommonArgExpansions.begin(),
- CommonArgExpansions.end(), MacroFileID))
+ if (llvm::binary_search(CommonArgExpansions, MacroFileID))
MacroRange =
CharSourceRange(SM->getImmediateSpellingLoc(Loc), IsTokenRange);
MacroArgRange = SM->getImmediateExpansionRange(Loc);
diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
index 6de19d689988e..89fda3e839cb9 100644
--- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
+++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
@@ -482,7 +482,7 @@ static bool ParseDirective(StringRef S, ExpectedData *ED, SourceManager &SM,
// What's left in DToken is the actual prefix. That might not be a -verify
// prefix even if there is only one -verify prefix (for example, the full
// DToken is foo-bar-warning, but foo is the only -verify prefix).
- if (!std::binary_search(Prefixes.begin(), Prefixes.end(), DToken))
+ if (!llvm::binary_search(Prefixes, DToken))
continue;
if (NoDiag) {
diff --git a/clang/lib/Lex/PPDirectives.cpp b/clang/lib/Lex/PPDirectives.cpp
index c2bab9118234c..b2a8459d6b9cc 100644
--- a/clang/lib/Lex/PPDirectives.cpp
+++ b/clang/lib/Lex/PPDirectives.cpp
@@ -148,8 +148,7 @@ static bool isFeatureTestMacro(StringRef MacroName) {
"__STDCPP_WANT_MATH_SPEC_FUNCS__",
"__STDC_FORMAT_MACROS",
};
- return std::binary_search(std::begin(ReservedMacro), std::end(ReservedMacro),
- MacroName);
+ return llvm::binary_search(ReservedMacro, MacroName);
}
static bool isLanguageDefinedBuiltin(const SourceManager &SourceMgr,
More information about the cfe-commits
mailing list