aboutsummaryrefslogtreecommitdiff
path: root/lib/Analysis
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-07-16 19:58:26 +0000
committerTed Kremenek <kremenek@apple.com>2009-07-16 19:58:26 +0000
commit1a1a6e2bd4c5aefd7fd643cf25915f9623a02e59 (patch)
tree333652f464e28debc770fc4b30bc5b8f74254d28 /lib/Analysis
parente41611aa2237d06a0ef61db4528fb2883a8defcd (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/Analysis')
-rw-r--r--lib/Analysis/BasicStore.cpp2
-rw-r--r--lib/Analysis/CFRefCount.cpp6
-rw-r--r--lib/Analysis/CheckNSError.cpp4
-rw-r--r--lib/Analysis/GRExprEngine.cpp4
-rw-r--r--lib/Analysis/RegionStore.cpp14
-rw-r--r--lib/Analysis/Store.cpp4
6 files changed, 17 insertions, 17 deletions
diff --git a/lib/Analysis/BasicStore.cpp b/lib/Analysis/BasicStore.cpp
index 7aa63c1c63..99bfac2f50 100644
--- a/lib/Analysis/BasicStore.cpp
+++ b/lib/Analysis/BasicStore.cpp
@@ -251,7 +251,7 @@ SVal BasicStoreManager::getLValueElement(const GRState *state,
static bool isHigherOrderRawPtr(QualType T, ASTContext &C) {
bool foundPointer = false;
while (1) {
- const PointerType *PT = T->getAsPointerType();
+ const PointerType *PT = T->getAs<PointerType>();
if (!PT) {
if (!foundPointer)
return false;
diff --git a/lib/Analysis/CFRefCount.cpp b/lib/Analysis/CFRefCount.cpp
index 3d2e3ac9a8..1fa3e57af0 100644
--- a/lib/Analysis/CFRefCount.cpp
+++ b/lib/Analysis/CFRefCount.cpp
@@ -248,7 +248,7 @@ static bool isRefType(QualType RetTy, const char* prefix,
return false;
// Is the type void*?
- const PointerType* PT = RetTy->getAsPointerType();
+ const PointerType* PT = RetTy->getAs<PointerType>();
if (!(PT->getPointeeType().getUnqualifiedType() == Ctx->VoidTy))
return false;
@@ -1250,7 +1250,7 @@ RetainSummaryManager::updateSummaryFromAnnotations(RetainSummary &Summ,
Summ.setRetEffect(RetEffect::MakeOwned(RetEffect::CF, true));
}
}
- else if (RetTy->getAsPointerType()) {
+ else if (RetTy->getAs<PointerType>()) {
if (FD->getAttr<CFReturnsRetainedAttr>()) {
Summ.setRetEffect(RetEffect::MakeOwned(RetEffect::CF, true));
}
@@ -1276,7 +1276,7 @@ RetainSummaryManager::updateSummaryFromAnnotations(RetainSummary &Summ,
}
if (!isTrackedLoc)
- isTrackedLoc = MD->getResultType()->getAsPointerType() != NULL;
+ isTrackedLoc = MD->getResultType()->getAs<PointerType>() != NULL;
if (isTrackedLoc && MD->getAttr<CFReturnsRetainedAttr>())
Summ.setRetEffect(RetEffect::MakeOwned(RetEffect::CF, true));
diff --git a/lib/Analysis/CheckNSError.cpp b/lib/Analysis/CheckNSError.cpp
index c1382d0377..4e8ba01e3e 100644
--- a/lib/Analysis/CheckNSError.cpp
+++ b/lib/Analysis/CheckNSError.cpp
@@ -161,7 +161,7 @@ NSErrorCheck::CheckSignature(FunctionDecl& F, QualType& ResultTy,
bool NSErrorCheck::CheckNSErrorArgument(QualType ArgTy) {
- const PointerType* PPT = ArgTy->getAsPointerType();
+ const PointerType* PPT = ArgTy->getAs<PointerType>();
if (!PPT)
return false;
@@ -182,7 +182,7 @@ bool NSErrorCheck::CheckNSErrorArgument(QualType ArgTy) {
bool NSErrorCheck::CheckCFErrorArgument(QualType ArgTy) {
- const PointerType* PPT = ArgTy->getAsPointerType();
+ const PointerType* PPT = ArgTy->getAs<PointerType>();
if (!PPT) return false;
const TypedefType* TT = PPT->getPointeeType()->getAsTypedefType();
diff --git a/lib/Analysis/GRExprEngine.cpp b/lib/Analysis/GRExprEngine.cpp
index f83e92acb3..b4bec54877 100644
--- a/lib/Analysis/GRExprEngine.cpp
+++ b/lib/Analysis/GRExprEngine.cpp
@@ -1274,7 +1274,7 @@ static bool EvalOSAtomicCompareAndSwap(ExplodedNodeSet<GRState>& Dst,
return false;
Expr *theValueExpr = CE->getArg(2);
- const PointerType *theValueType = theValueExpr->getType()->getAsPointerType();
+ const PointerType *theValueType = theValueExpr->getType()->getAs<PointerType>();
// theValueType not a pointer?
if (!theValueType)
@@ -1382,7 +1382,7 @@ void GRExprEngine::VisitCall(CallExpr* CE, NodeTy* Pred,
// Determine the type of function we're calling (if available).
const FunctionProtoType *Proto = NULL;
QualType FnType = CE->getCallee()->IgnoreParens()->getType();
- if (const PointerType *FnTypePtr = FnType->getAsPointerType())
+ if (const PointerType *FnTypePtr = FnType->getAs<PointerType>())
Proto = FnTypePtr->getPointeeType()->getAsFunctionProtoType();
VisitCallRec(CE, Pred, AI, AE, Dst, Proto, /*ParamIdx=*/0);
diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp
index 0d2467f55e..31623b9983 100644
--- a/lib/Analysis/RegionStore.cpp
+++ b/lib/Analysis/RegionStore.cpp
@@ -365,7 +365,7 @@ static bool isGenericPtr(ASTContext &Ctx, QualType Ty) {
if (Ty->isVoidType())
return true;
- if (const PointerType *PT = Ty->getAsPointerType()) {
+ if (const PointerType *PT = Ty->getAs<PointerType>()) {
Ty = PT->getPointeeType();
continue;
}
@@ -680,7 +680,7 @@ SVal RegionStoreManager::EvalBinOp(const GRState *state,
T = Sym->getType(getContext());
}
- QualType EleTy = T->getAsPointerType()->getPointeeType();
+ QualType EleTy = T->getAs<PointerType>()->getPointeeType();
SVal ZeroIdx = ValMgr.makeZeroArrayIndex();
ER = MRMgr.getElementRegion(EleTy, ZeroIdx, SR, getContext());
break;
@@ -689,7 +689,7 @@ SVal RegionStoreManager::EvalBinOp(const GRState *state,
// Get the alloca region's current cast type.
const AllocaRegion *AR = cast<AllocaRegion>(MR);
QualType T = *(state->get<RegionCasts>(AR));
- QualType EleTy = T->getAsPointerType()->getPointeeType();
+ QualType EleTy = T->getAs<PointerType>()->getPointeeType();
SVal ZeroIdx = ValMgr.makeZeroArrayIndex();
ER = MRMgr.getElementRegion(EleTy, ZeroIdx, AR, getContext());
break;
@@ -865,7 +865,7 @@ SVal RegionStoreManager::Retrieve(const GRState *state, Loc L, QualType T) {
// symbol value.
if (const QualType *p = state->get<RegionCasts>(R)) {
QualType T = *p;
- RTy = T->getAsPointerType()->getPointeeType();
+ RTy = T->getAs<PointerType>()->getPointeeType();
}
// All other values are symbolic.
@@ -937,7 +937,7 @@ SVal RegionStoreManager::RetrieveElement(const GRState* state,
// If the region is already cast to another type, use that type to create the
// symbol value.
if (const QualType *p = state->get<RegionCasts>(R))
- Ty = (*p)->getAsPointerType()->getPointeeType();
+ Ty = (*p)->getAs<PointerType>()->getPointeeType();
return ValMgr.getRegionValueSymbolValOrUnknown(R, Ty);
}
@@ -976,7 +976,7 @@ SVal RegionStoreManager::RetrieveField(const GRState* state,
// symbol value.
if (const QualType *p = state->get<RegionCasts>(R)) {
QualType tmp = *p;
- Ty = tmp->getAsPointerType()->getPointeeType();
+ Ty = tmp->getAs<PointerType>()->getPointeeType();
}
// All other values are symbolic.
@@ -1009,7 +1009,7 @@ SVal RegionStoreManager::RetrieveObjCIvar(const GRState* state,
// symbol value.
if (const QualType *p = state->get<RegionCasts>(R)) {
QualType tmp = *p;
- Ty = tmp->getAsPointerType()->getPointeeType();
+ Ty = tmp->getAs<PointerType>()->getPointeeType();
}
// All other values are symbolic.
diff --git a/lib/Analysis/Store.cpp b/lib/Analysis/Store.cpp
index b939a0df9c..9147f93eda 100644
--- a/lib/Analysis/Store.cpp
+++ b/lib/Analysis/Store.cpp
@@ -62,7 +62,7 @@ StoreManager::NewCastRegion(const GRState *state, const MemRegion* R,
// Now assume we are casting from pointer to pointer. Other cases should
// already be handled.
- QualType PointeeTy = CastToTy->getAsPointerType()->getPointeeType();
+ QualType PointeeTy = CastToTy->getAs<PointerType>()->getPointeeType();
// Process region cast according to the kind of the region being cast.
switch (R->getKind()) {
@@ -243,7 +243,7 @@ const GRState *StoreManager::InvalidateRegion(const GRState *state,
// If the region is cast to another type, use that type.
if (const QualType *CastTy = getCastType(state, R)) {
assert(!(*CastTy)->isObjCObjectPointerType());
- QualType NewT = (*CastTy)->getAsPointerType()->getPointeeType();
+ QualType NewT = (*CastTy)->getAs<PointerType>()->getPointeeType();
// The only exception is if the original region had a location type as its
// value type we always want to treat the region as binding to a location.