aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/SemaExpr.cpp
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2009-07-14 18:25:06 +0000
committerSteve Naroff <snaroff@apple.com>2009-07-14 18:25:06 +0000
commit58f9f2c884af6b72d036b746a016d8031d31cb7a (patch)
tree89a7b1e5b8e5ba78419af5fb1f023c6e38f66dc0 /lib/Sema/SemaExpr.cpp
parentd01c915dda27bb0045687f0a08bbcab1dd40e652 (diff)
Introduce Type::isAnyPointerType() and convert all clients (suggested by Chris).
I don't love the name, however it simplifies the code and is a worthwhile change. If/when we come up with a better name, we can do a search/replace. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@75650 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaExpr.cpp')
-rw-r--r--lib/Sema/SemaExpr.cpp31
1 files changed, 9 insertions, 22 deletions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index 3ae9c3590d..66d2cdcb38 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -3094,14 +3094,12 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS,
}
// C99 6.5.15p6 - "if one operand is a null pointer constant, the result has
// the type of the other operand."
- if ((LHSTy->isPointerType() || LHSTy->isBlockPointerType() ||
- LHSTy->isObjCObjectPointerType()) &&
+ if ((LHSTy->isAnyPointerType() || LHSTy->isBlockPointerType()) &&
RHS->isNullPointerConstant(Context)) {
ImpCastExprToType(RHS, LHSTy); // promote the null to a pointer.
return LHSTy;
}
- if ((RHSTy->isPointerType() || RHSTy->isBlockPointerType() ||
- RHSTy->isObjCObjectPointerType()) &&
+ if ((RHSTy->isAnyPointerType() || RHSTy->isBlockPointerType()) &&
LHS->isNullPointerConstant(Context)) {
ImpCastExprToType(LHS, RHSTy); // promote the null to a pointer.
return RHSTy;
@@ -3823,12 +3821,10 @@ inline QualType Sema::CheckAdditionOperands( // C99 6.5.6
// Put any potential pointer into PExp
Expr* PExp = lex, *IExp = rex;
- if (IExp->getType()->isPointerType() ||
- IExp->getType()->isObjCObjectPointerType())
+ if (IExp->getType()->isAnyPointerType())
std::swap(PExp, IExp);
- if (PExp->getType()->isPointerType() ||
- PExp->getType()->isObjCObjectPointerType()) {
+ if (PExp->getType()->isAnyPointerType()) {
if (IExp->getType()->isIntegerType()) {
QualType PointeeTy = PExp->getType()->getPointeeType();
@@ -3912,8 +3908,7 @@ QualType Sema::CheckSubtractionOperands(Expr *&lex, Expr *&rex,
}
// Either ptr - int or ptr - ptr.
- if (lex->getType()->isPointerType() ||
- lex->getType()->isObjCObjectPointerType()) {
+ if (lex->getType()->isAnyPointerType()) {
QualType lpointee = lex->getType()->getPointeeType();
// The LHS must be an completely-defined object type.
@@ -4293,8 +4288,7 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc,
return ResultTy;
}
}
- if ((lType->isPointerType() || lType->isObjCObjectPointerType()) &&
- rType->isIntegerType()) {
+ if (lType->isAnyPointerType() && rType->isIntegerType()) {
if (isRelational)
Diag(Loc, diag::ext_typecheck_ordered_comparison_of_pointer_integer)
<< lType << rType << lex->getSourceRange() << rex->getSourceRange();
@@ -4304,8 +4298,7 @@ QualType Sema::CheckCompareOperands(Expr *&lex, Expr *&rex, SourceLocation Loc,
ImpCastExprToType(rex, lType); // promote the integer to pointer
return ResultTy;
}
- if (lType->isIntegerType() &&
- (rType->isPointerType() || rType->isObjCObjectPointerType())) {
+ if (lType->isIntegerType() && rType->isAnyPointerType()) {
if (isRelational)
Diag(Loc, diag::ext_typecheck_ordered_comparison_of_pointer_integer)
<< lType << rType << lex->getSourceRange() << rex->getSourceRange();
@@ -4578,15 +4571,9 @@ QualType Sema::CheckIncrementDecrementOperand(Expr *Op, SourceLocation OpLoc,
Diag(OpLoc, diag::warn_increment_bool) << Op->getSourceRange();
} else if (ResType->isRealType()) {
// OK!
- } else if (ResType->getAsPointerType() ||ResType->isObjCObjectPointerType()) {
- QualType PointeeTy;
+ } else if (ResType->isAnyPointerType()) {
+ QualType PointeeTy = ResType->getPointeeType();
- if (const PointerType *PTy = ResType->getAsPointerType())
- PointeeTy = PTy->getPointeeType();
- else if (const ObjCObjectPointerType *OPT =
- ResType->getAsObjCObjectPointerType())
- PointeeTy = OPT->getPointeeType();
-
// C99 6.5.2.4p2, 6.5.6p2
if (PointeeTy->isVoidType()) {
if (getLangOptions().CPlusPlus) {