[PATCH] D147327: [clang-format] Add option for having one port per line in Verilog

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 31 13:03:31 PDT 2023


HazardyKnusperkeks requested changes to this revision.
HazardyKnusperkeks added inline comments.
This revision now requires changes to proceed.


================
Comment at: clang/include/clang/Format/Format.h:4185
+  /// For Verilog, put each port on its own line in module instantiations.
+  /// \code
+  ///    ffnand ff1(.q(),
----------------
Can you put the true vs. false in the doc, like on other options?


================
Comment at: clang/include/clang/Format/Format.h:4192
+  /// \version 17
+  bool VerilogBreakBetweenInstancePorts;
+
----------------
V after U


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:1150
+      if (Style.isVerilog()) {
+        const FormatToken *Prev = Tok->getPreviousNonComment(), *Prev2;
+        // Identify the parameter list and port list in a module instantiation.
----------------



================
Comment at: clang/lib/Format/TokenAnnotator.cpp:1156-1163
+        if (Prev && (Prev2 = Prev->getPreviousNonComment()) &&
+            ((Prev->is(tok::hash) && Keywords.isVerilogIdentifier(*Prev2)) ||
+             (Keywords.isVerilogIdentifier(*Prev) &&
+              (Prev2->is(tok::r_paren) ||
+               Keywords.isVerilogIdentifier(*Prev2) ||
+               (Prev2->endsSequence(tok::comma, tok::r_paren) &&
+                (Prev2 = Prev2->getPreviousNonComment()->MatchingParen) &&
----------------
I won't read that.

I think you should go with multiple if statements.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147327



More information about the cfe-commits mailing list