[PATCH] Revamp indentation behavior for complex binary expressions.

Manuel Klimek klimek at google.com
Mon Apr 8 12:00:54 PDT 2013



================
Comment at: lib/Format/Format.cpp:874
@@ -886,1 +873,3 @@
 
+    // If return is "part" of a binary expression, align after it.
+    if (Current.is(tok::kw_return) && !Current.FakeLParens.empty())
----------------
As discussed offline, change comment.

================
Comment at: lib/Format/Format.cpp:886
@@ +885,3 @@
+    // Don't add extra indentation for the first fake parenthesis after
+    // 'return', assignements or opening <({[. The indendtation for these cases
+    // is special cased.
----------------
*indentation

================
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 ||
----------------
Why does SkipFirstExtraIndent only apply to the latter?

================
Comment at: lib/Format/TokenAnnotator.cpp:787
@@ -789,2 +786,3 @@
     // Eagerly consume trailing comments.
-    while (isTrailingComment(Current)) {
+    while (Current && Current->FormatTok.NewlinesBefore == 0 &&
+           isTrailingComment(Current)) {
----------------
Is this independent of newline escaping? (NewlinesBefore includes escaped newlines)

================
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;
----------------
Why did this change?


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



More information about the cfe-commits mailing list