[cfe-commits] r47226 - in /cfe/trunk: CodeGen/CGExprScalar.cpp test/CodeGen/compound.c
Chris Lattner
sabre at nondot.org
Sat Feb 16 15:55:17 PST 2008
Author: lattner
Date: Sat Feb 16 17:55:16 2008
New Revision: 47226
URL: http://llvm.org/viewvc/llvm-project?rev=47226&view=rev
Log:
implement codegen support for aggregates casted to void.
Modified:
cfe/trunk/CodeGen/CGExprScalar.cpp
cfe/trunk/test/CodeGen/compound.c
Modified: cfe/trunk/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/CodeGen/CGExprScalar.cpp?rev=47226&r1=47225&r2=47226&view=diff
==============================================================================
--- cfe/trunk/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/CodeGen/CGExprScalar.cpp Sat Feb 16 17:55:16 2008
@@ -508,16 +508,24 @@
// handle things like function to ptr-to-function decay etc.
Value *ScalarExprEmitter::EmitCastExpr(const Expr *E, QualType DestTy) {
// Handle cases where the source is an non-complex type.
- if (!E->getType()->isComplexType()) {
+
+ if (!CGF.hasAggregateLLVMType(E->getType())) {
Value *Src = Visit(const_cast<Expr*>(E));
// Use EmitScalarConversion to perform the conversion.
return EmitScalarConversion(Src, E->getType(), DestTy);
}
+
+ if (E->getType()->isComplexType()) {
+ // Handle cases where the source is a complex type.
+ return EmitComplexToScalarConversion(CGF.EmitComplexExpr(E), E->getType(),
+ DestTy);
+ }
- // Handle cases where the source is a complex type.
- return EmitComplexToScalarConversion(CGF.EmitComplexExpr(E), E->getType(),
- DestTy);
+ // Okay, this is a cast from an aggregate. It must be a cast to void. Just
+ // evaluate the result and return.
+ CGF.EmitAggExpr(E, 0, false);
+ return 0;
}
Value *ScalarExprEmitter::VisitStmtExpr(const StmtExpr *E) {
Modified: cfe/trunk/test/CodeGen/compound.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/compound.c?rev=47226&r1=47225&r2=47226&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/compound.c (original)
+++ cfe/trunk/test/CodeGen/compound.c Sat Feb 16 17:55:16 2008
@@ -1,4 +1,4 @@
-// RUN: clang %s -emit-llvm
+// RUN: clang < %s -emit-llvm
int A;
long long B;
int C;
@@ -18,3 +18,8 @@
int stufflen = 4;
strbuf += stufflen;
}
+
+
+// Aggregate cast to void
+union uu { int a;}; void f(union uu p) { (void) p;}
+
More information about the cfe-commits
mailing list