[PATCH] clang-format properly handles try/catch blocks

Daniel Jasper djasper at google.com
Wed Jan 22 06:11:32 PST 2014



================
Comment at: lib/Format/UnwrappedLineParser.cpp:1076
@@ +1075,3 @@
+  while (FormatTok->Tok.is(tok::kw_catch)) {
+    nextToken();
+    if (FormatTok->Tok.is(tok::l_paren))
----------------
Manuel Klimek wrote:
> Alexander Rojas wrote:
> > Manuel Klimek wrote:
> > > Same here. The problem is if anybody ever finds a real use case to put anything in between (including macros) we might fail to parse the file...
> > I don't get what you mean here. If the token is not tok::kw_catch, it won't start the while and NeedsUnwrappedLine will be true. Is there any other case that needs consideration?
> Well, what do we do on this snippet:
>   ...
>   } catch (Type) ANNOTATION_MACRO(something else) {
>      ...
>   }
> As I said, I'm not sure exactly how to resolve this.
> 
> Daniel, do you have ideas here?
Maybe we should just consume everything until the next "{" (possibly recognizing a few error cases explicitly - e.g. ";" or "}").


http://llvm-reviews.chandlerc.com/D2555



More information about the cfe-commits mailing list