[PATCH] clang-format: Add support for SEH __try / __except / __finally blocks.

Daniel Jasper djasper at google.com
Tue Feb 3 23:29:45 PST 2015


Looks good, thanks. In the commit, mention that this fixes llvm.org/PR22321.


================
Comment at: lib/Format/UnwrappedLineFormatter.cpp:218
@@ -215,1 +217,3 @@
+      if (Line.First->isOneOf(tok::kw_try, tok::kw___try, tok::kw_catch,
+                              Keywords.kw___except, tok::kw___finally))
         return 0;
----------------
thakis wrote:
> Note: The if down here doesn't have any effect, neither for SEH try statements nor for regular try statements, according to the test suite. I added kw___try here because kw_try was here, but maybe this block used to do try formatting and now no longer does.
> 
> (All other changes are covered by the tests added in this change.)
Please add a FIXME. I'll take a look afterwards.

There are two problems here:
1. This doesn't get triggered in tests as the tests use LLVM style which has AllowShortBlocksOnASingleLine set to false meaning that the first "if" in this block always fires.
2. This doesn't work properly, as commonly "catch" (and __except and __finally) won't be the first token in a line (the line will usually start with "} catch ...".

http://reviews.llvm.org/D7386

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the cfe-commits mailing list