[PATCH] Revamp indentation behavior for complex binary expressions.

Manuel Klimek klimek at google.com
Mon Apr 8 12:55:57 PDT 2013



================
Comment at: lib/Format/Format.cpp:903
@@ +902,3 @@
+      // the 'operator' is ',', ';' or an assignment as those have different
+      // indentation rules.
+      if (*I == prec::Conditional ||
----------------
Daniel Jasper wrote:
> Manuel Klimek wrote:
> > Why does SkipFirstExtraIndent only apply to the latter?
> Because the rule for conditional expressions supersedes the one for assignments etc.. Thus "always indent conditional expressions.". Otherwise, we would end up with:
> 
>   int aaaaaa = bbbbbb
>                ? ccccccc
>                : dddddd
The next sentence also says "never indent ...", but it's under !SkipFirstExtraIndent, or am I missing something?

================
Comment at: lib/Format/TokenAnnotator.cpp:803
@@ -804,4 +802,3 @@
           CurrentPrecedence = 1 + (int) prec::Conditional;
-        else if (Current->is(tok::semi) || Current->Type == TT_InlineASMColon ||
-                 Current->Type == TT_CtorInitializerColon)
+        else if (Current->is(tok::semi) || Current->Type == TT_InlineASMColon)
           CurrentPrecedence = 1;
----------------
Daniel Jasper wrote:
> Manuel Klimek wrote:
> > Why did this change?
> Because it is no longer necessary to "cheat" by regarding constructor initializers as binary operators. They follow different rules and thus should be handled in a different fashion.
I assume that was already the case before, and is not necessarily related to this change?


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



More information about the cfe-commits mailing list