[clang] [clang-format] Preserve trailing NOLINTEND placement with SeparateDefinitionBlocks (PR #190741)

via cfe-commits cfe-commits at lists.llvm.org
Fri Apr 17 23:51:44 PDT 2026


================
@@ -291,6 +291,36 @@ TEST_F(DefinitionBlockSeparatorTest, Always) {
                "struct E {};",
                Style);
 
+  verifyFormat("// NOLINTBEGIN\n"
+               "int x = 1;\n"
+               "int y = 2;\n"
+               "// NOLINTEND\n"
+               "\n"
+               "void some_function() {}\n",
+               Style,
+               "// NOLINTBEGIN\n"
+               "int x = 1;\n"
+               "int y = 2;\n"
+               "// NOLINTEND\n"
+               "\n"
+               "void some_function() {}\n",
+               false);
+
+  verifyFormat("int x = 0;\n"
+               "int y = 0;\n"
+               "// trailing comment 1\n"
+               "// trailing comment 2\n"
+               "\n"
+               "void some_function() {}\n",
+               Style,
+               "int x = 0;\n"
+               "int y = 0;\n"
+               "// trailing comment 1\n"
+               "// trailing comment 2\n"
+               "\n"
+               "void some_function() {}\n",
+               false);
----------------
owenca wrote:

```suggestion
  constexpr StringRef Code2( ... );
  verifyFormat(Code2, Style, Code2);
```

https://github.com/llvm/llvm-project/pull/190741


More information about the cfe-commits mailing list