From: Chris Lattner Date: Tue, 4 Sep 2007 02:45:27 +0000 (+0000) Subject: Silence VC++ warnings, patch by Hartmut Kaiser X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=701e5eb608d7b0b94279b6be86bf90f8dea68e9e;p=clang Silence VC++ warnings, patch by Hartmut Kaiser git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41693 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/AST/Expr.cpp b/AST/Expr.cpp index c257b3b8e6..8ce5846cce 100644 --- a/AST/Expr.cpp +++ b/AST/Expr.cpp @@ -499,20 +499,23 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx, break; case CharacterLiteralClass: { const CharacterLiteral *CL = cast(this); - Result.zextOrTrunc(Ctx.getTypeSize(getType(), CL->getLoc())); + Result.zextOrTrunc( + static_cast(Ctx.getTypeSize(getType(), CL->getLoc()))); Result = CL->getValue(); Result.setIsUnsigned(!getType()->isSignedIntegerType()); break; } case TypesCompatibleExprClass: { const TypesCompatibleExpr *TCE = cast(this); - Result.zextOrTrunc(Ctx.getTypeSize(getType(), TCE->getLocStart())); + Result.zextOrTrunc( + static_cast(Ctx.getTypeSize(getType(), TCE->getLocStart()))); Result = TCE->typesAreCompatible(); break; } case CallExprClass: { const CallExpr *CE = cast(this); - Result.zextOrTrunc(Ctx.getTypeSize(getType(), CE->getLocStart())); + Result.zextOrTrunc( + static_cast(Ctx.getTypeSize(getType(), CE->getLocStart()))); if (CE->isBuiltinClassifyType(Result)) break; if (Loc) *Loc = getLocStart(); @@ -550,7 +553,8 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx, return false; // Return the result in the right width. - Result.zextOrTrunc(Ctx.getTypeSize(getType(), Exp->getOperatorLoc())); + Result.zextOrTrunc( + static_cast(Ctx.getTypeSize(getType(), Exp->getOperatorLoc()))); // Get information about the size or align. if (Exp->getOpcode() == UnaryOperator::SizeOf) @@ -562,7 +566,8 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx, break; case UnaryOperator::LNot: { bool Val = Result != 0; - Result.zextOrTrunc(Ctx.getTypeSize(getType(), Exp->getOperatorLoc())); + Result.zextOrTrunc( + static_cast(Ctx.getTypeSize(getType(), Exp->getOperatorLoc()))); Result = Val; break; } @@ -584,7 +589,8 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx, return false; // Return the result in the right width. - Result.zextOrTrunc(Ctx.getTypeSize(getType(), Exp->getOperatorLoc())); + Result.zextOrTrunc( + static_cast(Ctx.getTypeSize(getType(), Exp->getOperatorLoc()))); // Get information about the size or align. if (Exp->isSizeOf()) @@ -647,10 +653,12 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx, case BinaryOperator::Add: Result += RHS; break; case BinaryOperator::Sub: Result -= RHS; break; case BinaryOperator::Shl: - Result <<= RHS.getLimitedValue(Result.getBitWidth()-1); + Result <<= + static_cast(RHS.getLimitedValue(Result.getBitWidth()-1)); break; case BinaryOperator::Shr: - Result >>= RHS.getLimitedValue(Result.getBitWidth()-1); + Result >>= + static_cast(RHS.getLimitedValue(Result.getBitWidth()-1)); break; case BinaryOperator::LT: Result = Result < RHS; break; case BinaryOperator::GT: Result = Result > RHS; break; @@ -711,7 +719,8 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx, return false; // Figure out if this is a truncate, extend or noop cast. - unsigned DestWidth = Ctx.getTypeSize(getType(), CastLoc); + unsigned DestWidth = + static_cast(Ctx.getTypeSize(getType(), CastLoc)); // If the input is signed, do a sign extend, noop, or truncate. if (SubExpr->getType()->isSignedIntegerType()) diff --git a/Lex/PPExpressions.cpp b/Lex/PPExpressions.cpp index 48ec52af8c..2a18cfd610 100644 --- a/Lex/PPExpressions.cpp +++ b/Lex/PPExpressions.cpp @@ -475,7 +475,7 @@ static bool EvaluateDirectiveSubExpr(llvm::APSInt &LHS, unsigned MinPrec, break; case tok::lessless: { // Determine whether overflow is about to happen. - unsigned ShAmt = RHS.getLimitedValue(); + unsigned ShAmt = static_cast(RHS.getLimitedValue()); if (ShAmt >= LHS.getBitWidth()) Overflow = true, ShAmt = LHS.getBitWidth()-1; else if (LHS.isUnsigned()) @@ -490,7 +490,7 @@ static bool EvaluateDirectiveSubExpr(llvm::APSInt &LHS, unsigned MinPrec, } case tok::greatergreater: { // Determine whether overflow is about to happen. - unsigned ShAmt = RHS.getLimitedValue(); + unsigned ShAmt = static_cast(RHS.getLimitedValue()); if (ShAmt >= LHS.getBitWidth()) Overflow = true, ShAmt = LHS.getBitWidth()-1; Res = LHS >> ShAmt; diff --git a/Sema/Sema.h b/Sema/Sema.h index ff3ec1bfbc..95b89002ed 100644 --- a/Sema/Sema.h +++ b/Sema/Sema.h @@ -36,8 +36,8 @@ namespace clang { class TypedefDecl; class FunctionDecl; class QualType; - class LangOptions; - class DeclaratorChunk; + struct LangOptions; + struct DeclaratorChunk; class Token; class IntegerLiteral; class ArrayType; diff --git a/Sema/SemaDecl.cpp b/Sema/SemaDecl.cpp index f478bf3df9..a1ef816b01 100644 --- a/Sema/SemaDecl.cpp +++ b/Sema/SemaDecl.cpp @@ -1190,7 +1190,8 @@ Sema::DeclTy *Sema::ParseEnumConstant(Scope *S, DeclTy *theEnumDecl, } else { // First value, set to zero. EltTy = Context.IntTy; - EnumVal.zextOrTrunc(Context.getTypeSize(EltTy, IdLoc)); + EnumVal.zextOrTrunc( + static_cast(Context.getTypeSize(EltTy, IdLoc))); } } @@ -1420,7 +1421,7 @@ void Sema::HandleOCUVectorTypeAttribute(TypedefDecl *tDecl, } // unlike gcc's vector_size attribute, the size is specified as the // number of elements, not the number of bytes. - unsigned vectorSize = vecSize.getZExtValue(); + unsigned vectorSize = static_cast(vecSize.getZExtValue()); if (vectorSize == 0) { Diag(rawAttr->getAttributeLoc(), diag::err_attribute_zero_size, @@ -1473,9 +1474,10 @@ QualType Sema::HandleVectorTypeAttribute(QualType curType, curType.getCanonicalType().getAsString()); return QualType(); } - unsigned typeSize = Context.getTypeSize(curType, rawAttr->getAttributeLoc()); + unsigned typeSize = static_cast( + Context.getTypeSize(curType, rawAttr->getAttributeLoc())); // vecSize is specified in bytes - convert to bits. - unsigned vectorSize = vecSize.getZExtValue() * 8; + unsigned vectorSize = static_cast(vecSize.getZExtValue() * 8); // the vector size needs to be an integral multiple of the type size. if (vectorSize % typeSize) { diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp index 55b6d600c4..d2d1f9567c 100644 --- a/Sema/SemaExpr.cpp +++ b/Sema/SemaExpr.cpp @@ -129,7 +129,8 @@ Action::ExprResult Sema::ParseNumericConstant(const Token &Tok) { if (Tok.getLength() == 1) { const char *t = PP.getSourceManager().getCharacterData(Tok.getLocation()); - unsigned IntSize = Context.getTypeSize(Context.IntTy, Tok.getLocation()); + unsigned IntSize = static_cast( + Context.getTypeSize(Context.IntTy, Tok.getLocation())); return ExprResult(new IntegerLiteral(llvm::APInt(IntSize, *t-'0'), Context.IntTy, Tok.getLocation())); @@ -181,7 +182,8 @@ Action::ExprResult Sema::ParseNumericConstant(const Token &Tok) { // Check from smallest to largest, picking the smallest type we can. if (!Literal.isLong && !Literal.isLongLong) { // Are int/unsigned possibilities? - unsigned IntSize = Context.getTypeSize(Context.IntTy,Tok.getLocation()); + unsigned IntSize = static_cast( + Context.getTypeSize(Context.IntTy,Tok.getLocation())); // Does it fit in a unsigned int? if (ResultVal.isIntN(IntSize)) { // Does it fit in a signed int? @@ -197,8 +199,8 @@ Action::ExprResult Sema::ParseNumericConstant(const Token &Tok) { // Are long/unsigned long possibilities? if (t.isNull() && !Literal.isLongLong) { - unsigned LongSize = Context.getTypeSize(Context.LongTy, - Tok.getLocation()); + unsigned LongSize = static_cast( + Context.getTypeSize(Context.LongTy, Tok.getLocation())); // Does it fit in a unsigned long? if (ResultVal.isIntN(LongSize)) { @@ -214,8 +216,8 @@ Action::ExprResult Sema::ParseNumericConstant(const Token &Tok) { // Finally, check long long if needed. if (t.isNull()) { - unsigned LongLongSize = - Context.getTypeSize(Context.LongLongTy, Tok.getLocation()); + unsigned LongLongSize = static_cast( + Context.getTypeSize(Context.LongLongTy, Tok.getLocation())); // Does it fit in a unsigned long long? if (ResultVal.isIntN(LongLongSize)) {