[clang] 0556ab3 - [clang-format][NFC] Improve efficiency of isFunctionDeclarationName

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Fri Jul 7 16:29:43 PDT 2023


Author: Owen Pan
Date: 2023-07-07T16:29:36-07:00
New Revision: 0556ab33532964dd8720b3b3ebd87dfe459d81d2

URL: https://github.com/llvm/llvm-project/commit/0556ab33532964dd8720b3b3ebd87dfe459d81d2
DIFF: https://github.com/llvm/llvm-project/commit/0556ab33532964dd8720b3b3ebd87dfe459d81d2.diff

LOG: [clang-format][NFC] Improve efficiency of isFunctionDeclarationName

Return immediately in isFunctionDeclarationName() if the token is neither a
keyword nor an identifier.

Added: 
    

Modified: 
    clang/lib/Format/TokenAnnotator.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 2ffa07bffa1f32..7bec899754362d 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -3129,6 +3129,9 @@ void TokenAnnotator::annotate(AnnotatedLine &Line) {
 static bool isFunctionDeclarationName(bool IsCpp, const FormatToken &Current,
                                       const AnnotatedLine &Line) {
   assert(Current.Previous);
+  if (!Current.Tok.getIdentifierInfo())
+    return false;
+
   auto skipOperatorName = [](const FormatToken *Next) -> const FormatToken * {
     for (; Next; Next = Next->Next) {
       if (Next->is(TT_OverloadedOperatorLParen))


        


More information about the cfe-commits mailing list