]> granicus.if.org Git - clang/commitdiff
Introduce Type::isAnyPointerType() and convert all clients (suggested by Chris).
authorSteve Naroff <snaroff@apple.com>
Tue, 14 Jul 2009 18:25:06 +0000 (18:25 +0000)
committerSteve Naroff <snaroff@apple.com>
Tue, 14 Jul 2009 18:25:06 +0000 (18:25 +0000)
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

include/clang/AST/Type.h
include/clang/Analysis/PathSensitive/SVals.h
lib/AST/ASTContext.cpp
lib/Analysis/CheckObjCInstMethSignature.cpp
lib/CodeGen/CGExprScalar.cpp
lib/Sema/SemaExpr.cpp
lib/Sema/SemaExprCXX.cpp

index d3f7b5be015e0c305e7a7938b2f6fcd1dcaf8beb..7ddf90bcab09803beb374dc5d24c3d039cd5fe88 100644 (file)
@@ -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()); 
 }
index 0a425482009dee66d46d717dcaf8617727ed9f90..2ba370e5322f6bd6e8ada813d153f677807e851b 100644 (file)
@@ -200,8 +200,7 @@ public:
   }
   
   static inline bool IsLocType(QualType T) {
-    return T->isPointerType() || T->isObjCObjectPointerType() 
-      || T->isBlockPointerType();
+    return T->isAnyPointerType() || T->isBlockPointerType();
   }
 };
   
index 971f2da0c05a815ef22b1da2bd6e92a536e44049..13f35dc3a089e794b8b631505e4330779edc93b7 100644 (file)
@@ -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);
     }
index c4e586d2e492bf209939ac06b0e9a030accee1d4..c208a7c323e5127e75931c8e7f1b1df8a2a0a1b1 100644 (file)
@@ -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);
index 17d2c13ff3ad17da907eeec6f56979ece0db97c0..14c4ac64f032fd02ebb2c1c6f26b4b6027480ef7 100644 (file)
@@ -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);
index 3ae9c3590da397b4d2e17996ede8ae522c9a75b8..66d2cdcb387e25f8169e55773069ffa38c043dd1 100644 (file)
@@ -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) {
index ac3afa8b755a5fba0cfb42da26044c5827abf84e..144dc5095f8d63153439d57055bdb5cc77cd933d 100644 (file)
@@ -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