================
@@ -4895,6 +4895,188 @@ TEST_F(FormatTest, FormatTryCatch) {
   verifyIncompleteFormat("try {} catch (");
 }
 
+TEST_F(FormatTest, TryMacros) {
+  FormatStyle Style = getLLVMStyle();
+  Style.TryMacros.push_back("KJ_TRY");
+  Style.TryMacros.push_back("JSG_TRY");
+  Style.CatchMacros.push_back("KJ_CATCH");
+  Style.CatchMacros.push_back("JSG_CATCH");
+
+  // Basic try-catch macro formatting (catch attaches to closing brace).
+  // No space before '(' — macros look like macro invocations.
+  verifyFormat("KJ_TRY {\n"
+               "  doStuff();\n"
+               "} KJ_CATCH(e) {\n"
+               "  handleError();\n"
+               "}",
+               Style);
+
+  // Try macro with arguments (like JSG_TRY(js)).
+  verifyFormat("JSG_TRY(js) {\n"
+               "  doStuff();\n"
+               "} JSG_CATCH(e) {\n"
+               "  handleError();\n"
+               "}",
+               Style);
+
+  // Variadic catch macro (like JSG_CATCH(exception, ...)).
+  verifyFormat("JSG_TRY(js) {\n"
+               "  doStuff();\n"
+               "} JSG_CATCH(e, js) {\n"
+               "  handleError();\n"
+               "}",
+               Style);
+
+  // Catch macro without arguments.
+  verifyFormat("KJ_TRY {\n"
+               "  doStuff();\n"
+               "} KJ_CATCH {\n"
+               "  handleError();\n"
+               "}",
+               Style);
+
+  // Multiple catch blocks.
+  verifyFormat("KJ_TRY {\n"
+               "  doStuff();\n"
+               "} KJ_CATCH(e1) {\n"
+               "  handleError1();\n"
+               "} KJ_CATCH(e2) {\n"
+               "  handleError2();\n"
+               "}",
+               Style);
+
+  // With BeforeCatch = true, catch goes on its own line.
----------------
harrishancock wrote:

Removed in 
https://github.com/llvm/llvm-project/pull/183352/changes/1c7ecc65fc6d0701f06a76a15eab956ee3cc7f3e

https://github.com/llvm/llvm-project/pull/183352
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to