From: Eli Friedman Date: Sun, 22 Feb 2009 04:02:33 +0000 (+0000) Subject: Enhance Evaluate to handle ObjC qualified id and class types; as far as X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=4bdf08770e75a068de2430e21a43b381aeb13b95;p=clang Enhance Evaluate to handle ObjC qualified id and class types; as far as 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 --- diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index fce2289574..78f2a8a9ab 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -387,6 +387,7 @@ ASTContext::getTypeInfo(const Type *T) { // alignment requirements: getPointerInfo should take an AddrSpace. return getTypeInfo(QualType(cast(T)->getBaseType(), 0)); case Type::ObjCQualifiedId: + case Type::ObjCQualifiedClass: Width = Target.getPointerWidth(0); Align = Target.getPointerAlign(0); break; diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 103bc37f4f..8f43700e46 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -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(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(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()) {