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

David K Turner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 17 15:39:08 PST 2023


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


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:2490-2491
+    // Opeartors at class scope are likely pointer or reference members
+    if (TokScope == ScopeType::Class)
+      return TT_PointerOrReference;
+
----------------
HazardyKnusperkeks wrote:
> What about
> ```
> struct S {
>   auto Mem = C & D;
> };
> ```
> That would be annotated, or is there another rule above with would kick in? If there isn't a test with such a construct already please add one.
This case was already handled properly by the `IsExpression && !Contexts.back().CaretFound` condition, but I'll add this test case as there isn't an equivalent test yet.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:2544
   SmallVector<Context, 8> Contexts;
+  static SmallVector<ScopeType, 8> Scopes;
 
----------------
HazardyKnusperkeks wrote:
> Why static?
The AnnotatingParser object lifetime is too short to track the scope information I wanted.  From my testing, it seems like this object is created once per line.  This is why I haven't added the scope information as part of the contexts member.

I would like to make this a non-static member, but I'm not sure which object it should be a member of.  Do you have a recommendation?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141959



More information about the cfe-commits mailing list