[cfe-commits] r55249 - in /cfe/trunk: lib/AST/Expr.cpp lib/CodeGen/CGExprComplex.cpp lib/CodeGen/CGExprConstant.cpp lib/CodeGen/CGExprScalar.cpp test/CodeGen/cxx-value-init.cpp

Argiris Kirtzidis akyrtzi at gmail.com
Sat Aug 23 12:35:47 PDT 2008


Author: akirtzidis
Date: Sat Aug 23 14:35:47 2008
New Revision: 55249

URL: http://llvm.org/viewvc/llvm-project?rev=55249&view=rev
Log:
Add CodeGen support for CXXZeroInitValueExpr.

Added:
    cfe/trunk/test/CodeGen/cxx-value-init.cpp
Modified:
    cfe/trunk/lib/AST/Expr.cpp
    cfe/trunk/lib/CodeGen/CGExprComplex.cpp
    cfe/trunk/lib/CodeGen/CGExprConstant.cpp
    cfe/trunk/lib/CodeGen/CGExprScalar.cpp

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

==============================================================================
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Sat Aug 23 14:35:47 2008
@@ -720,6 +720,9 @@
     Result.setIsUnsigned(!getType()->isSignedIntegerType());
     break;
   }
+  case CXXZeroInitValueExprClass:
+    Result.clear();
+    break;
   case TypesCompatibleExprClass: {
     const TypesCompatibleExpr *TCE = cast<TypesCompatibleExpr>(this);
     Result.zextOrTrunc(static_cast<uint32_t>(Ctx.getTypeSize(getType())));

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprComplex.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprComplex.cpp Sat Aug 23 14:35:47 2008
@@ -124,6 +124,12 @@
   ComplexPairTy VisitCXXDefaultArgExpr(CXXDefaultArgExpr *DAE) {
     return Visit(DAE->getExpr());
   }
+  ComplexPairTy VisitCXXZeroInitValueExpr(CXXZeroInitValueExpr *E) {
+    assert(E->getType()->isAnyComplexType() && "Expected complex type!");
+    QualType Elem = E->getType()->getAsComplexType()->getElementType();
+    llvm::Constant *Null = llvm::Constant::getNullValue(CGF.ConvertType(Elem));
+    return ComplexPairTy(Null, Null);
+  }
   
   struct BinOpInfo {
     ComplexPairTy LHS;

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Sat Aug 23 14:35:47 2008
@@ -61,6 +61,9 @@
   llvm::Constant *VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *E) {
     return llvm::ConstantInt::get(ConvertType(E->getType()), E->getValue());
   }
+  llvm::Constant *VisitCXXZeroInitValueExpr(const CXXZeroInitValueExpr *E) {
+    return llvm::Constant::getNullValue(ConvertType(E->getType()));
+  }
   llvm::Constant *VisitObjCStringLiteral(const ObjCStringLiteral *E) {
     std::string S(E->getString()->getStrData(), 
                   E->getString()->getByteLength());

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

==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Sat Aug 23 14:35:47 2008
@@ -109,6 +109,9 @@
   Value *VisitCXXBoolLiteralExpr(const CXXBoolLiteralExpr *E) {
     return llvm::ConstantInt::get(ConvertType(E->getType()), E->getValue());
   }
+  Value *VisitCXXZeroInitValueExpr(const CXXZeroInitValueExpr *E) {
+    return llvm::Constant::getNullValue(ConvertType(E->getType()));
+  }
   Value *VisitTypesCompatibleExpr(const TypesCompatibleExpr *E) {
     return llvm::ConstantInt::get(ConvertType(E->getType()),
                                   CGF.getContext().typesAreCompatible(

Added: cfe/trunk/test/CodeGen/cxx-value-init.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/cxx-value-init.cpp?rev=55249&view=auto

==============================================================================
--- cfe/trunk/test/CodeGen/cxx-value-init.cpp (added)
+++ cfe/trunk/test/CodeGen/cxx-value-init.cpp Sat Aug 23 14:35:47 2008
@@ -0,0 +1,11 @@
+// RUN: clang -emit-llvm %s -o %t
+
+enum E {};
+int v1 = E();
+float v2 = float();
+
+void f() {
+  int v3 = int();
+  _Complex int v4 = typeof(_Complex int)();
+  _Complex float v5 = typeof(_Complex float)();
+}





More information about the cfe-commits mailing list