Skip to content

[clang] Use llvm::binary_search (NFC) #140216

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,7 @@ class AnalyzerOptions {
return AnalyzerConfigCmdFlags;
}();

return !std::binary_search(AnalyzerConfigCmdFlags.begin(),
AnalyzerConfigCmdFlags.end(), Name);
return !llvm::binary_search(AnalyzerConfigCmdFlags, Name);
}

AnalyzerOptions()
Expand Down
5 changes: 2 additions & 3 deletions clang/lib/Format/Format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/Format/FormatToken.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/Frontend/DiagnosticRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Frontend/VerifyDiagnosticConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/Lex/PPDirectives.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down