[cfe-commits] r75650 - in /cfe/trunk: 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
Fariborz Jahanian
fjahanian at apple.com
Tue Jul 14 11:33:40 PDT 2009
Maybe this was discussed before. Sorry for asking again. Why do we
exclude block pointers?
- Fariborz
On Jul 14, 2009, at 11:25 AM, Steve Naroff wrote:
> Author: snaroff
> Date: Tue Jul 14 13:25:06 2009
> New Revision: 75650
>
> URL: http://llvm.org/viewvc/llvm-project?rev=75650&view=rev
> Log:
> 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.
>
> Modified:
> cfe/trunk/include/clang/AST/Type.h
> cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h
> cfe/trunk/lib/AST/ASTContext.cpp
> cfe/trunk/lib/Analysis/CheckObjCInstMethSignature.cpp
> cfe/trunk/lib/CodeGen/CGExprScalar.cpp
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/lib/Sema/SemaExprCXX.cpp
>
> Modified: cfe/trunk/include/clang/AST/Type.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=75650&r1=75649&r2=75650&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/include/clang/AST/Type.h (original)
> +++ cfe/trunk/include/clang/AST/Type.h Tue Jul 14 13:25:06 2009
> @@ -375,6 +375,7 @@
> 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::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());
> }
>
> Modified: cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h?rev=75650&r1=75649&r2=75650&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h (original)
> +++ cfe/trunk/include/clang/Analysis/PathSensitive/SVals.h Tue Jul
> 14 13:25:06 2009
> @@ -200,8 +200,7 @@
> }
>
> static inline bool IsLocType(QualType T) {
> - return T->isPointerType() || T->isObjCObjectPointerType()
> - || T->isBlockPointerType();
> + return T->isAnyPointerType() || T->isBlockPointerType();
> }
> };
>
>
> Modified: cfe/trunk/lib/AST/ASTContext.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=75650&r1=75649&r2=75650&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/lib/AST/ASTContext.cpp (original)
> +++ cfe/trunk/lib/AST/ASTContext.cpp Tue Jul 14 13:25:06 2009
> @@ -1088,7 +1088,7 @@
>
> if (T->isPointerType()) {
> QualType Pointee = T->getAsPointerType()->getPointeeType();
> - if (Pointee->isPointerType() || Pointee-
> >isObjCObjectPointerType()) {
> + if (Pointee->isAnyPointerType()) {
> QualType ResultType = getObjCGCQualType(Pointee, GCAttr);
> return getPointerType(ResultType);
> }
>
> Modified: cfe/trunk/lib/Analysis/CheckObjCInstMethSignature.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/CheckObjCInstMethSignature.cpp?rev=75650&r1=75649&r2=75650&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/lib/Analysis/CheckObjCInstMethSignature.cpp (original)
> +++ cfe/trunk/lib/Analysis/CheckObjCInstMethSignature.cpp Tue Jul 14
> 13:25:06 2009
> @@ -30,8 +30,7 @@
>
> // 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);
>
> Modified: cfe/trunk/lib/CodeGen/CGExprScalar.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprScalar.cpp?rev=75650&r1=75649&r2=75650&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/lib/CodeGen/CGExprScalar.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGExprScalar.cpp Tue Jul 14 13:25:06 2009
> @@ -986,7 +986,7 @@
> }
>
> 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);
>
> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=75650&r1=75649&r2=75650&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Jul 14 13:25:06 2009
> @@ -3094,14 +3094,12 @@
> }
> // 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 @@
>
> // 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 @@
> }
>
> // 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 @@
> 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 @@
> 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 @@
> 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) {
>
> Modified: cfe/trunk/lib/Sema/SemaExprCXX.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprCXX.cpp?rev=75650&r1=75649&r2=75650&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- cfe/trunk/lib/Sema/SemaExprCXX.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExprCXX.cpp Tue Jul 14 13:25:06 2009
> @@ -1482,8 +1482,7 @@
> 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
>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
More information about the cfe-commits
mailing list