]> granicus.if.org Git - clang/commitdiff
Enhance Evaluate to handle ObjC qualified id and class types; as far as
authorEli Friedman <eli.friedman@gmail.com>
Sun, 22 Feb 2009 04:02:33 +0000 (04:02 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Sun, 22 Feb 2009 04:02:33 +0000 (04:02 +0000)
I know, these follow the exact same rules as pointers, so I just made
them use the same codepath.  Someone more familiar with ObjC should
double-check this, though.

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

lib/AST/ASTContext.cpp
lib/AST/ExprConstant.cpp

index fce2289574796f8a4006261b9e6b7da07b549fc2..78f2a8a9ab5c7ca9bc3d33c0f221181a72481611 100644 (file)
@@ -387,6 +387,7 @@ ASTContext::getTypeInfo(const Type *T) {
     // alignment requirements: getPointerInfo should take an AddrSpace.
     return getTypeInfo(QualType(cast<ExtQualType>(T)->getBaseType(), 0));
   case Type::ObjCQualifiedId:
+  case Type::ObjCQualifiedClass:
     Width = Target.getPointerWidth(0);
     Align = Target.getPointerAlign(0);
     break;
index 103bc37f4fe88fdf1e3362e675b6d10e5cd6f1c3..8f43700e46d1df896ac239dd5b50de0392e4ce24 100644 (file)
@@ -279,9 +279,15 @@ public:
 };
 } // end anonymous namespace
 
+static bool HasPointerEvalType(const Expr* E) {
+  return E->getType()->isPointerType()
+         || E->getType()->isBlockPointerType()
+         || E->getType()->isObjCQualifiedIdType()
+         || E->getType()->isObjCQualifiedClassType();
+}
+
 static bool EvaluatePointer(const Expr* E, APValue& Result, EvalInfo &Info) {
-  if (!E->getType()->isPointerType()
-      && !E->getType()->isBlockPointerType())
+  if (!HasPointerEvalType(E))
     return false;
   Result = PointerExprEvaluator(Info).Visit(const_cast<Expr*>(E));
   return Result.isLValue();
@@ -1519,8 +1525,7 @@ bool Expr::Evaluate(EvalResult &Result, ASTContext &Ctx) const {
   } else if (getType()->isIntegerType()) {
     if (!IntExprEvaluator(Info, Result.Val).Visit(const_cast<Expr*>(this)))
       return false;
-  } else if (getType()->isPointerType()
-             || getType()->isBlockPointerType()) {
+  } else if (HasPointerEvalType(this)) {
     if (!EvaluatePointer(this, Result.Val, Info))
       return false;
   } else if (getType()->isRealFloatingType()) {