[PATCH] D141959: [clang-format] Fix inconsistent identification of operator&

David K Turner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 26 09:20:03 PST 2023


dkt01 marked 11 inline comments as done.
dkt01 added inline comments.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:1162-1169
+      case TT_EnumLBrace:
+      case TT_ControlStatementLBrace:
+      case TT_ElseLBrace:
+      case TT_BracedListLBrace:
+      case TT_CompoundRequirementLBrace:
+      case TT_ObjCBlockLBrace:
+      case TT_RecordLBrace:
----------------
owenpan wrote:
> Do we really need these? If we add other special `l_brace` token types, we will have to update this list.
Agreed.  This was left over from a prior implementation that didn't have a default case.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:2488-2490
+        (NextToken && NextToken->Tok.isAnyIdentifier()) &&
+        (NextToken->getNextNonComment() &&
+         (NextToken->getNextNonComment()->isOneOf(
----------------
owenpan wrote:
> `NextToken` is guarded against null on line 2488 but not on lines 2489-2490.
If NextToken is null on 2488, 2489-2490 will be short circuited.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:2766
 
-void TokenAnnotator::annotate(AnnotatedLine &Line) const {
   for (auto &Child : Line.Children)
----------------
MyDeveloperDay wrote:
> was there a reason it could no longer be const?
Member `Scopes` can be modified.  Alternate would be to make `Scopes` mutable, but I thought removing const from this function is cleaner


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D141959/new/

https://reviews.llvm.org/D141959



More information about the cfe-commits mailing list