From 280609c215e4a684cad215ea5be913293de0d255 Mon Sep 17 00:00:00 2001 From: Owen Pan Date: Fri, 31 Jan 2025 18:47:20 -0800 Subject: [PATCH] [clang-format][NFC] Minor improvement to FormatToken::isTypeName() --- clang/lib/Format/FormatToken.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/clang/lib/Format/FormatToken.cpp b/clang/lib/Format/FormatToken.cpp index 963e8f87793fa0..99bce1f5f09851 100644 --- a/clang/lib/Format/FormatToken.cpp +++ b/clang/lib/Format/FormatToken.cpp @@ -42,11 +42,12 @@ static SmallVector 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 {