aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/AST/Type.h4
-rw-r--r--include/clang/Analysis/PathSensitive/SVals.h3
-rw-r--r--lib/AST/ASTContext.cpp2
-rw-r--r--lib/Analysis/CheckObjCInstMethSignature.cpp3
-rw-r--r--lib/CodeGen/CGExprScalar.cpp2
-rw-r--r--lib/Sema/SemaExpr.cpp31
-rw-r--r--lib/Sema/SemaExprCXX.cpp3
7 files changed, 18 insertions, 30 deletions
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index d3f7b5be01..7ddf90bcab 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -375,6 +375,7 @@ public:
bool isFunctionNoProtoType() const { return getAsFunctionNoProtoType() != 0; }
bool isFunctionProtoType() const { return getAsFunctionProtoType() != 0; }
bool isPointerType() const;
+ bool isAnyPointerType() const; // Any C pointer or ObjC object pointer
bool isBlockPointerType() const;
bool isVoidPointerType() const;
bool isReferenceType() const;
@@ -2120,6 +2121,9 @@ inline bool Type::isFunctionType() const {
inline bool Type::isPointerType() const {
return isa<PointerType>(CanonicalType.getUnqualifiedType());
}
+inline bool Type::isAnyPointerType() const {
+ return isPointerType() || isObjCObjectPointerType();
+}
inline bool Type::isBlockPointerType() const {
return isa<BlockPointerType>(CanonicalType.getUnqualifiedType());
}
diff --git a/include/clang/Analysis/PathSensitive/SVals.h b/include/clang/Analysis/PathSensitive/SVals.h
index 0a42548200..2ba370e532 100644
--- a/include/clang/Analysis/PathSensitive/SVals.h
+++ b/include/clang/Analysis/PathSensitive/SVals.h
@@ -200,8 +200,7 @@ public:
}
static inline bool IsLocType(QualType T) {
- return T->isPointerType() || T->isObjCObjectPointerType()
- || T->isBlockPointerType();
+ return T->isAnyPointerType() || T->isBlockPointerType();
}
};
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index 971f2da0c0..13f35dc3a0 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -1088,7 +1088,7 @@ QualType ASTContext::getObjCGCQualType(QualType T,
if (T->isPointerType()) {
QualType Pointee = T->getAsPointerType()->getPointeeType();
- if (Pointee->isPointerType() || Pointee->isObjCObjectPointerType()) {
+ if (Pointee->isAnyPointerType()) {
QualType ResultType = getObjCGCQualType(Pointee, GCAttr);
return getPointerType(ResultType);
}
diff --git a/lib/Analysis/CheckObjCInstMethSignature.cpp b/lib/Analysis/CheckObjCInstMethSignature.cpp
index c4e586d2e4..c208a7c323 100644
--- a/lib/Analysis/CheckObjCInstMethSignature.cpp
+++ b/lib/Analysis/CheckObjCInstMethSignature.cpp
@@ -30,8 +30,7 @@ static bool AreTypesCompatible(QualType Derived, QualType Ancestor,
// Right now don't compare the compatibility of pointers. That involves
// looking at subtyping relationships. FIXME: Future patch.
- if ((Derived->isPointerType() || Derived->isObjCObjectPointerType()) &&
- (Ancestor->isPointerType() || Ancestor->isObjCObjectPointerType()))
+ if (Derived->isAnyPointerType() && Ancestor->isAnyPointerType())
return true;
return C.typesAreCompatible(Derived, Ancestor);
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index 17d2c13ff3..14c4ac64f0 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -986,7 +986,7 @@ Value *ScalarExprEmitter::EmitOverflowCheckedBinOp(const BinOpInfo &Ops) {
}
Value *ScalarExprEmitter::EmitAdd(const BinOpInfo &Ops) {
- if (!Ops.Ty->isPointerType() && !Ops.Ty->isObjCObjectPointerType()) {
+ if (!Ops.Ty->isAnyPointerType()) {
if (CGF.getContext().getLangOptions().OverflowChecking &&
Ops.Ty->isSignedIntegerType())
return EmitOverflowCheckedBinOp(Ops);
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) {
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index ac3afa8b75..144dc5095f 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -1482,8 +1482,7 @@ QualType Sema::CXXCheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS,
QualType Sema::FindCompositePointerType(Expr *&E1, Expr *&E2) {
assert(getLangOptions().CPlusPlus && "This function assumes C++");
QualType T1 = E1->getType(), T2 = E2->getType();
- if(!T1->isPointerType() && !T2->isPointerType() &&
- !T1->isObjCObjectPointerType() && !T2->isObjCObjectPointerType())
+ if(!T1->isAnyPointerType() && !T2->isAnyPointerType())
return QualType();
// C++0x 5.9p2