clang-format: Inside decltype(), there is an expression.
authorDaniel Jasper <djasper@google.com>
Thu, 13 Aug 2015 13:43:51 +0000 (13:43 +0000)
committerDaniel Jasper <djasper@google.com>
Thu, 13 Aug 2015 13:43:51 +0000 (13:43 +0000)
Before:
  decltype(a* b) F();

After:
  decltype(a * b) F();

llvm-svn: 244891

clang/lib/Format/TokenAnnotator.cpp
clang/unittests/Format/FormatTest.cpp

index 25ec7e6..41d1811 100644 (file)
@@ -120,8 +120,9 @@ private:
     }
 
     if (Left->Previous &&
-        (Left->Previous->isOneOf(tok::kw_static_assert, tok::kw_if,
-                                 tok::kw_while, tok::l_paren, tok::comma) ||
+        (Left->Previous->isOneOf(tok::kw_static_assert, tok::kw_decltype,
+                                 tok::kw_if, tok::kw_while, tok::l_paren,
+                                 tok::comma) ||
          Left->Previous->is(TT_BinaryOperator))) {
       // static_assert, if and while usually contain expressions.
       Contexts.back().IsExpression = true;
index 6fd07b9..7eaebad 100644 (file)
@@ -5408,6 +5408,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) {
   verifyFormat("auto PointerBinding = [](const char *S) {};");
   verifyFormat("typedef typeof(int(int, int)) *MyFunc;");
   verifyFormat("[](const decltype(*a) &value) {}");
+  verifyFormat("decltype(a * b) F();");
   verifyFormat("#define MACRO() [](A *a) { return 1; }");
   verifyIndependentOfContext("typedef void (*f)(int *a);");
   verifyIndependentOfContext("int i{a * b};");