]> granicus.if.org Git - clang/commitdiff
Silence VC++ warnings, patch by Hartmut Kaiser
authorChris Lattner <sabre@nondot.org>
Tue, 4 Sep 2007 02:45:27 +0000 (02:45 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 4 Sep 2007 02:45:27 +0000 (02:45 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@41693 91177308-0d34-0410-b5e6-96231b3b80d8

AST/Expr.cpp
Lex/PPExpressions.cpp
Sema/Sema.h
Sema/SemaDecl.cpp
Sema/SemaExpr.cpp

index c257b3b8e6640d74968aa006cb067802b91da510..8ce5846cceb5e4be26632551fe342703d28eda30 100644 (file)
@@ -499,20 +499,23 @@ bool Expr::isIntegerConstantExpr(llvm::APSInt &Result, ASTContext &Ctx,
     break;
   case CharacterLiteralClass: {
     const CharacterLiteral *CL = cast<CharacterLiteral>(this);
-    Result.zextOrTrunc(Ctx.getTypeSize(getType(), CL->getLoc()));                              
+    Result.zextOrTrunc(
+      static_cast<uint32_t>(Ctx.getTypeSize(getType(), CL->getLoc())));
     Result = CL->getValue();
     Result.setIsUnsigned(!getType()->isSignedIntegerType());
     break;
   }
   case TypesCompatibleExprClass: {
     const TypesCompatibleExpr *TCE = cast<TypesCompatibleExpr>(this);
-    Result.zextOrTrunc(Ctx.getTypeSize(getType(), TCE->getLocStart()));                              
+    Result.zextOrTrunc(
+      static_cast<uint32_t>(Ctx.getTypeSize(getType(), TCE->getLocStart())));
     Result = TCE->typesAreCompatible();
     break;
   }
   case CallExprClass: {
     const CallExpr *CE = cast<CallExpr>(this);
-    Result.zextOrTrunc(Ctx.getTypeSize(getType(), CE->getLocStart()));
+    Result.zextOrTrunc(
+      static_cast<uint32_t>(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<uint32_t>(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<uint32_t>(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<uint32_t>(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<uint32_t>(RHS.getLimitedValue(Result.getBitWidth()-1));
       break;
     case BinaryOperator::Shr:
-      Result >>= RHS.getLimitedValue(Result.getBitWidth()-1);
+      Result >>= 
+        static_cast<uint32_t>(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<uint32_t>(Ctx.getTypeSize(getType(), CastLoc));
       
       // If the input is signed, do a sign extend, noop, or truncate.
       if (SubExpr->getType()->isSignedIntegerType())
index 48ec52af8cbf4590a3d933862f81ab9d506598bd..2a18cfd610251b218afcf0a97edd1f056999c0f7 100644 (file)
@@ -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<unsigned>(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<unsigned>(RHS.getLimitedValue());
       if (ShAmt >= LHS.getBitWidth())
         Overflow = true, ShAmt = LHS.getBitWidth()-1;
       Res = LHS >> ShAmt;
index ff3ec1bfbcc643268de0d951cd67d4a6a2921fc0..95b89002ed8a59ef10c8c467006c1568e30c5697 100644 (file)
@@ -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;
index f478bf3df9ae7928f116d4afab2b68a076ec7d52..a1ef816b01ef1b740021e970496068781749a077 100644 (file)
@@ -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<uint32_t>(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<unsigned>(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<unsigned>(
+    Context.getTypeSize(curType, rawAttr->getAttributeLoc()));
   // vecSize is specified in bytes - convert to bits.
-  unsigned vectorSize = vecSize.getZExtValue() * 8
+  unsigned vectorSize = static_cast<unsigned>(vecSize.getZExtValue() * 8)
   
   // the vector size needs to be an integral multiple of the type size.
   if (vectorSize % typeSize) {
index 55b6d600c4e2708e84d27e7512282519f4c8793a..d2d1f9567c24c476cf8413501c13bb9825c604b7 100644 (file)
@@ -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<unsigned>(
+      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<unsigned>(
+          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<unsigned>(
+          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<unsigned>(
+          Context.getTypeSize(Context.LongLongTy, Tok.getLocation()));
         
         // Does it fit in a unsigned long long?
         if (ResultVal.isIntN(LongLongSize)) {