]> granicus.if.org Git - clang/commitdiff
More objective-c typechecking stuff. This is work in progress and more patches
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 20 Dec 2007 01:06:58 +0000 (01:06 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 20 Dec 2007 01:06:58 +0000 (01:06 +0000)
are due to arrive.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45244 91177308-0d34-0410-b5e6-96231b3b80d8

Sema/SemaChecking.cpp
Sema/SemaExpr.cpp
include/clang/AST/Type.h

index 01314102d425538f88c3cc8f8841990cedd36ba8..09304399e97f27c39525fb96f6bb2aa89d5623b0 100644 (file)
@@ -594,7 +594,9 @@ Sema::CheckReturnStackAddr(Expr *RetValExp, QualType lhsType,
 static DeclRefExpr* EvalAddr(Expr *E) {
 
   // We should only be called for evaluating pointer expressions.
-  assert (E->getType()->isPointerType() && "EvalAddr only works on pointers");
+  assert ((E->getType()->isPointerType() || 
+           E->getType()->isObjcQualifiedIdType())
+             && "EvalAddr only works on pointers");
     
   // Our "symbolic interpreter" is just a dispatch off the currently
   // viewed AST node.  We then recursively traverse the AST by calling
@@ -654,7 +656,8 @@ static DeclRefExpr* EvalAddr(Expr *E) {
       ImplicitCastExpr *IE = cast<ImplicitCastExpr>(E);
       Expr* SubExpr = IE->getSubExpr();
       
-      if (SubExpr->getType()->isPointerType())
+      if (SubExpr->getType()->isPointerType() ||
+          SubExpr->getType()->isObjcQualifiedIdType())
         return EvalAddr(SubExpr);
       else
         return EvalVal(SubExpr);
index 846c52905c1b040a454318ce84a33e712602afa8..e720c2e460343c081d497beed921ed0c4c3d1009 100644 (file)
@@ -1399,6 +1399,11 @@ inline QualType Sema::CheckCompareOperands( // C99 6.5.8
     promoteExprToType(rex, lType); // promote the pointer to pointer
     return Context.IntTy;
   }
+  if ((lType->isObjcQualifiedIdType() || rType->isObjcQualifiedIdType())
+      && Context.ObjcQualifiedIdTypesAreCompatible(lType, rType)) {
+    promoteExprToType(rex, lType); 
+    return Context.IntTy;
+  }
   if (lType->isPointerType() && rType->isIntegerType()) {
     if (!RHSIsNull)
       Diag(loc, diag::ext_typecheck_comparison_of_pointer_integer,
index 7c9391080630998defa8a77a6964d2a64b8f4676..e3825a9f31465332b7592e559b3de843111fb5a3 100644 (file)
@@ -1029,8 +1029,7 @@ inline bool Type::isFunctionType() const {
   return isa<FunctionType>(CanonicalType);
 }
 inline bool Type::isPointerType() const {
-  return isa<PointerType>(CanonicalType) || 
-        isa<ObjcQualifiedIdType>(CanonicalType);
+  return isa<PointerType>(CanonicalType); 
 }
 inline bool Type::isFunctionPointerType() const {
   if (const PointerType* T = getAsPointerType())