From 7cd95fe25455904da18f2f396b3a7fd75c3eac88 Mon Sep 17 00:00:00 2001 From: Dinesh Dwivedi Date: Tue, 6 May 2014 11:46:49 +0000 Subject: [PATCH] Fixed one issue with casting Before: (void) SimplifyICmpOperands(Cond, LHS, RHS); After: (void)SimplifyICmpOperands(Cond, LHS, RHS); Differential Revision: http://reviews.llvm.org/D3615 git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@208080 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Format/TokenAnnotator.cpp | 5 +++-- unittests/Format/FormatTest.cpp | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index b65971103e..98ef453e4c 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -694,8 +694,9 @@ private: } else if (Current.isOneOf(tok::kw_return, tok::kw_throw)) { Contexts.back().IsExpression = true; } else if (Current.is(tok::l_paren) && !Line.MustBeDeclaration && - !Line.InPPDirective && Current.Previous && - Current.Previous->isNot(tok::kw_decltype)) { + !Line.InPPDirective && + (!Current.Previous || + Current.Previous->isNot(tok::kw_decltype))) { bool ParametersOfFunctionType = Current.Previous && Current.Previous->is(tok::r_paren) && Current.Previous->MatchingParen && diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index e80d1e3d11..aad0cb19fb 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -4754,6 +4754,8 @@ TEST_F(FormatTest, FormatsCasts) { // FIXME: single value wrapped with paren will be treated as cast. verifyFormat("void f(int i = (kValue)*kMask) {}"); + verifyFormat("{ (void)F; }"); + // Don't break after a cast's verifyFormat("int aaaaaaaaaaaaaaaaaaaaaaaaaaa =\n" " (aaaaaaaaaaaaaaaaaaaaaaaaaa *)(aaaaaaaaaaaaaaaaaaaaaa +\n" -- 2.40.0