Skip to content

Commit

Permalink
[clang-format][NFC] Minor improvement to FormatToken::isTypeName()
Browse files Browse the repository at this point in the history
  • Loading branch information
owenca committed Feb 1, 2025
1 parent f73f5af commit 280609c
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions clang/lib/Format/FormatToken.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,12 @@ static SmallVector<StringRef> CppNonKeywordTypes = {
};

bool FormatToken::isTypeName(const LangOptions &LangOpts) const {
if (is(TT_TypeName) || Tok.isSimpleTypeSpecifier(LangOpts))
return true;
const bool IsCpp = LangOpts.CXXOperatorNames;
return is(TT_TypeName) || Tok.isSimpleTypeSpecifier(LangOpts) ||
(IsCpp && is(tok::identifier) &&
std::binary_search(CppNonKeywordTypes.begin(),
CppNonKeywordTypes.end(), TokenText));
return IsCpp && is(tok::identifier) &&
std::binary_search(CppNonKeywordTypes.begin(),
CppNonKeywordTypes.end(), TokenText);
}

bool FormatToken::isTypeOrIdentifier(const LangOptions &LangOpts) const {
Expand Down

0 comments on commit 280609c

Please sign in to comment.