aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/clang/AST/ExprCXX.h2
-rw-r--r--include/clang/AST/Type.h29
-rw-r--r--include/clang/Analysis/PathSensitive/MemRegion.h2
-rw-r--r--lib/AST/ASTContext.cpp20
-rw-r--r--lib/AST/DeclPrinter.cpp2
-rw-r--r--lib/AST/Expr.cpp10
-rw-r--r--lib/AST/ExprConstant.cpp6
-rw-r--r--lib/AST/Type.cpp44
-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
-rw-r--r--lib/CodeGen/CGBlocks.cpp2
-rw-r--r--lib/CodeGen/CGExpr.cpp6
-rw-r--r--lib/CodeGen/CGExprScalar.cpp10
-rw-r--r--lib/CodeGen/CGObjCMac.cpp2
-rw-r--r--lib/CodeGen/CodeGenFunction.cpp2
-rw-r--r--lib/Frontend/RewriteBlocks.cpp14
-rw-r--r--lib/Frontend/RewriteObjC.cpp32
-rw-r--r--lib/Sema/SemaChecking.cpp8
-rw-r--r--lib/Sema/SemaDeclAttr.cpp18
-rw-r--r--lib/Sema/SemaDeclCXX.cpp6
-rw-r--r--lib/Sema/SemaExpr.cpp80
-rw-r--r--lib/Sema/SemaExprCXX.cpp12
-rw-r--r--lib/Sema/SemaExprObjC.cpp2
-rw-r--r--lib/Sema/SemaLookup.cpp2
-rw-r--r--lib/Sema/SemaNamedCast.cpp12
-rw-r--r--lib/Sema/SemaOverload.cpp56
-rw-r--r--lib/Sema/SemaStmt.cpp4
-rw-r--r--lib/Sema/SemaTemplate.cpp8
-rw-r--r--lib/Sema/SemaTemplateDeduction.cpp4
-rw-r--r--lib/Sema/SemaType.cpp14
34 files changed, 214 insertions, 229 deletions
diff --git a/include/clang/AST/ExprCXX.h b/include/clang/AST/ExprCXX.h
index 1767866017..ccfab7418a 100644
--- a/include/clang/AST/ExprCXX.h
+++ b/include/clang/AST/ExprCXX.h
@@ -711,7 +711,7 @@ public:
QualType getAllocatedType() const {
assert(getType()->isPointerType());
- return getType()->getAsPointerType()->getPointeeType();
+ return getType()->getAs<PointerType>()->getPointeeType();
}
FunctionDecl *getOperatorNew() const { return OperatorNew; }
diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h
index 33770f4f1a..3dee933fcf 100644
--- a/include/clang/AST/Type.h
+++ b/include/clang/AST/Type.h
@@ -431,8 +431,6 @@ public:
const FunctionType *getAsFunctionType() const;
const FunctionNoProtoType *getAsFunctionNoProtoType() const;
const FunctionProtoType *getAsFunctionProtoType() const;
- const PointerType *getAsPointerType() const;
- const BlockPointerType *getAsBlockPointerType() const;
const ReferenceType *getAsReferenceType() const;
const LValueReferenceType *getAsLValueReferenceType() const;
const RValueReferenceType *getAsRValueReferenceType() const;
@@ -457,6 +455,10 @@ public:
const ObjCQualifiedInterfaceType *getAsObjCQualifiedInterfaceType() const;
const TemplateTypeParmType *getAsTemplateTypeParmType() const;
+ // Member-template getAs<specific type>'. This scheme will eventually
+ // replace the specific getAsXXXX methods above.
+ template <typename T> const T *getAs() const;
+
const TemplateSpecializationType *
getAsTemplateSpecializationType() const;
@@ -2113,7 +2115,7 @@ inline const TypedefType* Type::getAsTypedefType() const {
return dyn_cast<TypedefType>(this);
}
inline const ObjCInterfaceType *Type::getAsPointerToObjCInterfaceType() const {
- if (const PointerType *PT = getAsPointerType())
+ if (const PointerType *PT = getAs<PointerType>())
return PT->getPointeeType()->getAsObjCInterfaceType();
return 0;
}
@@ -2142,7 +2144,7 @@ inline bool Type::isRValueReferenceType() const {
return isa<RValueReferenceType>(CanonicalType.getUnqualifiedType());
}
inline bool Type::isFunctionPointerType() const {
- if (const PointerType* T = getAsPointerType())
+ if (const PointerType* T = getAs<PointerType>())
return T->getPointeeType()->isFunctionType();
else
return false;
@@ -2247,6 +2249,25 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
Diagnostic::ak_qualtype);
return DB;
}
+
+/// Member-template getAs<specific type>'.
+template <typename T> const T *Type::getAs() const {
+ // If this is directly a T type, return it.
+ if (const T *Ty = dyn_cast<T>(this))
+ return Ty;
+
+ // If the canonical form of this type isn't the right kind, reject it.
+ if (!isa<T>(CanonicalType)) {
+ // Look through type qualifiers
+ if (isa<T>(CanonicalType.getUnqualifiedType()))
+ return CanonicalType.getUnqualifiedType()->getAs<T>();
+ return 0;
+ }
+
+ // If this is a typedef for a pointer type, strip the typedef off without
+ // losing all typedef information.
+ return cast<T>(getDesugaredType());
+}
} // end namespace clang
diff --git a/include/clang/Analysis/PathSensitive/MemRegion.h b/include/clang/Analysis/PathSensitive/MemRegion.h
index 7f8c5c2903..46d0113422 100644
--- a/include/clang/Analysis/PathSensitive/MemRegion.h
+++ b/include/clang/Analysis/PathSensitive/MemRegion.h
@@ -357,7 +357,7 @@ public:
}
QualType getValueType(ASTContext&) const {
- const PointerType* PTy = LValueType->getAsPointerType();
+ const PointerType* PTy = LValueType->getAs<PointerType>();
assert(PTy);
return PTy->getPointeeType();
}
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index b43aadb62e..f30927c4ec 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -1092,7 +1092,7 @@ QualType ASTContext::getObjCGCQualType(QualType T,
return T;
if (T->isPointerType()) {
- QualType Pointee = T->getAsPointerType()->getPointeeType();
+ QualType Pointee = T->getAs<PointerType>()->getPointeeType();
if (Pointee->isAnyPointerType()) {
QualType ResultType = getObjCGCQualType(Pointee, GCAttr);
return getPointerType(ResultType);
@@ -2779,7 +2779,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
return;
}
- if (const PointerType *PT = T->getAsPointerType()) {
+ if (const PointerType *PT = T->getAs<PointerType>()) {
QualType PointeeTy = PT->getPointeeType();
bool isReadOnly = false;
// For historical/compatibility reasons, the read-only qualifier of the
@@ -2794,8 +2794,8 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S,
}
else if (OutermostType) {
QualType P = PointeeTy;
- while (P->getAsPointerType())
- P = P->getAsPointerType()->getPointeeType();
+ while (P->getAs<PointerType>())
+ P = P->getAs<PointerType>()->getPointeeType();
if (P.isConstQualified()) {
isReadOnly = true;
S += 'r';
@@ -3035,7 +3035,7 @@ void ASTContext::setObjCSelType(QualType T) {
TypedefDecl *TD = TT->getDecl();
// typedef struct objc_selector *SEL;
- const PointerType *ptr = TD->getUnderlyingType()->getAsPointerType();
+ const PointerType *ptr = TD->getUnderlyingType()->getAs<PointerType>();
if (!ptr)
return;
const RecordType *rec = ptr->getPointeeType()->getAsStructureType();
@@ -3159,7 +3159,7 @@ QualType::GCAttrTypes ASTContext::getObjCGCAttrKind(const QualType &Ty) const {
if (Ty->isObjCObjectPointerType())
GCAttrs = QualType::Strong;
else if (Ty->isPointerType())
- return getObjCGCAttrKind(Ty->getAsPointerType()->getPointeeType());
+ return getObjCGCAttrKind(Ty->getAs<PointerType>()->getPointeeType());
}
// Non-pointers have none gc'able attribute regardless of the attribute
// set on them.
@@ -3519,8 +3519,8 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
case Type::Pointer:
{
// Merge two pointer types, while trying to preserve typedef info
- QualType LHSPointee = LHS->getAsPointerType()->getPointeeType();
- QualType RHSPointee = RHS->getAsPointerType()->getPointeeType();
+ QualType LHSPointee = LHS->getAs<PointerType>()->getPointeeType();
+ QualType RHSPointee = RHS->getAs<PointerType>()->getPointeeType();
QualType ResultType = mergeTypes(LHSPointee, RHSPointee);
if (ResultType.isNull()) return QualType();
if (getCanonicalType(LHSPointee) == getCanonicalType(ResultType))
@@ -3532,8 +3532,8 @@ QualType ASTContext::mergeTypes(QualType LHS, QualType RHS) {
case Type::BlockPointer:
{
// Merge two block pointer types, while trying to preserve typedef info
- QualType LHSPointee = LHS->getAsBlockPointerType()->getPointeeType();
- QualType RHSPointee = RHS->getAsBlockPointerType()->getPointeeType();
+ QualType LHSPointee = LHS->getAs<BlockPointerType>()->getPointeeType();
+ QualType RHSPointee = RHS->getAs<BlockPointerType>()->getPointeeType();
QualType ResultType = mergeTypes(LHSPointee, RHSPointee);
if (ResultType.isNull()) return QualType();
if (getCanonicalType(LHSPointee) == getCanonicalType(ResultType))
diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp
index 84ae72977e..55d39e5cc8 100644
--- a/lib/AST/DeclPrinter.cpp
+++ b/lib/AST/DeclPrinter.cpp
@@ -90,7 +90,7 @@ static QualType GetBaseType(QualType T) {
while (!BaseType->isSpecifierType()) {
if (isa<TypedefType>(BaseType))
break;
- else if (const PointerType* PTy = BaseType->getAsPointerType())
+ else if (const PointerType* PTy = BaseType->getAs<PointerType>())
BaseType = PTy->getPointeeType();
else if (const ArrayType* ATy = dyn_cast<ArrayType>(BaseType))
BaseType = ATy->getElementType();
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*
diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp
index 2c29347c51..9473e4f48c 100644
--- a/lib/AST/ExprConstant.cpp
+++ b/lib/AST/ExprConstant.cpp
@@ -222,7 +222,7 @@ APValue LValueExprEvaluator::VisitMemberExpr(MemberExpr *E) {
if (E->isArrow()) {
if (!EvaluatePointer(E->getBase(), result, Info))
return APValue();
- Ty = E->getBase()->getType()->getAsPointerType()->getPointeeType();
+ Ty = E->getBase()->getType()->getAs<PointerType>()->getPointeeType();
} else {
result = Visit(E->getBase());
if (result.isUninit())
@@ -351,7 +351,7 @@ APValue PointerExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
if (!EvaluateInteger(IExp, AdditionalOffset, Info))
return APValue();
- QualType PointeeType = PExp->getType()->getAsPointerType()->getPointeeType();
+ QualType PointeeType = PExp->getType()->getAs<PointerType>()->getPointeeType();
uint64_t SizeOfPointee;
// Explicitly handle GNU void* and function pointer arithmetic extensions.
@@ -1029,7 +1029,7 @@ bool IntExprEvaluator::VisitBinaryOperator(const BinaryOperator *E) {
if (E->getOpcode() == BinaryOperator::Sub) {
const QualType Type = E->getLHS()->getType();
- const QualType ElementType = Type->getAsPointerType()->getPointeeType();
+ const QualType ElementType = Type->getAs<PointerType>()->getPointeeType();
uint64_t D = LHSValue.getLValueOffset() - RHSValue.getLValueOffset();
if (!ElementType->isVoidType() && !ElementType->isFunctionType())
diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp
index 18fa76bf25..13d0cb03e8 100644
--- a/lib/AST/Type.cpp
+++ b/lib/AST/Type.cpp
@@ -202,7 +202,7 @@ bool Type::isStructureType() const {
return false;
}
bool Type::isVoidPointerType() const {
- if (const PointerType *PT = getAsPointerType())
+ if (const PointerType *PT = getAs<PointerType>())
return PT->getPointeeType()->isVoidType();
return false;
}
@@ -296,51 +296,15 @@ const FunctionProtoType *Type::getAsFunctionProtoType() const {
}
QualType Type::getPointeeType() const {
- if (const PointerType *PT = getAsPointerType())
+ if (const PointerType *PT = getAs<PointerType>())
return PT->getPointeeType();
if (const ObjCObjectPointerType *OPT = getAsObjCObjectPointerType())
return OPT->getPointeeType();
- if (const BlockPointerType *BPT = getAsBlockPointerType())
+ if (const BlockPointerType *BPT = getAs<BlockPointerType>())
return BPT->getPointeeType();
return QualType();
}
-const PointerType *Type::getAsPointerType() const {
- // If this is directly a pointer type, return it.
- if (const PointerType *PTy = dyn_cast<PointerType>(this))
- return PTy;
-
- // If the canonical form of this type isn't the right kind, reject it.
- if (!isa<PointerType>(CanonicalType)) {
- // Look through type qualifiers
- if (isa<PointerType>(CanonicalType.getUnqualifiedType()))
- return CanonicalType.getUnqualifiedType()->getAsPointerType();
- return 0;
- }
-
- // If this is a typedef for a pointer type, strip the typedef off without
- // losing all typedef information.
- return cast<PointerType>(getDesugaredType());
-}
-
-const BlockPointerType *Type::getAsBlockPointerType() const {
- // If this is directly a block pointer type, return it.
- if (const BlockPointerType *PTy = dyn_cast<BlockPointerType>(this))
- return PTy;
-
- // If the canonical form of this type isn't the right kind, reject it.
- if (!isa<BlockPointerType>(CanonicalType)) {
- // Look through type qualifiers
- if (isa<BlockPointerType>(CanonicalType.getUnqualifiedType()))
- return CanonicalType.getUnqualifiedType()->getAsBlockPointerType();
- return 0;
- }
-
- // If this is a typedef for a block pointer type, strip the typedef off
- // without losing all typedef information.
- return cast<BlockPointerType>(getDesugaredType());
-}
-
const ReferenceType *Type::getAsReferenceType() const {
// If this is directly a reference type, return it.
if (const ReferenceType *RTy = dyn_cast<ReferenceType>(this))
@@ -429,7 +393,7 @@ bool Type::isVariablyModifiedType() const {
// Also, C++ references and member pointers can point to a variably modified
// type, where VLAs appear as an extension to C++, and should be treated
// correctly.
- if (const PointerType *PT = getAsPointerType())
+ if (const PointerType *PT = getAs<PointerType>())
return PT->getPointeeType()->isVariablyModifiedType();
if (const ReferenceType *RT = getAsReferenceType())
return RT->getPointeeType()->isVariablyModifiedType();
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.
diff --git a/lib/CodeGen/CGBlocks.cpp b/lib/CodeGen/CGBlocks.cpp
index 73200fe2ca..d8d1259587 100644
--- a/lib/CodeGen/CGBlocks.cpp
+++ b/lib/CodeGen/CGBlocks.cpp
@@ -388,7 +388,7 @@ const llvm::Type *BlockModule::getGenericExtendedBlockLiteralType() {
RValue CodeGenFunction::EmitBlockCallExpr(const CallExpr* E) {
const BlockPointerType *BPT =
- E->getCallee()->getType()->getAsBlockPointerType();
+ E->getCallee()->getType()->getAs<BlockPointerType>();
llvm::Value *Callee = EmitScalarExpr(E->getCallee());
diff --git a/lib/CodeGen/CGExpr.cpp b/lib/CodeGen/CGExpr.cpp
index 346b6703d3..ab7b70e793 100644
--- a/lib/CodeGen/CGExpr.cpp
+++ b/lib/CodeGen/CGExpr.cpp
@@ -934,7 +934,7 @@ EmitExtVectorElementExpr(const ExtVectorElementExpr *E) {
assert(E->getBase()->getType()->isVectorType());
Base = EmitLValue(E->getBase());
} else {
- const PointerType *PT = E->getBase()->getType()->getAsPointerType();
+ const PointerType *PT = E->getBase()->getType()->getAs<PointerType>();
llvm::Value *Ptr = EmitScalarExpr(E->getBase());
Base = LValue::MakeAddr(Ptr, PT->getPointeeType().getCVRQualifiers());
}
@@ -976,7 +976,7 @@ LValue CodeGenFunction::EmitMemberExpr(const MemberExpr *E) {
if (E->isArrow()) {
BaseValue = EmitScalarExpr(BaseExpr);
const PointerType *PTy =
- BaseExpr->getType()->getAsPointerType();
+ BaseExpr->getType()->getAs<PointerType>();
if (PTy->getPointeeType()->isUnionType())
isUnion = true;
CVRQualifiers = PTy->getPointeeType().getCVRQualifiers();
@@ -1317,7 +1317,7 @@ RValue CodeGenFunction::EmitCall(llvm::Value *Callee, QualType CalleeType,
assert(CalleeType->isFunctionPointerType() &&
"Call must have function pointer type!");
- QualType FnType = CalleeType->getAsPointerType()->getPointeeType();
+ QualType FnType = CalleeType->getAs<PointerType>()->getPointeeType();
QualType ResultType = FnType->getAsFunctionType()->getResultType();
CallArgList Args;
diff --git a/lib/CodeGen/CGExprScalar.cpp b/lib/CodeGen/CGExprScalar.cpp
index e18e08b5c5..0316116631 100644
--- a/lib/CodeGen/CGExprScalar.cpp
+++ b/lib/CodeGen/CGExprScalar.cpp
@@ -679,7 +679,7 @@ Value *ScalarExprEmitter::VisitPrePostIncDec(const UnaryOperator *E,
int AmountVal = isInc ? 1 : -1;
if (ValTy->isPointerType() &&
- ValTy->getAsPointerType()->isVariableArrayType()) {
+ ValTy->getAs<PointerType>()->isVariableArrayType()) {
// The amount of the addition/subtraction needs to account for the VLA size
CGF.ErrorUnsupported(E, "VLA pointer inc/dec");
}
@@ -1002,13 +1002,13 @@ Value *ScalarExprEmitter::EmitAdd(const BinOpInfo &Ops) {
}
if (Ops.Ty->isPointerType() &&
- Ops.Ty->getAsPointerType()->isVariableArrayType()) {
+ Ops.Ty->getAs<PointerType>()->isVariableArrayType()) {
// The amount of the addition needs to account for the VLA size
CGF.ErrorUnsupported(Ops.E, "VLA pointer addition");
}
Value *Ptr, *Idx;
Expr *IdxExp;
- const PointerType *PT = Ops.E->getLHS()->getType()->getAsPointerType();
+ const PointerType *PT = Ops.E->getLHS()->getType()->getAs<PointerType>();
const ObjCObjectPointerType *OPT =
Ops.E->getLHS()->getType()->getAsObjCObjectPointerType();
if (PT || OPT) {
@@ -1016,7 +1016,7 @@ Value *ScalarExprEmitter::EmitAdd(const BinOpInfo &Ops) {
Idx = Ops.RHS;
IdxExp = Ops.E->getRHS();
} else { // int + pointer
- PT = Ops.E->getRHS()->getType()->getAsPointerType();
+ PT = Ops.E->getRHS()->getType()->getAs<PointerType>();
OPT = Ops.E->getRHS()->getType()->getAsObjCObjectPointerType();
assert((PT || OPT) && "Invalid add expr");
Ptr = Ops.RHS;
@@ -1073,7 +1073,7 @@ Value *ScalarExprEmitter::EmitSub(const BinOpInfo &Ops) {
}