]> granicus.if.org Git - clang/commitdiff
Fixed one issue with casting
authorDinesh Dwivedi <dinesh.d@samsung.com>
Tue, 6 May 2014 11:46:49 +0000 (11:46 +0000)
committerDinesh Dwivedi <dinesh.d@samsung.com>
Tue, 6 May 2014 11:46:49 +0000 (11:46 +0000)
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
unittests/Format/FormatTest.cpp

index b65971103ef669424cb31b1bfe03dfbbe612ef68..98ef453e4cd4a65be822e12370ad5faa8d0a927e 100644 (file)
@@ -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 &&
index e80d1e3d112db2c28fd2ef0ce4372578721128a5..aad0cb19fb2ed05251cbc419ca628027cb31d845 100644 (file)
@@ -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"