Change uses of:
Type::getAsReferenceType() -> Type::getAs<ReferenceType>()
Type::getAsRecordType() -> Type::getAs<RecordType>()
Type::getAsPointerType() -> Type::getAs<PointerType>()
Type::getAsBlockPointerType() -> Type::getAs<BlockPointerType>()
Type::getAsLValueReferenceType() -> Type::getAs<LValueReferenceType>()
Type::getAsRValueReferenceType() -> Type::getAs<RValueReferenceType>()
Type::getAsMemberPointerType() -> Type::getAs<MemberPointerType>()
Type::getAsReferenceType() -> Type::getAs<ReferenceType>()
Type::getAsTagType() -> Type::getAs<TagType>()
And remove Type::getAsReferenceType(), etc.
This change is similar to one I made a couple weeks ago, but that was partly
reverted pending some additional design discussion. With Doug's pending smart
pointer changes for Types, it seemed natural to take this approach.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@77510 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index d3daa07..1bb516e 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -305,8 +305,8 @@
if (TypeQuals & QualType::Restrict) {
if (Result->isPointerType() || Result->isReferenceType()) {
QualType EltTy = Result->isPointerType() ?
- Result->getAsPointerType()->getPointeeType() :
- Result->getAsReferenceType()->getPointeeType();
+ Result->getAs<PointerType>()->getPointeeType() :
+ Result->getAs<ReferenceType>()->getPointeeType();
// If we have a pointer or reference, the pointee must have an object
// incomplete type.
@@ -419,7 +419,7 @@
QualType Sema::BuildReferenceType(QualType T, bool LValueRef, unsigned Quals,
SourceLocation Loc, DeclarationName Entity) {
if (LValueRef) {
- if (const RValueReferenceType *R = T->getAsRValueReferenceType()) {
+ if (const RValueReferenceType *R = T->getAs<RValueReferenceType>()) {
// C++0x [dcl.typedef]p9: If a typedef TD names a type that is a
// reference to a type T, and attempt to create the type "lvalue
// reference to cv TD" creates the type "lvalue reference to T".
@@ -529,7 +529,7 @@
return QualType();
}
- if (const RecordType *EltTy = T->getAsRecordType()) {
+ if (const RecordType *EltTy = T->getAs<RecordType>()) {
// If the element type is a struct or union that contains a variadic
// array, accept it as a GNU extension: C99 6.7.2.1p2.
if (EltTy->getDecl()->hasFlexibleArrayMember())
@@ -1191,10 +1191,10 @@
// an incomplete type a pointer or reference to an incomplete type, other
// than (cv) void*.
int kind;
- if (const PointerType* IT = T->getAsPointerType()) {
+ if (const PointerType* IT = T->getAs<PointerType>()) {
T = IT->getPointeeType();
kind = 1;
- } else if (const ReferenceType* IT = T->getAsReferenceType()) {
+ } else if (const ReferenceType* IT = T->getAs<ReferenceType>()) {
T = IT->getPointeeType();
kind = 2;
} else
@@ -1211,9 +1211,9 @@
/// to member to a function with an exception specification. This means that
/// it is invalid to add another level of indirection.
bool Sema::CheckDistantExceptionSpec(QualType T) {
- if (const PointerType *PT = T->getAsPointerType())
+ if (const PointerType *PT = T->getAs<PointerType>())
T = PT->getPointeeType();
- else if (const MemberPointerType *PT = T->getAsMemberPointerType())
+ else if (const MemberPointerType *PT = T->getAs<MemberPointerType>())
T = PT->getPointeeType();
else
return false;
@@ -1291,9 +1291,9 @@
// Take one type from the subset.
QualType CanonicalSubT = Context.getCanonicalType(*SubI);
bool SubIsPointer = false;
- if (const ReferenceType *RefTy = CanonicalSubT->getAsReferenceType())
+ if (const ReferenceType *RefTy = CanonicalSubT->getAs<ReferenceType>())
CanonicalSubT = RefTy->getPointeeType();
- if (const PointerType *PtrTy = CanonicalSubT->getAsPointerType()) {
+ if (const PointerType *PtrTy = CanonicalSubT->getAs<PointerType>()) {
CanonicalSubT = PtrTy->getPointeeType();
SubIsPointer = true;
}
@@ -1311,10 +1311,10 @@
QualType CanonicalSuperT = Context.getCanonicalType(*SuperI);
// SubT must be SuperT or derived from it, or pointer or reference to
// such types.
- if (const ReferenceType *RefTy = CanonicalSuperT->getAsReferenceType())
+ if (const ReferenceType *RefTy = CanonicalSuperT->getAs<ReferenceType>())
CanonicalSuperT = RefTy->getPointeeType();
if (SubIsPointer) {
- if (const PointerType *PtrTy = CanonicalSuperT->getAsPointerType())
+ if (const PointerType *PtrTy = CanonicalSuperT->getAs<PointerType>())
CanonicalSuperT = PtrTy->getPointeeType();
else {
continue;
@@ -1391,16 +1391,16 @@
/// be called in a loop that successively "unwraps" pointer and
/// pointer-to-member types to compare them at each level.
bool Sema::UnwrapSimilarPointerTypes(QualType& T1, QualType& T2) {
- const PointerType *T1PtrType = T1->getAsPointerType(),
- *T2PtrType = T2->getAsPointerType();
+ const PointerType *T1PtrType = T1->getAs<PointerType>(),
+ *T2PtrType = T2->getAs<PointerType>();
if (T1PtrType && T2PtrType) {
T1 = T1PtrType->getPointeeType();
T2 = T2PtrType->getPointeeType();
return true;
}
- const MemberPointerType *T1MPType = T1->getAsMemberPointerType(),
- *T2MPType = T2->getAsMemberPointerType();
+ const MemberPointerType *T1MPType = T1->getAs<MemberPointerType>(),
+ *T2MPType = T2->getAs<MemberPointerType>();
if (T1MPType && T2MPType &&
Context.getCanonicalType(T1MPType->getClass()) ==
Context.getCanonicalType(T2MPType->getClass())) {
@@ -1610,7 +1610,7 @@
// If we have a class template specialization or a class member of a
// class template specialization, try to instantiate it.
- if (const RecordType *Record = T->getAsRecordType()) {
+ if (const RecordType *Record = T->getAs<RecordType>()) {
if (ClassTemplateSpecializationDecl *ClassTemplateSpec
= dyn_cast<ClassTemplateSpecializationDecl>(Record->getDecl())) {
if (ClassTemplateSpec->getSpecializationKind() == TSK_Undeclared) {
@@ -1646,7 +1646,7 @@
// If the type was a forward declaration of a class/struct/union
// type, produce
const TagType *Tag = 0;
- if (const RecordType *Record = T->getAsRecordType())
+ if (const RecordType *Record = T->getAs<RecordType>())
Tag = Record;
else if (const EnumType *Enum = T->getAsEnumType())
Tag = Enum;