llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-format <details> <summary>Changes</summary> The spec doesn't allow splitting these strings and we're seeing compile issues with splitting it. String splitting was enabled for Verilog in https://reviews.llvm.org/D154093. --- Full diff: https://github.com/llvm/llvm-project/pull/66951.diff 2 Files Affected: - (modified) clang/lib/Format/ContinuationIndenter.cpp (+8) - (modified) clang/unittests/Format/FormatTestVerilog.cpp (+6) ``````````diff diff --git a/clang/lib/Format/ContinuationIndenter.cpp b/clang/lib/Format/ContinuationIndenter.cpp index deb3e554fdc124b..0bdf339d8df5827 100644 --- a/clang/lib/Format/ContinuationIndenter.cpp +++ b/clang/lib/Format/ContinuationIndenter.cpp @@ -2270,7 +2270,15 @@ ContinuationIndenter::createBreakableToken(const FormatToken &Current, if (State.Stack.back().IsInsideObjCArrayLiteral) return nullptr; + // The "DPI" (or "DPI-C") in SystemVerilog direct programming interface + // imports cannot be split, e.g. + // `import "DPI" function foo();` + // FIXME: We should see if this is an import statement instead of hardcoding + // "DPI"/"DPI-C". StringRef Text = Current.TokenText; + if (Style.isVerilog() && (Text == "\"DPI\"" || Text == "\"DPI-C\"")) + return nullptr; + // We need this to address the case where there is an unbreakable tail only // if certain other formatting decisions have been taken. The // UnbreakableTailLength of Current is an overapproximation in that case and diff --git a/clang/unittests/Format/FormatTestVerilog.cpp b/clang/unittests/Format/FormatTestVerilog.cpp index 945e06143ccc3f1..56a8d19a31e919c 100644 --- a/clang/unittests/Format/FormatTestVerilog.cpp +++ b/clang/unittests/Format/FormatTestVerilog.cpp @@ -1253,6 +1253,12 @@ TEST_F(FormatTestVerilog, StringLiteral) { "xxxx"});)", R"(x({"xxxxxxxxxxxxxxxx xxxxxxxxxxxxxxxx ", "xxxx"});)", getStyleWithColumns(getDefaultStyle(), 23)); + // "DPI"/"DPI-C" in imports cannot be split. + verifyFormat(R"(import + "DPI-C" function t foo + ();)", + R"(import "DPI-C" function t foo();)", + getStyleWithColumns(getDefaultStyle(), 23)); // These kinds of strings don't exist in Verilog. verifyNoCrash(R"(x(@"xxxxxxxxxxxxxxxx xxxx");)", getStyleWithColumns(getDefaultStyle(), 23)); `````````` </details> https://github.com/llvm/llvm-project/pull/66951 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits