diff options
author | sstwcw <su3e8a96kzlver@posteo.net> | 2023-12-02 19:26:07 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-02 19:26:07 +0000 |
commit | b3e80d8ed251bfdad4a49fee19b8354eba407d1d (patch) | |
tree | ccb9280edc6b3e6a89acadd785e40a3b7c10e8d5 /clang/unittests | |
parent | 5602636835e3fe655d196428091a64abd1837966 (diff) | |
download | llvm-b3e80d8ed251bfdad4a49fee19b8354eba407d1d.zip llvm-b3e80d8ed251bfdad4a49fee19b8354eba407d1d.tar.gz llvm-b3e80d8ed251bfdad4a49fee19b8354eba407d1d.tar.bz2 |
[clang-format] Add space in Verilog tagged unions (#71354)
In a tagged union expression, there should be a space between the field
name and the data. Previously, the tag could be recognized as part of a
dotted identifier or a struct literal, and the space would be omitted.
Diffstat (limited to 'clang/unittests')
-rw-r--r-- | clang/unittests/Format/FormatTestVerilog.cpp | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/clang/unittests/Format/FormatTestVerilog.cpp b/clang/unittests/Format/FormatTestVerilog.cpp index 5828874..fcda05d 100644 --- a/clang/unittests/Format/FormatTestVerilog.cpp +++ b/clang/unittests/Format/FormatTestVerilog.cpp @@ -373,6 +373,11 @@ TEST_F(FormatTestVerilog, Case) { " arg);\n" "endcase", Style); + + verifyFormat("case (v) matches\n" + " tagged Valid .n:\n" + " ;\n" + "endcase"); } TEST_F(FormatTestVerilog, Coverage) { @@ -1292,12 +1297,17 @@ TEST_F(FormatTestVerilog, StructLiteral) { verifyFormat("c = '{'{1, 1.0}, '{2, 2.0}};"); verifyFormat("c = '{a: 0, b: 0.0};"); verifyFormat("c = '{a: 0, b: 0.0, default: 0};"); + verifyFormat("d = {int: 1, shortreal: 1.0};"); + verifyFormat("c = '{default: 0};"); + + // The identifier before the quote can be either a tag or a type case. There + // should be a space between the tag and the quote. verifyFormat("c = ab'{a: 0, b: 0.0};"); verifyFormat("c = ab'{cd: cd'{1, 1.0}, ef: ef'{2, 2.0}};"); verifyFormat("c = ab'{cd'{1, 1.0}, ef'{2, 2.0}};"); - verifyFormat("d = {int: 1, shortreal: 1.0};"); verifyFormat("d = ab'{int: 1, shortreal: 1.0};"); - verifyFormat("c = '{default: 0};"); + verifyFormat("x = tagged Add '{e1, 4, ed};"); + auto Style = getDefaultStyle(); Style.SpacesInContainerLiterals = true; verifyFormat("c = '{a : 0, b : 0.0};", Style); |