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/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index 103bc37..8f43700 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -279,9 +279,15 @@
};
} // 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 @@
} 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()) {