[cfe-commits] r61314 - in /cfe/trunk: lib/AST/ExprConstant.cpp lib/CodeGen/CGExprScalar.cpp test/CodeGenCXX/ test/CodeGenCXX/__null.cpp test/SemaCXX/__null.cpp
Anders Carlsson
andersca at mac.com
Sun Dec 21 14:39:45 PST 2008
Author: andersca
Date: Sun Dec 21 16:39:40 2008
New Revision: 61314
URL: http://llvm.org/viewvc/llvm-project?rev=61314&view=rev
Log:
Add codegen support for __null
Added:
cfe/trunk/test/CodeGenCXX/
cfe/trunk/test/CodeGenCXX/__null.cpp
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/test/SemaCXX/__null.cpp
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=61314&r1=61313&r2=61314&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Sun Dec 21 16:39:40 2008
@@ -416,6 +416,12 @@
return true;
}
+ bool VisitGNUNullExpr(const GNUNullExpr *E) {
+ Result = APSInt::getNullValue(getIntTypeSizeInBits(E->getType()));
+ Result.setIsUnsigned(E->getType()->isUnsignedIntegerType());
+ return true;
+ }
+
bool VisitCXXZeroInitValueExpr(const CXXZeroInitValueExpr *E) {
Result = APSInt::getNullValue(getIntTypeSizeInBits(E->getType()));
Result.setIsUnsigned(E->getType()->isUnsignedIntegerType());
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=61314&r1=61313&r2=61314&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Sun Dec 21 16:39:40 2008
@@ -113,6 +113,9 @@
Value *VisitCXXZeroInitValueExpr(const CXXZeroInitValueExpr *E) {
return llvm::Constant::getNullValue(ConvertType(E->getType()));
}
+ Value *VisitGNUNullExpr(const GNUNullExpr *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/CodeGenCXX/__null.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/__null.cpp?rev=61314&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/__null.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/__null.cpp Sun Dec 21 16:39:40 2008
@@ -0,0 +1,9 @@
+// RUN: clang %s -emit-llvm -o %t
+
+int* a = __null;
+int b = __null;
+
+void f() {
+ int* c = __null;
+ int d = __null;
+}
Modified: cfe/trunk/test/SemaCXX/__null.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/__null.cpp?rev=61314&r1=61313&r2=61314&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/__null.cpp (original)
+++ cfe/trunk/test/SemaCXX/__null.cpp Sun Dec 21 16:39:40 2008
@@ -8,4 +8,7 @@
// Verify statically that __null is the right size
int a[sizeof(typeof(__null)) == sizeof(void*)? 1 : -1];
+
+ // Verify that null is evaluated as 0.
+ int b[__null ? -1 : 1];
}
More information about the cfe-commits
mailing list