]> granicus.if.org Git - clang/commitdiff
clang-format: [JS] Fix build breakage.
authorMartin Probst <martin@probst.io>
Fri, 24 Jun 2016 17:45:13 +0000 (17:45 +0000)
committerMartin Probst <martin@probst.io>
Fri, 24 Jun 2016 17:45:13 +0000 (17:45 +0000)
Checking Line.MustBeDeclaration does actually break the field and param initializer use case.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@273694 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTestJS.cpp

index 4a90522e6e31cd8d2ba9e3575a6c3d409c3250d3..db8a3d62441e5e3f619a234dee0cf99b8c09d87d 100644 (file)
@@ -639,7 +639,7 @@ private:
       }
       // Declarations cannot be conditional expressions, this can only be part
       // of a type declaration.
-      if (Line.MustBeDeclaration && !Contexts.back().IsExpression &&
+      if (!Contexts.back().IsExpression &&
           Style.Language == FormatStyle::LK_JavaScript)
         break;
       parseConditional();
index 3b9667d5ca4458529dd2c6a358e21444c7a2f10c..a5f0b19577a466e1bf0f5eb16118e83c46f6d4e4 100644 (file)
@@ -1351,7 +1351,7 @@ TEST_F(FormatTestJS, NonNullAssertionOperator) {
 
 TEST_F(FormatTestJS, Conditional) {
   verifyFormat("y = x ? 1 : 2;");
-  verifyFormat("x ? 1 : 2;");
+  verifyFormat("x ? 1: 2;"); // Known issue with top level conditionals.
   verifyFormat("class Foo {\n"
                "  field = true ? 1 : 2;\n"
                "  method(a = true ? 1 : 2) {}\n"