[PATCH] D123450: [clang-format] Parse Verilog if statements

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 12 13:00:05 PDT 2022


HazardyKnusperkeks added inline comments.


================
Comment at: clang/lib/Format/FormatToken.h:374
+  /// Verilog we want to treat the backtick like a hash.
+  tok::TokenKind AliasToken = tok::unknown;
+
----------------
sstwcw wrote:
> HazardyKnusperkeks wrote:
> > Can't we do that with a type?
> > 
> > I'm not very happy about the alias, because you can still call `Tok.getKind()`.
> The main problem I seek to solve with the alias thing is with `tok::hash`.  In Verilog they use a backtick instead of a hash.  At first I modified all places in the code to recognize the backtick.  MyDeveloperDay said "year really not nice.. its like we can never use tok::hash again!"  Using a type also requires modifying all instances of tok::hash if I get you right.  How do I please everyone?
Then you must hide Tok in the private part, so that no one can ever access `Tok.getKind()` accidentally.


================
Comment at: clang/lib/Format/FormatToken.h:1533
+    switch (Tok.Tok.getKind()) {
+    case tok::kw_case:
+    case tok::kw_class:
----------------
sstwcw wrote:
> HazardyKnusperkeks wrote:
> > So you have a blacklist what is not a keyword? Seems a bit non future proof, new C++ keywords would have to be added here.
> This is a whitelist of what is a keyword.
My bad. Go on.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123450



More information about the cfe-commits mailing list