From 3fae4abaf20d1904925b72dc0ecea31daf59a2aa Mon Sep 17 00:00:00 2001 From: Richard Trieu <rtrieu@google.com> Date: Thu, 18 Feb 2016 22:34:54 +0000 Subject: [PATCH] Remove use of builtin comma operator. Cleanup for upcoming Clang warning -Wcomma. No functionality change intended. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@261271 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/FormatString.cpp | 16 ++++++-- lib/Basic/SourceManager.cpp | 12 ++++-- lib/CodeGen/CGOpenMPRuntime.cpp | 19 ++++++--- lib/CodeGen/CGStmtOpenMP.cpp | 19 ++++++--- lib/Frontend/FrontendActions.cpp | 3 +- lib/Frontend/PrintPreprocessedOutput.cpp | 6 ++- lib/Lex/Lexer.cpp | 4 +- lib/Lex/PPExpressions.cpp | 6 ++- lib/Rewrite/RewriteRope.cpp | 6 ++- lib/Sema/SemaChecking.cpp | 51 +++++++++++++++++++----- lib/Sema/SemaOpenMP.cpp | 3 +- lib/Sema/SemaOverload.cpp | 6 ++- lib/Sema/SemaStmt.cpp | 3 +- unittests/Format/FormatTest.cpp | 3 +- 14 files changed, 116 insertions(+), 41 deletions(-) diff --git a/lib/Analysis/FormatString.cpp b/lib/Analysis/FormatString.cpp index 0948bc0b08a..1c42ec0e87c 100644 --- a/lib/Analysis/FormatString.cpp +++ b/lib/Analysis/FormatString.cpp @@ -190,13 +190,21 @@ clang::analyze_format_string::ParseLengthModifier(FormatSpecifier &FS, return false; case 'h': ++I; - lmKind = (I != E && *I == 'h') ? (++I, LengthModifier::AsChar) - : LengthModifier::AsShort; + if (I != E && *I == 'h') { + ++I; + lmKind = LengthModifier::AsChar; + } else { + lmKind = LengthModifier::AsShort; + } break; case 'l': ++I; - lmKind = (I != E && *I == 'l') ? (++I, LengthModifier::AsLongLong) - : LengthModifier::AsLong; + if (I != E && *I == 'l') { + ++I; + lmKind = LengthModifier::AsLongLong; + } else { + lmKind = LengthModifier::AsLong; + } break; case 'j': lmKind = LengthModifier::AsIntMax; ++I; break; case 'z': lmKind = LengthModifier::AsSizeT; ++I; break; diff --git a/lib/Basic/SourceManager.cpp b/lib/Basic/SourceManager.cpp index 416031d4adb..92f473a3808 100644 --- a/lib/Basic/SourceManager.cpp +++ b/lib/Basic/SourceManager.cpp @@ -1258,15 +1258,19 @@ FoundSpecialChar: if (Buf[0] == '\n' || Buf[0] == '\r') { // If this is \n\r or \r\n, skip both characters. - if ((Buf[1] == '\n' || Buf[1] == '\r') && Buf[0] != Buf[1]) - ++Offs, ++Buf; - ++Offs, ++Buf; + if ((Buf[1] == '\n' || Buf[1] == '\r') && Buf[0] != Buf[1]) { + ++Offs; + ++Buf; + } + ++Offs; + ++Buf; LineOffsets.push_back(Offs); } else { // Otherwise, this is a null. If end of file, exit. if (Buf == End) break; // Otherwise, skip the null. - ++Offs, ++Buf; + ++Offs; + ++Buf; } } diff --git a/lib/CodeGen/CGOpenMPRuntime.cpp b/lib/CodeGen/CGOpenMPRuntime.cpp index bbcd3a64df2..4637c7b7711 100644 --- a/lib/CodeGen/CGOpenMPRuntime.cpp +++ b/lib/CodeGen/CGOpenMPRuntime.cpp @@ -2760,7 +2760,8 @@ void CGOpenMPRuntime::emitTaskCall( PrivateHelpersTy( VD, cast<VarDecl>(cast<DeclRefExpr>(*I)->getDecl()), cast<VarDecl>(cast<DeclRefExpr>(*IElemInitRef)->getDecl())))); - ++I, ++IElemInitRef; + ++I; + ++IElemInitRef; } llvm::array_pod_sort(Privates.begin(), Privates.end(), array_pod_sort_comparator); @@ -3259,7 +3260,9 @@ static llvm::Value *emitReductionFunction(CodeGenModule &CGM, } else // Emit reduction for array subscript or single variable. CGF.EmitIgnoredExpr(E); - ++IPriv, ++ILHS, ++IRHS; + ++IPriv; + ++ILHS; + ++IRHS; } Scope.ForceCleanup(); CGF.FinishFunction(); @@ -3326,7 +3329,9 @@ void CGOpenMPRuntime::emitReduction(CodeGenFunction &CGF, SourceLocation Loc, const Expr *) { CGF.EmitIgnoredExpr(E); }); } else CGF.EmitIgnoredExpr(E); - ++IPriv, ++ILHS, ++IRHS; + ++IPriv; + ++ILHS; + ++IRHS; } return; } @@ -3444,7 +3449,9 @@ void CGOpenMPRuntime::emitReduction(CodeGenFunction &CGF, SourceLocation Loc, } else // Emit reduction for array subscript or single variable. CGF.EmitIgnoredExpr(E); - ++IPriv, ++ILHS, ++IRHS; + ++IPriv; + ++ILHS; + ++IRHS; } } @@ -3553,7 +3560,9 @@ void CGOpenMPRuntime::emitReduction(CodeGenFunction &CGF, SourceLocation Loc, } else CritRedGen(CGF, nullptr, nullptr, nullptr); } - ++ILHS, ++IRHS, ++IPriv; + ++ILHS; + ++IRHS; + ++IPriv; } } diff --git a/lib/CodeGen/CGStmtOpenMP.cpp b/lib/CodeGen/CGStmtOpenMP.cpp index a4bc354ddb6..9ccac258ee0 100644 --- a/lib/CodeGen/CGStmtOpenMP.cpp +++ b/lib/CodeGen/CGStmtOpenMP.cpp @@ -201,7 +201,8 @@ CodeGenFunction::GenerateOpenMPCapturedStmtFunction(const CapturedStmt &S) { // use the value that we get from the arguments. if (I->capturesVariableByCopy() && FD->getType()->isAnyPointerType()) { setAddrOfLocalVar(I->getCapturedVar(), GetAddrOfLocalVar(Args[Cnt])); - ++Cnt, ++I; + ++Cnt; + ++I; continue; } @@ -242,7 +243,8 @@ CodeGenFunction::GenerateOpenMPCapturedStmtFunction(const CapturedStmt &S) { CXXThisValue = EmitLoadOfLValue(ArgLVal, Args[Cnt]->getLocation()).getScalarVal(); } - ++Cnt, ++I; + ++Cnt; + ++I; } PGO.assignRegionCounters(GlobalDecl(CD), F); @@ -489,7 +491,8 @@ bool CodeGenFunction::EmitOMPFirstprivateClause(const OMPExecutableDirective &D, // Silence the warning about unused variable. (void)IsRegistered; } - ++IRef, ++InitsRef; + ++IRef; + ++InitsRef; } } return FirstprivateIsLastprivate && !EmittedAsFirstprivate.empty(); @@ -628,7 +631,8 @@ bool CodeGenFunction::EmitOMPLastprivateClauseInit( (void)IsRegistered; } } - ++IRef, ++IDestRef; + ++IRef; + ++IDestRef; } } return HasAtLeastOneLastprivate; @@ -917,7 +921,9 @@ void CodeGenFunction::EmitOMPReductionClauseInit( }); } } - ++ILHS, ++IRHS, ++IPriv; + ++ILHS; + ++IRHS; + ++IPriv; } } } @@ -2013,7 +2019,8 @@ void CodeGenFunction::EmitOMPTaskDirective(const OMPTaskDirective &S) { FirstprivateCopies.push_back(IInit); FirstprivateInits.push_back(*IElemInitRef); } - ++IRef, ++IElemInitRef; + ++IRef; + ++IElemInitRef; } } // Build list of dependences. diff --git a/lib/Frontend/FrontendActions.cpp b/lib/Frontend/FrontendActions.cpp index 407ccea2e7d..060055fe115 100644 --- a/lib/Frontend/FrontendActions.cpp +++ b/lib/Frontend/FrontendActions.cpp @@ -707,7 +707,8 @@ void PrintPreprocessedAction::ExecuteAction() { } else if (*cur == 0x0A) // LF break; - ++cur, ++next; + ++cur; + ++next; } } diff --git a/lib/Frontend/PrintPreprocessedOutput.cpp b/lib/Frontend/PrintPreprocessedOutput.cpp index 88262ebef3e..5dd7980d81b 100644 --- a/lib/Frontend/PrintPreprocessedOutput.cpp +++ b/lib/Frontend/PrintPreprocessedOutput.cpp @@ -545,8 +545,10 @@ void PrintPPOutputPPCallbacks::HandleNewlinesInToken(const char *TokStr, // If we have \n\r or \r\n, skip both and count as one line. if (Len != 1 && (TokStr[1] == '\n' || TokStr[1] == '\r') && - TokStr[0] != TokStr[1]) - ++TokStr, --Len; + TokStr[0] != TokStr[1]) { + ++TokStr; + --Len; + } } if (NumNewlines == 0) return; diff --git a/lib/Lex/Lexer.cpp b/lib/Lex/Lexer.cpp index 43bd12f2435..d0e38a42473 100644 --- a/lib/Lex/Lexer.cpp +++ b/lib/Lex/Lexer.cpp @@ -719,7 +719,9 @@ SourceLocation Lexer::AdvanceToTokenCharacter(SourceLocation TokStart, while (Lexer::isObviouslySimpleCharacter(*TokPtr)) { if (CharNo == 0) return TokStart.getLocWithOffset(PhysOffset); - ++TokPtr, --CharNo, ++PhysOffset; + ++TokPtr; + --CharNo; + ++PhysOffset; } // If we have a character that may be a trigraph or escaped newline, use a diff --git a/lib/Lex/PPExpressions.cpp b/lib/Lex/PPExpressions.cpp index 6603a17cbd4..058e2741d7a 100644 --- a/lib/Lex/PPExpressions.cpp +++ b/lib/Lex/PPExpressions.cpp @@ -650,8 +650,10 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec, case tok::greatergreater: { // Determine whether overflow is about to happen. unsigned ShAmt = static_cast<unsigned>(RHS.Val.getLimitedValue()); - if (ShAmt >= LHS.getBitWidth()) - Overflow = true, ShAmt = LHS.getBitWidth()-1; + if (ShAmt >= LHS.getBitWidth()) { + Overflow = true; + ShAmt = LHS.getBitWidth()-1; + } Res = LHS.Val >> ShAmt; break; } diff --git a/lib/Rewrite/RewriteRope.cpp b/lib/Rewrite/RewriteRope.cpp index 451ad07e4e8..030ab7732fc 100644 --- a/lib/Rewrite/RewriteRope.cpp +++ b/lib/Rewrite/RewriteRope.cpp @@ -350,8 +350,10 @@ void RopePieceBTreeLeaf::erase(unsigned Offset, unsigned NumBytes) { PieceOffs += getPiece(i).size(); // If we exactly include the last one, include it in the region to delete. - if (Offset+NumBytes == PieceOffs+getPiece(i).size()) - PieceOffs += getPiece(i).size(), ++i; + if (Offset+NumBytes == PieceOffs+getPiece(i).size()) { + PieceOffs += getPiece(i).size(); + ++i; + } // If we completely cover some RopePieces, erase them now. if (i != StartPiece) { diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index db29e720054..4a9df07bc42 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -1307,17 +1307,30 @@ static bool SemaBuiltinCpuSupports(Sema &S, CallExpr *TheCall) { bool Sema::CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { unsigned i = 0, l = 0, u = 0; switch (BuiltinID) { - default: return false; + default: + return false; case X86::BI__builtin_cpu_supports: return SemaBuiltinCpuSupports(*this, TheCall); case X86::BI__builtin_ms_va_start: return SemaBuiltinMSVAStart(TheCall); - case X86::BI_mm_prefetch: i = 1; l = 0; u = 3; break; - case X86::BI__builtin_ia32_sha1rnds4: i = 2, l = 0; u = 3; break; + case X86::BI_mm_prefetch: + i = 1; + l = 0; + u = 3; + break; + case X86::BI__builtin_ia32_sha1rnds4: + i = 2; + l = 0; + u = 3; + break; case X86::BI__builtin_ia32_vpermil2pd: case X86::BI__builtin_ia32_vpermil2pd256: case X86::BI__builtin_ia32_vpermil2ps: - case X86::BI__builtin_ia32_vpermil2ps256: i = 3, l = 0; u = 3; break; + case X86::BI__builtin_ia32_vpermil2ps256: + i = 3; + l = 0; + u = 3; + break; case X86::BI__builtin_ia32_cmpb128_mask: case X86::BI__builtin_ia32_cmpw128_mask: case X86::BI__builtin_ia32_cmpd128_mask: @@ -1341,13 +1354,25 @@ bool Sema::CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { case X86::BI__builtin_ia32_ucmpb512_mask: case X86::BI__builtin_ia32_ucmpw512_mask: case X86::BI__builtin_ia32_ucmpd512_mask: - case X86::BI__builtin_ia32_ucmpq512_mask: i = 2; l = 0; u = 7; break; + case X86::BI__builtin_ia32_ucmpq512_mask: + i = 2; + l = 0; + u = 7; + break; case X86::BI__builtin_ia32_roundps: case X86::BI__builtin_ia32_roundpd: case X86::BI__builtin_ia32_roundps256: - case X86::BI__builtin_ia32_roundpd256: i = 1, l = 0; u = 15; break; + case X86::BI__builtin_ia32_roundpd256: + i = 1; + l = 0; + u = 15; + break; case X86::BI__builtin_ia32_roundss: - case X86::BI__builtin_ia32_roundsd: i = 2, l = 0; u = 15; break; + case X86::BI__builtin_ia32_roundsd: + i = 2; + l = 0; + u = 15; + break; case X86::BI__builtin_ia32_cmpps: case X86::BI__builtin_ia32_cmpss: case X86::BI__builtin_ia32_cmppd: @@ -1355,7 +1380,11 @@ bool Sema::CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { case X86::BI__builtin_ia32_cmpps256: case X86::BI__builtin_ia32_cmppd256: case X86::BI__builtin_ia32_cmpps512_mask: - case X86::BI__builtin_ia32_cmppd512_mask: i = 2; l = 0; u = 31; break; + case X86::BI__builtin_ia32_cmppd512_mask: + i = 2; + l = 0; + u = 31; + break; case X86::BI__builtin_ia32_vpcomub: case X86::BI__builtin_ia32_vpcomuw: case X86::BI__builtin_ia32_vpcomud: @@ -1363,7 +1392,11 @@ bool Sema::CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { case X86::BI__builtin_ia32_vpcomb: case X86::BI__builtin_ia32_vpcomw: case X86::BI__builtin_ia32_vpcomd: - case X86::BI__builtin_ia32_vpcomq: i = 2; l = 0; u = 7; break; + case X86::BI__builtin_ia32_vpcomq: + i = 2; + l = 0; + u = 7; + break; } return SemaBuiltinConstantArgRange(TheCall, i, l, u); } diff --git a/lib/Sema/SemaOpenMP.cpp b/lib/Sema/SemaOpenMP.cpp index b354c90138a..7f000dc0bd0 100644 --- a/lib/Sema/SemaOpenMP.cpp +++ b/lib/Sema/SemaOpenMP.cpp @@ -8458,7 +8458,8 @@ static bool FinishOpenMPLinearClause(OMPLinearClause &Clause, DeclRefExpr *IV, Updates.push_back(Update.get()); Finals.push_back(Final.get()); } - ++CurInit, ++CurPrivate; + ++CurInit; + ++CurPrivate; } Clause.setUpdates(Updates); Clause.setFinals(Finals); diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp index f190872f0aa..f1b74ad5545 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -9056,8 +9056,10 @@ static void DiagnoseBadConversion(Sema &S, OverloadCandidate *Cand, else { // TODO: detect and diagnose the full richness of const mismatches. if (CanQual<PointerType> FromPT = CFromTy->getAs<PointerType>()) - if (CanQual<PointerType> ToPT = CToTy->getAs<PointerType>()) - CFromTy = FromPT->getPointeeType(), CToTy = ToPT->getPointeeType(); + if (CanQual<PointerType> ToPT = CToTy->getAs<PointerType>()) { + CFromTy = FromPT->getPointeeType(); + CToTy = ToPT->getPointeeType(); + } } if (CToTy.getUnqualifiedType() == CFromTy.getUnqualifiedType() && diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index e304965562b..350f16d93d8 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -980,7 +980,8 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch, << SourceRange(CR->getLHS()->getLocStart(), Hi->getLocEnd()); CaseRanges.erase(CaseRanges.begin()+i); - --i, --e; + --i; + --e; continue; } diff --git a/unittests/Format/FormatTest.cpp b/unittests/Format/FormatTest.cpp index 48269cae66d..d7bbafa48ce 100644 --- a/unittests/Format/FormatTest.cpp +++ b/unittests/Format/FormatTest.cpp @@ -8683,7 +8683,8 @@ TEST_F(FormatTest, ConfigurableSpacesInParentheses) { verifyFormat("#define x (( int )-1)", Spaces); // Run the first set of tests again with: - Spaces.SpacesInParentheses = false, Spaces.SpaceInEmptyParentheses = true; + Spaces.SpacesInParentheses = false; + Spaces.SpaceInEmptyParentheses = true; Spaces.SpacesInCStyleCastParentheses = true; verifyFormat("call(x, y, z);", Spaces); verifyFormat("call( );", Spaces); -- GitLab