Add Type::hasPointerRepresentation predicate.
- For types whose native representation is a pointer.
- Use to replace ExprConstant.cpp:HasPointerEvalType,
CodeGenFunction::isObjCPointerType.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@65569 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index 6899b61..5cfc6e6 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -279,14 +279,8 @@
};
} // end anonymous namespace
-static bool HasPointerEvalType(const Expr* E) {
- return E->getType()->isPointerType()
- || E->getType()->isBlockPointerType()
- || E->getType()->isObjCQualifiedIdType();
-}
-
static bool EvaluatePointer(const Expr* E, APValue& Result, EvalInfo &Info) {
- if (!HasPointerEvalType(E))
+ if (!E->getType()->hasPointerRepresentation())
return false;
Result = PointerExprEvaluator(Info).Visit(const_cast<Expr*>(E));
return Result.isLValue();
@@ -1570,7 +1564,7 @@
} else if (getType()->isIntegerType()) {
if (!IntExprEvaluator(Info, Result.Val).Visit(const_cast<Expr*>(this)))
return false;
- } else if (HasPointerEvalType(this)) {
+ } else if (getType()->hasPointerRepresentation()) {
if (!EvaluatePointer(this, Result.Val, Info))
return false;
} else if (getType()->isRealFloatingType()) {