[PATCH] D121907: [clang-format] Use an enum for context types.

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Mar 17 13:16:39 PDT 2022


HazardyKnusperkeks added a comment.

In D121907#3390226 <https://reviews.llvm.org/D121907#3390226>, @MyDeveloperDay wrote:

> So out of interest, what is the reason? my assumption is that you wanted to add more for Verilog and you felt adding the extra bools was the wrong design and its better an an enum
>
>   bool InCpp11AttributeSpecifier = false;
>   bool InCSharpAttributeSpecifier = false;
>
> Does the fact that some aren't exclusive make you think its ok to split it into enums and bools is ok?  (no real opinion just wondered what you and others think?)

It is really helpful to see that these are exclusive. It helps reasoning about the code.



================
Comment at: clang/lib/Format/TokenAnnotator.cpp:1498
     bool CaretFound = false;
-    bool IsForEachMacro = false;
+    // These two are not handled like the rest in ContextType because they are
+    // not exclusive.
----------------
This is a comment for the change, afterwards it's strange to see for newcomers. Since it's without `Context`. *scnr*


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D121907



More information about the cfe-commits mailing list