зеркало из https://github.com/microsoft/clang-1.git
Add codegen support for __null
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@61314 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
a89d82c1c8
Коммит
3f70456b8a
|
@ -416,6 +416,12 @@ public:
|
||||||
return true;
|
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) {
|
bool VisitCXXZeroInitValueExpr(const CXXZeroInitValueExpr *E) {
|
||||||
Result = APSInt::getNullValue(getIntTypeSizeInBits(E->getType()));
|
Result = APSInt::getNullValue(getIntTypeSizeInBits(E->getType()));
|
||||||
Result.setIsUnsigned(E->getType()->isUnsignedIntegerType());
|
Result.setIsUnsigned(E->getType()->isUnsignedIntegerType());
|
||||||
|
|
|
@ -113,6 +113,9 @@ public:
|
||||||
Value *VisitCXXZeroInitValueExpr(const CXXZeroInitValueExpr *E) {
|
Value *VisitCXXZeroInitValueExpr(const CXXZeroInitValueExpr *E) {
|
||||||
return llvm::Constant::getNullValue(ConvertType(E->getType()));
|
return llvm::Constant::getNullValue(ConvertType(E->getType()));
|
||||||
}
|
}
|
||||||
|
Value *VisitGNUNullExpr(const GNUNullExpr *E) {
|
||||||
|
return llvm::Constant::getNullValue(ConvertType(E->getType()));
|
||||||
|
}
|
||||||
Value *VisitTypesCompatibleExpr(const TypesCompatibleExpr *E) {
|
Value *VisitTypesCompatibleExpr(const TypesCompatibleExpr *E) {
|
||||||
return llvm::ConstantInt::get(ConvertType(E->getType()),
|
return llvm::ConstantInt::get(ConvertType(E->getType()),
|
||||||
CGF.getContext().typesAreCompatible(
|
CGF.getContext().typesAreCompatible(
|
||||||
|
|
|
@ -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;
|
||||||
|
}
|
|
@ -8,4 +8,7 @@ void f() {
|
||||||
|
|
||||||
// Verify statically that __null is the right size
|
// Verify statically that __null is the right size
|
||||||
int a[sizeof(typeof(__null)) == sizeof(void*)? 1 : -1];
|
int a[sizeof(typeof(__null)) == sizeof(void*)? 1 : -1];
|
||||||
|
|
||||||
|
// Verify that null is evaluated as 0.
|
||||||
|
int b[__null ? -1 : 1];
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче