aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExprObjC.cpp
diff options
context:
space:
mode:
authorJohn McCall <rjmccall@apple.com>2010-11-13 01:35:44 +0000
committerJohn McCall <rjmccall@apple.com>2010-11-13 01:35:44 +0000
commit404cd1669c3ba138a9ae0a619bd689cce5aae271 (patch)
treea053c793cd8d0204c8b52a673e79aa7d387ba52d /lib/Sema/SemaExprObjC.cpp
parent73d15c452e675b684b7eee4f2096e386e59397aa (diff)
Introduce a null-to-pointer implicit cast kind.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118966 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExprObjC.cpp')
-rw-r--r--lib/Sema/SemaExprObjC.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/Sema/SemaExprObjC.cpp b/lib/Sema/SemaExprObjC.cpp
index 5ddf94597b..be87a42a3c 100644
--- a/lib/Sema/SemaExprObjC.cpp
+++ b/lib/Sema/SemaExprObjC.cpp
@@ -1014,9 +1014,13 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver,
if (ReceiverType->isPointerType())
ImpCastExprToType(Receiver, Context.getObjCIdType(),
CK_BitCast);
- else
+ else {
+ // TODO: specialized warning on null receivers?
+ bool IsNull = Receiver->isNullPointerConstant(Context,
+ Expr::NPC_ValueDependentIsNull);
ImpCastExprToType(Receiver, Context.getObjCIdType(),
- CK_IntegralToPointer);
+ IsNull ? CK_NullToPointer : CK_IntegralToPointer);
+ }
ReceiverType = Receiver->getType();
}
else if (getLangOptions().CPlusPlus &&