[cfe-commits] r81835 - in /cfe/trunk: lib/AST/ExprConstant.cpp lib/CodeGen/CGExprScalar.cpp lib/CodeGen/CodeGenTypes.cpp test/CodeGenCXX/nullptr.cpp
Anders Carlsson
andersca at mac.com
Mon Sep 14 21:39:46 PDT 2009
Author: andersca
Date: Mon Sep 14 23:39:46 2009
New Revision: 81835
URL: http://llvm.org/viewvc/llvm-project?rev=81835&view=rev
Log:
Codegen support for nullptr from C++0x.
Added:
cfe/trunk/test/CodeGenCXX/nullptr.cpp
Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=81835&r1=81834&r2=81835&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Mon Sep 14 23:39:46 2009
@@ -383,7 +383,8 @@
// Check for pointer->pointer cast
if (SubExpr->getType()->isPointerType() ||
- SubExpr->getType()->isObjCObjectPointerType()) {
+ SubExpr->getType()->isObjCObjectPointerType() ||
+ SubExpr->getType()->isNullPtrType()) {
APValue Result;
if (EvaluatePointer(SubExpr, Result, Info))
return Result;
Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=81835&r1=81834&r2=81835&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Mon Sep 14 23:39:46 2009
@@ -308,6 +308,10 @@
return 0;
}
+ Value *VisitCXXNullPtrLiteralExpr(const CXXNullPtrLiteralExpr *E) {
+ return llvm::Constant::getNullValue(ConvertType(E->getType()));
+ }
+
// Binary Operators.
Value *EmitMul(const BinOpInfo &Ops) {
if (CGF.getContext().getLangOptions().OverflowChecking
Modified: cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenTypes.cpp?rev=81835&r1=81834&r2=81835&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenTypes.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenTypes.cpp Mon Sep 14 23:39:46 2009
@@ -229,6 +229,12 @@
return getTypeForFormat(getLLVMContext(),
Context.getFloatTypeSemantics(T));
+ case BuiltinType::NullPtr: {
+ // Model std::nullptr_t as i8*
+ const llvm::Type *Ty = llvm::IntegerType::get(getLLVMContext(), 8);
+ return llvm::PointerType::getUnqual(Ty);
+ }
+
case BuiltinType::UInt128:
case BuiltinType::Int128:
return llvm::IntegerType::get(getLLVMContext(), 128);
Added: cfe/trunk/test/CodeGenCXX/nullptr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/nullptr.cpp?rev=81835&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/nullptr.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/nullptr.cpp Mon Sep 14 23:39:46 2009
@@ -0,0 +1,7 @@
+// RUN: clang-cc -std=c++0x %s -emit-llvm -o %t
+
+int* a = nullptr;
+
+void f() {
+ int* a = nullptr;
+}
More information about the cfe-commits
mailing list