[cfe-commits] r104447 - in /cfe/trunk: lib/CodeGen/CGExprScalar.cpp test/CodeGenCXX/pointers-to-data-members.cpp
Anders Carlsson
andersca at mac.com
Sat May 22 10:45:10 PDT 2010
Author: andersca
Date: Sat May 22 12:45:10 2010
New Revision: 104447
URL: http://llvm.org/viewvc/llvm-project?rev=104447&view=rev
Log:
Really fix PR7139. There was one boost test that we still failed, and my first fix broke self-host.
Modified:
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/test/CodeGenCXX/pointers-to-data-members.cpp
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=104447&r1=104446&r2=104447&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Sat May 22 12:45:10 2010
@@ -96,6 +96,9 @@
Value *EmitComplexToScalarConversion(CodeGenFunction::ComplexPairTy Src,
QualType SrcTy, QualType DstTy);
+ /// EmitNullValue - Emit a value that corresponds to null for the given type.
+ Value *EmitNullValue(QualType Ty);
+
//===--------------------------------------------------------------------===//
// Visitor Methods
//===--------------------------------------------------------------------===//
@@ -123,10 +126,10 @@
return llvm::ConstantInt::get(ConvertType(E->getType()), E->getValue());
}
Value *VisitCXXZeroInitValueExpr(const CXXZeroInitValueExpr *E) {
- return llvm::Constant::getNullValue(ConvertType(E->getType()));
+ return EmitNullValue(E->getType());
}
Value *VisitGNUNullExpr(const GNUNullExpr *E) {
- return llvm::Constant::getNullValue(ConvertType(E->getType()));
+ return EmitNullValue(E->getType());
}
Value *VisitTypesCompatibleExpr(const TypesCompatibleExpr *E) {
return llvm::ConstantInt::get(ConvertType(E->getType()),
@@ -278,7 +281,7 @@
}
Value *VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *E) {
- return llvm::Constant::getNullValue(ConvertType(E->getType()));
+ return EmitNullValue(E->getType());
}
Value *VisitCXXThrowExpr(const CXXThrowExpr *E) {
@@ -549,6 +552,19 @@
return EmitScalarConversion(Src.first, SrcTy, DstTy);
}
+Value *ScalarExprEmitter::EmitNullValue(QualType Ty) {
+ const llvm::Type *LTy = ConvertType(Ty);
+
+ if (!Ty->isMemberPointerType())
+ return llvm::Constant::getNullValue(LTy);
+
+ assert(!Ty->isMemberFunctionPointerType() &&
+ "member function pointers are not scalar!");
+
+ // Itanium C++ ABI 2.3:
+ // A NULL pointer is represented as -1.
+ return llvm::ConstantInt::get(LTy, -1ULL, /*isSigned=*/true);
+}
//===----------------------------------------------------------------------===//
// Visitor Methods
Modified: cfe/trunk/test/CodeGenCXX/pointers-to-data-members.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/pointers-to-data-members.cpp?rev=104447&r1=104446&r2=104447&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/pointers-to-data-members.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/pointers-to-data-members.cpp Sat May 22 12:45:10 2010
@@ -144,4 +144,10 @@
return A().a.data == 0;
}
+// CHECK-O3: define zeroext i1 @_ZN6PR71396check2Ev() nounwind readnone
+bool check2() {
+ // CHECK-O3: ret i1 true
+ return ptr_to_member_type() == 0;
+}
+
}
More information about the cfe-commits
mailing list