[clang] ClangFormat: Insert braces & newline for Chromium (PR #140888)
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Wed May 21 20:56:52 PDT 2025
================
@@ -5904,7 +5904,7 @@ TEST_F(FormatTest, MacrosWithoutTrailingSemicolon) {
getLLVMStyleWithColumns(60));
verifyFormat("VISIT_GL_CALL(GenBuffers, void, (GLsizei n, GLuint* buffers), "
- "(n, buffers))",
+ "(n, buffers))\n",
getChromiumStyle(FormatStyle::LK_Cpp));
----------------
owenca wrote:
```suggestion
"(n, buffers))",
getChromiumStyle());
```
You can add the following to FormatTestUtils.h and replace all `getChromiumStyle(FormatStyle::LK_Cpp)` with `getChromiumStyle()` so that the test cases in this file can be left unchanged.
```c++
@@ -24,6 +24,12 @@ inline FormatStyle getGoogleStyle() {
return getGoogleStyle(FormatStyle::LK_Cpp);
}
+inline FormatStyle getChromiumStyle() {
+ auto Style = getChromiumStyle(FormatStyle::LK_Cpp);
+ Style.InsertNewlineAtEOF = false;
+ return Style;
+}
+
// When HandleHash is false, preprocessor directives starting with hash will not
// be on separate lines. This is needed because Verilog uses hash for other
// purposes.
```
https://github.com/llvm/llvm-project/pull/140888
More information about the cfe-commits
mailing list