From: Daniel Jasper Date: Wed, 11 Jun 2014 07:35:16 +0000 (+0000) Subject: clang-format: Fix pointer/reference detection after decltype. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c9ec1c267c72ecb1ef787bde6d420b20742fcdfc;p=clang clang-format: Fix pointer/reference detection after decltype. Before: [](const decltype(*a) & value) {} After: [](const decltype(*a)& value) {} git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210643 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 66060f0b83..f92a8f095b 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -921,7 +921,8 @@ private: if (PrevToken->is(tok::r_paren) && PrevToken->MatchingParen && PrevToken->MatchingParen->Previous && - PrevToken->MatchingParen->Previous->is(tok::kw_typeof)) + PrevToken->MatchingParen->Previous->isOneOf(tok::kw_typeof, + tok::kw_decltype)) return TT_PointerOrReference; if (PrevToken->Tok.isLiteral() || diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index a923e1a9f8..f474c42144 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -4740,6 +4740,7 @@ TEST_F(FormatTest, UnderstandsUsesOfStarAndAmp) { verifyFormat("auto a = [](int **&, int ***) {};"); verifyFormat("auto PointerBinding = [](const char *S) {};"); verifyFormat("typedef typeof(int(int, int)) *MyFunc;"); + verifyFormat("[](const decltype(*a) &value) {}"); verifyIndependentOfContext("typedef void (*f)(int *a);"); verifyIndependentOfContext("int i{a * b};"); verifyIndependentOfContext("aaa && aaa->f();");