[clang] 47423e9 - [clang-format][NFC] Clean up IsQualifiedPointerOrReference in TokenAnnotator

Owen Pan via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 23 02:33:12 PDT 2024


Author: Owen Pan
Date: 2024-03-23T02:24:56-07:00
New Revision: 47423e9827abfdcc6b10ce41618965861b0e69a4

URL: https://github.com/llvm/llvm-project/commit/47423e9827abfdcc6b10ce41618965861b0e69a4
DIFF: https://github.com/llvm/llvm-project/commit/47423e9827abfdcc6b10ce41618965861b0e69a4.diff

LOG: [clang-format][NFC] Clean up IsQualifiedPointerOrReference in TokenAnnotator

Added: 
    

Modified: 
    clang/lib/Format/TokenAnnotator.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 7757c8ff76398f..4c83a7a3a323be 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -2753,10 +2753,9 @@ class AnnotatingParser {
     }
 
     // Heuristically try to determine whether the parentheses contain a type.
-    auto IsQualifiedPointerOrReference = [this](FormatToken *T) {
+    auto IsQualifiedPointerOrReference = [](FormatToken *T, bool IsCpp) {
       // This is used to handle cases such as x = (foo *const)&y;
       assert(!T->isTypeName(IsCpp) && "Should have already been checked");
-      (void)IsCpp; // Avoid -Wunused-lambda-capture when assertion is disabled.
       // Strip trailing qualifiers such as const or volatile when checking
       // whether the parens could be a cast to a pointer/reference type.
       while (T) {
@@ -2789,7 +2788,7 @@ class AnnotatingParser {
         !Tok.Previous ||
         Tok.Previous->isOneOf(TT_TemplateCloser, TT_TypeDeclarationParen) ||
         Tok.Previous->isTypeName(IsCpp) ||
-        IsQualifiedPointerOrReference(Tok.Previous);
+        IsQualifiedPointerOrReference(Tok.Previous, IsCpp);
     bool ParensCouldEndDecl =
         Tok.Next->isOneOf(tok::equal, tok::semi, tok::l_brace, tok::greater);
     if (ParensAreType && !ParensCouldEndDecl)


        


More information about the cfe-commits mailing list