summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/ExprConstant.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-02-22 04:02:33 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-02-22 04:02:33 +0000
commitf837924faf983abc205f678f0d4c792a0a6249a8 (patch)
treead2a1d8229e692b7bd3c304faa3e49f4538e4b24 /clang/lib/AST/ExprConstant.cpp
parent3f8c01a11029a0c7122426e93c1f9103c60aead3 (diff)
downloadbcm5719-llvm-f837924faf983abc205f678f0d4c792a0a6249a8.tar.gz
bcm5719-llvm-f837924faf983abc205f678f0d4c792a0a6249a8.zip
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. llvm-svn: 65261
Diffstat (limited to 'clang/lib/AST/ExprConstant.cpp')
-rw-r--r--clang/lib/AST/ExprConstant.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 103bc37f4fe..8f43700e46d 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/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<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()) {
OpenPOWER on IntegriCloud