[cfe-commits] r79929 - in /cfe/trunk: lib/CodeGen/CGExprScalar.cpp test/CodeGenCXX/member-pointers-zero-init.cpp
Anders Carlsson
andersca at mac.com
Mon Aug 24 11:26:39 PDT 2009
Author: andersca
Date: Mon Aug 24 13:26:39 2009
New Revision: 79929
URL: http://llvm.org/viewvc/llvm-project?rev=79929&view=rev
Log:
Handle CK_NullToMemberPointer in ScalarExprEmitter::EmitCast
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/test/CodeGenCXX/member-pointers-zero-init.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=79929&r1=79928&r2=79929&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Mon Aug 24 13:26:39 2009
@@ -656,7 +656,14 @@
CastExpr::CastKind Kind) {
if (!DestTy->isVoidType())
TestAndClearIgnoreResultAssign();
-
+
+ switch (Kind) {
+ default:
+ break;
+ case CastExpr::CK_NullToMemberPointer:
+ return CGF.CGM.EmitNullConstant(DestTy);
+ }
+
// Handle cases where the source is an non-complex type.
if (!CGF.hasAggregateLLVMType(E->getType())) {
Modified: cfe/trunk/test/CodeGenCXX/member-pointers-zero-init.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/member-pointers-zero-init.cpp?rev=79929&r1=79928&r2=79929&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/member-pointers-zero-init.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/member-pointers-zero-init.cpp Mon Aug 24 13:26:39 2009
@@ -17,11 +17,18 @@
int A::* b = 0;
void f() {
- // RUN: grep "%.* = icmp ne i64 %.*, -1" %t
+ // RUN: grep "%.* = icmp ne i64 %.*, -1" %t | count 2 &&
if (a) { }
+ if (a != 0) { }
+
+ // RUN: grep "%.* = icmp ne i64 -1, %.*" %t | count 1 &&
+ if (0 != a) { }
- // FIXME: This doesn't yet work
-// if (a != 0) { }
+ // RUN: grep "%.* = icmp eq i64 %.*, -1" %t | count 1 &&
+ if (a == 0) { }
+
+ // RUN: grep "%.* = icmp eq i64 -1, %.*" %t | count 1
+ if (0 == a) { }
}
More information about the cfe-commits
mailing list