[clang] [clang-format] Fix Macros configuration not working with try/catch expansions (PR #184891)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 6 22:43:14 PST 2026
owenca wrote:
I think we should just revert 6a0484f04b628870fb7cd0757a72d73294ff5346 like what we did with other similar commits after `LK_C` had been added. The test cases can be kept with slight adjustments:
```diff
diff --git a/clang/unittests/Format/FormatTest.cpp b/clang/unittests/Format/FormatTest.cpp
index 33af71de398b..135911945447 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -4896,9 +4896,11 @@ TEST_F(FormatTest, FormatTryCatch) {
}
TEST_F(FormatTest, FormatTryAsAVariable) {
- verifyFormat("int try;");
- verifyFormat("int try, size;");
- verifyFormat("try = foo();");
+ auto Style = getLLVMStyle(FormatStyle::LK_C);
+ verifyFormat("int try;", Style);
+ verifyFormat("int try, size;", Style);
+ verifyFormat("try = foo();", Style);
+
verifyFormat("if (try < size) {\n return true;\n}");
verifyFormat("int catch;");
@@ -4906,7 +4908,7 @@ TEST_F(FormatTest, FormatTryAsAVariable) {
verifyFormat("catch = foo();");
verifyFormat("if (catch < size) {\n return true;\n}");
- FormatStyle Style = getLLVMStyle();
+ Style.Language = FormatStyle::LK_Cpp;
Style.BreakBeforeBraces = FormatStyle::BS_Custom;
Style.BraceWrapping.AfterFunction = true;
Style.BraceWrapping.BeforeCatch = true;
```
https://github.com/llvm/llvm-project/pull/184891
More information about the cfe-commits
mailing list