r208080 - Fixed one issue with casting

Dinesh Dwivedi dinesh.d at samsung.com
Tue May 6 04:46:49 PDT 2014


Author: dinesh
Date: Tue May  6 06:46:49 2014
New Revision: 208080

URL: http://llvm.org/viewvc/llvm-project?rev=208080&view=rev
Log:
Fixed one issue with casting

Before:
(void) SimplifyICmpOperands(Cond, LHS, RHS);

After:
(void)SimplifyICmpOperands(Cond, LHS, RHS);

Differential Revision: http://reviews.llvm.org/D3615


Modified:
    cfe/trunk/lib/Format/TokenAnnotator.cpp
    cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=208080&r1=208079&r2=208080&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Tue May  6 06:46:49 2014
@@ -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 &&

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=208080&r1=208079&r2=208080&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Tue May  6 06:46:49 2014
@@ -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"





More information about the cfe-commits mailing list