Remove use of builtin comma operator.

Cleanup for upcoming Clang warning -Wcomma.  No functionality change intended.

llvm-svn: 261271
This commit is contained in:
Richard Trieu 2016-02-18 22:34:54 +00:00
parent 7a08381403
commit cc3949d99a
14 changed files with 116 additions and 41 deletions

View File

@ -190,13 +190,21 @@ clang::analyze_format_string::ParseLengthModifier(FormatSpecifier &FS,
return false; return false;
case 'h': case 'h':
++I; ++I;
lmKind = (I != E && *I == 'h') ? (++I, LengthModifier::AsChar) if (I != E && *I == 'h') {
: LengthModifier::AsShort; ++I;
lmKind = LengthModifier::AsChar;
} else {
lmKind = LengthModifier::AsShort;
}
break; break;
case 'l': case 'l':
++I; ++I;
lmKind = (I != E && *I == 'l') ? (++I, LengthModifier::AsLongLong) if (I != E && *I == 'l') {
: LengthModifier::AsLong; ++I;
lmKind = LengthModifier::AsLongLong;
} else {
lmKind = LengthModifier::AsLong;
}
break; break;
case 'j': lmKind = LengthModifier::AsIntMax; ++I; break; case 'j': lmKind = LengthModifier::AsIntMax; ++I; break;
case 'z': lmKind = LengthModifier::AsSizeT; ++I; break; case 'z': lmKind = LengthModifier::AsSizeT; ++I; break;

View File

@ -1258,15 +1258,19 @@ FoundSpecialChar:
if (Buf[0] == '\n' || Buf[0] == '\r') { if (Buf[0] == '\n' || Buf[0] == '\r') {
// If this is \n\r or \r\n, skip both characters. // If this is \n\r or \r\n, skip both characters.
if ((Buf[1] == '\n' || Buf[1] == '\r') && Buf[0] != Buf[1]) if ((Buf[1] == '\n' || Buf[1] == '\r') && Buf[0] != Buf[1]) {
++Offs, ++Buf; ++Offs;
++Offs, ++Buf; ++Buf;
}
++Offs;
++Buf;
LineOffsets.push_back(Offs); LineOffsets.push_back(Offs);
} else { } else {
// Otherwise, this is a null. If end of file, exit. // Otherwise, this is a null. If end of file, exit.
if (Buf == End) break; if (Buf == End) break;
// Otherwise, skip the null. // Otherwise, skip the null.
++Offs, ++Buf; ++Offs;
++Buf;
} }
} }

View File

@ -2760,7 +2760,8 @@ void CGOpenMPRuntime::emitTaskCall(
PrivateHelpersTy( PrivateHelpersTy(
VD, cast<VarDecl>(cast<DeclRefExpr>(*I)->getDecl()), VD, cast<VarDecl>(cast<DeclRefExpr>(*I)->getDecl()),
cast<VarDecl>(cast<DeclRefExpr>(*IElemInitRef)->getDecl())))); cast<VarDecl>(cast<DeclRefExpr>(*IElemInitRef)->getDecl()))));
++I, ++IElemInitRef; ++I;
++IElemInitRef;
} }
llvm::array_pod_sort(Privates.begin(), Privates.end(), llvm::array_pod_sort(Privates.begin(), Privates.end(),
array_pod_sort_comparator); array_pod_sort_comparator);
@ -3259,7 +3260,9 @@ static llvm::Value *emitReductionFunction(CodeGenModule &CGM,
} else } else
// Emit reduction for array subscript or single variable. // Emit reduction for array subscript or single variable.
CGF.EmitIgnoredExpr(E); CGF.EmitIgnoredExpr(E);
++IPriv, ++ILHS, ++IRHS; ++IPriv;
++ILHS;
++IRHS;
} }
Scope.ForceCleanup(); Scope.ForceCleanup();
CGF.FinishFunction(); CGF.FinishFunction();
@ -3326,7 +3329,9 @@ void CGOpenMPRuntime::emitReduction(CodeGenFunction &CGF, SourceLocation Loc,
const Expr *) { CGF.EmitIgnoredExpr(E); }); const Expr *) { CGF.EmitIgnoredExpr(E); });
} else } else
CGF.EmitIgnoredExpr(E); CGF.EmitIgnoredExpr(E);
++IPriv, ++ILHS, ++IRHS; ++IPriv;
++ILHS;
++IRHS;
} }
return; return;
} }
@ -3444,7 +3449,9 @@ void CGOpenMPRuntime::emitReduction(CodeGenFunction &CGF, SourceLocation Loc,
} else } else
// Emit reduction for array subscript or single variable. // Emit reduction for array subscript or single variable.
CGF.EmitIgnoredExpr(E); CGF.EmitIgnoredExpr(E);
++IPriv, ++ILHS, ++IRHS; ++IPriv;
++ILHS;
++IRHS;
} }
} }
@ -3553,7 +3560,9 @@ void CGOpenMPRuntime::emitReduction(CodeGenFunction &CGF, SourceLocation Loc,
} else } else
CritRedGen(CGF, nullptr, nullptr, nullptr); CritRedGen(CGF, nullptr, nullptr, nullptr);
} }
++ILHS, ++IRHS, ++IPriv; ++ILHS;
++IRHS;
++IPriv;
} }
} }

View File

@ -201,7 +201,8 @@ CodeGenFunction::GenerateOpenMPCapturedStmtFunction(const CapturedStmt &S) {
// use the value that we get from the arguments. // use the value that we get from the arguments.
if (I->capturesVariableByCopy() && FD->getType()->isAnyPointerType()) { if (I->capturesVariableByCopy() && FD->getType()->isAnyPointerType()) {
setAddrOfLocalVar(I->getCapturedVar(), GetAddrOfLocalVar(Args[Cnt])); setAddrOfLocalVar(I->getCapturedVar(), GetAddrOfLocalVar(Args[Cnt]));
++Cnt, ++I; ++Cnt;
++I;
continue; continue;
} }
@ -242,7 +243,8 @@ CodeGenFunction::GenerateOpenMPCapturedStmtFunction(const CapturedStmt &S) {
CXXThisValue = CXXThisValue =
EmitLoadOfLValue(ArgLVal, Args[Cnt]->getLocation()).getScalarVal(); EmitLoadOfLValue(ArgLVal, Args[Cnt]->getLocation()).getScalarVal();
} }
++Cnt, ++I; ++Cnt;
++I;
} }
PGO.assignRegionCounters(GlobalDecl(CD), F); PGO.assignRegionCounters(GlobalDecl(CD), F);
@ -489,7 +491,8 @@ bool CodeGenFunction::EmitOMPFirstprivateClause(const OMPExecutableDirective &D,
// Silence the warning about unused variable. // Silence the warning about unused variable.
(void)IsRegistered; (void)IsRegistered;
} }
++IRef, ++InitsRef; ++IRef;
++InitsRef;
} }
} }
return FirstprivateIsLastprivate && !EmittedAsFirstprivate.empty(); return FirstprivateIsLastprivate && !EmittedAsFirstprivate.empty();
@ -628,7 +631,8 @@ bool CodeGenFunction::EmitOMPLastprivateClauseInit(
(void)IsRegistered; (void)IsRegistered;
} }
} }
++IRef, ++IDestRef; ++IRef;
++IDestRef;
} }
} }
return HasAtLeastOneLastprivate; 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); FirstprivateCopies.push_back(IInit);
FirstprivateInits.push_back(*IElemInitRef); FirstprivateInits.push_back(*IElemInitRef);
} }
++IRef, ++IElemInitRef; ++IRef;
++IElemInitRef;
} }
} }
// Build list of dependences. // Build list of dependences.

View File

@ -707,7 +707,8 @@ void PrintPreprocessedAction::ExecuteAction() {
} else if (*cur == 0x0A) // LF } else if (*cur == 0x0A) // LF
break; break;
++cur, ++next; ++cur;
++next;
} }
} }

View File

@ -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 we have \n\r or \r\n, skip both and count as one line.
if (Len != 1 && if (Len != 1 &&
(TokStr[1] == '\n' || TokStr[1] == '\r') && (TokStr[1] == '\n' || TokStr[1] == '\r') &&
TokStr[0] != TokStr[1]) TokStr[0] != TokStr[1]) {
++TokStr, --Len; ++TokStr;
--Len;
}
} }
if (NumNewlines == 0) return; if (NumNewlines == 0) return;

View File

@ -719,7 +719,9 @@ SourceLocation Lexer::AdvanceToTokenCharacter(SourceLocation TokStart,
while (Lexer::isObviouslySimpleCharacter(*TokPtr)) { while (Lexer::isObviouslySimpleCharacter(*TokPtr)) {
if (CharNo == 0) if (CharNo == 0)
return TokStart.getLocWithOffset(PhysOffset); 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 // If we have a character that may be a trigraph or escaped newline, use a

View File

@ -650,8 +650,10 @@ static bool EvaluateDirectiveSubExpr(PPValue &LHS, unsigned MinPrec,
case tok::greatergreater: { case tok::greatergreater: {
// Determine whether overflow is about to happen. // Determine whether overflow is about to happen.
unsigned ShAmt = static_cast<unsigned>(RHS.Val.getLimitedValue()); unsigned ShAmt = static_cast<unsigned>(RHS.Val.getLimitedValue());
if (ShAmt >= LHS.getBitWidth()) if (ShAmt >= LHS.getBitWidth()) {
Overflow = true, ShAmt = LHS.getBitWidth()-1; Overflow = true;
ShAmt = LHS.getBitWidth()-1;
}
Res = LHS.Val >> ShAmt; Res = LHS.Val >> ShAmt;
break; break;
} }

View File

@ -350,8 +350,10 @@ void RopePieceBTreeLeaf::erase(unsigned Offset, unsigned NumBytes) {
PieceOffs += getPiece(i).size(); PieceOffs += getPiece(i).size();
// If we exactly include the last one, include it in the region to delete. // If we exactly include the last one, include it in the region to delete.
if (Offset+NumBytes == PieceOffs+getPiece(i).size()) if (Offset+NumBytes == PieceOffs+getPiece(i).size()) {
PieceOffs += getPiece(i).size(), ++i; PieceOffs += getPiece(i).size();
++i;
}
// If we completely cover some RopePieces, erase them now. // If we completely cover some RopePieces, erase them now.
if (i != StartPiece) { if (i != StartPiece) {

View File

@ -1307,17 +1307,30 @@ static bool SemaBuiltinCpuSupports(Sema &S, CallExpr *TheCall) {
bool Sema::CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) { bool Sema::CheckX86BuiltinFunctionCall(unsigned BuiltinID, CallExpr *TheCall) {
unsigned i = 0, l = 0, u = 0; unsigned i = 0, l = 0, u = 0;
switch (BuiltinID) { switch (BuiltinID) {
default: return false; default:
return false;
case X86::BI__builtin_cpu_supports: case X86::BI__builtin_cpu_supports:
return SemaBuiltinCpuSupports(*this, TheCall); return SemaBuiltinCpuSupports(*this, TheCall);
case X86::BI__builtin_ms_va_start: case X86::BI__builtin_ms_va_start:
return SemaBuiltinMSVAStart(TheCall); return SemaBuiltinMSVAStart(TheCall);
case X86::BI_mm_prefetch: i = 1; l = 0; u = 3; break; case X86::BI_mm_prefetch:
case X86::BI__builtin_ia32_sha1rnds4: i = 2, l = 0; u = 3; break; 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_vpermil2pd:
case X86::BI__builtin_ia32_vpermil2pd256: case X86::BI__builtin_ia32_vpermil2pd256:
case X86::BI__builtin_ia32_vpermil2ps: 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_cmpb128_mask:
case X86::BI__builtin_ia32_cmpw128_mask: case X86::BI__builtin_ia32_cmpw128_mask:
case X86::BI__builtin_ia32_cmpd128_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_ucmpb512_mask:
case X86::BI__builtin_ia32_ucmpw512_mask: case X86::BI__builtin_ia32_ucmpw512_mask:
case X86::BI__builtin_ia32_ucmpd512_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_roundps:
case X86::BI__builtin_ia32_roundpd: case X86::BI__builtin_ia32_roundpd:
case X86::BI__builtin_ia32_roundps256: 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_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_cmpps:
case X86::BI__builtin_ia32_cmpss: case X86::BI__builtin_ia32_cmpss:
case X86::BI__builtin_ia32_cmppd: 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_cmpps256:
case X86::BI__builtin_ia32_cmppd256: case X86::BI__builtin_ia32_cmppd256:
case X86::BI__builtin_ia32_cmpps512_mask: 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_vpcomub:
case X86::BI__builtin_ia32_vpcomuw: case X86::BI__builtin_ia32_vpcomuw:
case X86::BI__builtin_ia32_vpcomud: 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_vpcomb:
case X86::BI__builtin_ia32_vpcomw: case X86::BI__builtin_ia32_vpcomw:
case X86::BI__builtin_ia32_vpcomd: 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); return SemaBuiltinConstantArgRange(TheCall, i, l, u);
} }

View File

@ -8458,7 +8458,8 @@ static bool FinishOpenMPLinearClause(OMPLinearClause &Clause, DeclRefExpr *IV,
Updates.push_back(Update.get()); Updates.push_back(Update.get());
Finals.push_back(Final.get()); Finals.push_back(Final.get());
} }
++CurInit, ++CurPrivate; ++CurInit;
++CurPrivate;
} }
Clause.setUpdates(Updates); Clause.setUpdates(Updates);
Clause.setFinals(Finals); Clause.setFinals(Finals);

View File

@ -9056,8 +9056,10 @@ static void DiagnoseBadConversion(Sema &S, OverloadCandidate *Cand,
else { else {
// TODO: detect and diagnose the full richness of const mismatches. // TODO: detect and diagnose the full richness of const mismatches.
if (CanQual<PointerType> FromPT = CFromTy->getAs<PointerType>()) if (CanQual<PointerType> FromPT = CFromTy->getAs<PointerType>())
if (CanQual<PointerType> ToPT = CToTy->getAs<PointerType>()) if (CanQual<PointerType> ToPT = CToTy->getAs<PointerType>()) {
CFromTy = FromPT->getPointeeType(), CToTy = ToPT->getPointeeType(); CFromTy = FromPT->getPointeeType();
CToTy = ToPT->getPointeeType();
}
} }
if (CToTy.getUnqualifiedType() == CFromTy.getUnqualifiedType() && if (CToTy.getUnqualifiedType() == CFromTy.getUnqualifiedType() &&

View File

@ -980,7 +980,8 @@ Sema::ActOnFinishSwitchStmt(SourceLocation SwitchLoc, Stmt *Switch,
<< SourceRange(CR->getLHS()->getLocStart(), << SourceRange(CR->getLHS()->getLocStart(),
Hi->getLocEnd()); Hi->getLocEnd());
CaseRanges.erase(CaseRanges.begin()+i); CaseRanges.erase(CaseRanges.begin()+i);
--i, --e; --i;
--e;
continue; continue;
} }

View File

@ -8683,7 +8683,8 @@ TEST_F(FormatTest, ConfigurableSpacesInParentheses) {
verifyFormat("#define x (( int )-1)", Spaces); verifyFormat("#define x (( int )-1)", Spaces);
// Run the first set of tests again with: // Run the first set of tests again with:
Spaces.SpacesInParentheses = false, Spaces.SpaceInEmptyParentheses = true; Spaces.SpacesInParentheses = false;
Spaces.SpaceInEmptyParentheses = true;
Spaces.SpacesInCStyleCastParentheses = true; Spaces.SpacesInCStyleCastParentheses = true;
verifyFormat("call(x, y, z);", Spaces); verifyFormat("call(x, y, z);", Spaces);
verifyFormat("call( );", Spaces); verifyFormat("call( );", Spaces);