From 75109be3b9f589876baac5139f886bf468ca32f6 Mon Sep 17 00:00:00 2001 From: Daniel Jasper Date: Thu, 13 Aug 2015 13:43:51 +0000 Subject: [PATCH] clang-format: Inside decltype(), there is an expression. Before: decltype(a* b) F(); After: decltype(a * b) F(); git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@244891 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/TokenAnnotator.cpp | 5 +++-- unittests/Format/FormatTest.cpp | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 25ec7e6023..41d1811541 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -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; diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 6fd07b9a44..7eaebadcf7 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -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};"); -- 2.40.0