diff options
author | Ted Kremenek <kremenek@apple.com> | 2009-07-16 19:58:26 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2009-07-16 19:58:26 +0000 |
commit | 1a1a6e2bd4c5aefd7fd643cf25915f9623a02e59 (patch) | |
tree | 333652f464e28debc770fc4b30bc5b8f74254d28 /lib/AST/Expr.cpp | |
parent | e41611aa2237d06a0ef61db4528fb2883a8defcd (diff) |
Add member template 'Type::getAs<T>', which converts a Type* to a respective T*.
This method is intended to eventually replace the individual
Type::getAsXXXType<> methods.
The motivation behind this change is twofold:
1) Reduce redundant implementations of Type::getAsXXXType() methods. Most of
them are basically copy-and-paste.
2) By centralizing the implementation of the getAs<Type> logic we can more
smoothly move over to Doug Gregor's proposed canonical type smart pointer
scheme.
Along with this patch:
a) Removed 'Type::getAsPointerType()'; now clients use getAs<PointerType>.
b) Removed 'Type::getAsBlockPointerTypE()'; now clients use getAs<BlockPointerType>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76098 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Expr.cpp')
-rw-r--r-- | lib/AST/Expr.cpp | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 5d22f38770..74928bcd76 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -279,9 +279,9 @@ unsigned CallExpr::isBuiltinCall(ASTContext &Context) const { QualType CallExpr::getCallReturnType() const { QualType CalleeType = getCallee()->getType(); - if (const PointerType *FnTypePtr = CalleeType->getAsPointerType()) + if (const PointerType *FnTypePtr = CalleeType->getAs<PointerType>()) CalleeType = FnTypePtr->getPointeeType(); - else if (const BlockPointerType *BPT = CalleeType->getAsBlockPointerType()) + else if (const BlockPointerType *BPT = CalleeType->getAs<BlockPointerType>()) CalleeType = BPT->getPointeeType(); const FunctionType *FnType = CalleeType->getAsFunctionType(); @@ -430,7 +430,7 @@ Expr *InitListExpr::updateInit(unsigned Init, Expr *expr) { /// getFunctionType - Return the underlying function type for this block. /// const FunctionType *BlockExpr::getFunctionType() const { - return getType()->getAsBlockPointerType()-> + return getType()->getAs<BlockPointerType>()-> getPointeeType()->getAsFunctionType(); } @@ -991,7 +991,7 @@ bool Expr::isOBJCGCCandidate(ASTContext &Ctx) const { QualType T = VD->getType(); // dereferencing to an object pointer is always a gc'able candidate if (T->isPointerType() && - T->getAsPointerType()->getPointeeType()->isObjCObjectPointerType()) + T->getAs<PointerType>()->getPointeeType()->isObjCObjectPointerType()) return true; } @@ -1419,7 +1419,7 @@ bool Expr::isNullPointerConstant(ASTContext &Ctx) const if (const ExplicitCastExpr *CE = dyn_cast<ExplicitCastExpr>(this)) { if (!Ctx.getLangOptions().CPlusPlus) { // Check that it is a cast to void*. - if (const PointerType *PT = CE->getType()->getAsPointerType()) { + if (const PointerType *PT = CE->getType()->getAs<PointerType>()) { QualType Pointee = PT->getPointeeType(); if (Pointee.getCVRQualifiers() == 0 && Pointee->isVoidType() && // to void* |