[cfe-commits] r84039 - in /cfe/trunk/lib: AST/Expr.cpp CodeGen/CGExprConstant.cpp

Chris Lattner sabre at nondot.org
Tue Oct 13 15:12:10 PDT 2009


Author: lattner
Date: Tue Oct 13 17:12:09 2009
New Revision: 84039

URL: http://llvm.org/viewvc/llvm-project?rev=84039&view=rev
Log:
fix test/CodeGen/statements.c on 32-bit hosts.

Modified:
    cfe/trunk/lib/AST/Expr.cpp
    cfe/trunk/lib/CodeGen/CGExprConstant.cpp

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=84039&r1=84038&r2=84039&view=diff

==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Tue Oct 13 17:12:09 2009
@@ -1281,6 +1281,13 @@
     // cast-to-union extension.
     if (getType()->isRecordType())
       return cast<CastExpr>(this)->getSubExpr()->isConstantInitializer(Ctx);
+      
+    // Integer->integer casts can be handled here, which is important for
+    // things like (int)(&&x-&&y).  Scary but true.
+    if (getType()->isIntegerType() &&
+        cast<CastExpr>(this)->getSubExpr()->getType()->isIntegerType())
+      return cast<CastExpr>(this)->getSubExpr()->isConstantInitializer(Ctx);
+      
     break;
   }
   return isEvaluatable(Ctx);

Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprConstant.cpp?rev=84039&r1=84038&r2=84039&view=diff

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Tue Oct 13 17:12:09 2009
@@ -548,7 +548,18 @@
       // Explicit and implicit no-op casts
       QualType Ty = E->getType(), SubTy = E->getSubExpr()->getType();
       if (CGM.getContext().hasSameUnqualifiedType(Ty, SubTy))
-          return Visit(E->getSubExpr());
+        return Visit(E->getSubExpr());
+
+      // Handle integer->integer casts for address-of-label differences.
+      if (Ty->isIntegerType() && SubTy->isIntegerType() &&
+          CGF) {
+        llvm::Value *Src = Visit(E->getSubExpr());
+        if (Src == 0) return 0;
+        
+        // Use EmitScalarConversion to perform the conversion.
+        return cast<llvm::Constant>(CGF->EmitScalarConversion(Src, SubTy, Ty));
+      }
+      
       return 0;
     }
     }





More information about the cfe-commits mailing list