Replaced Type::getAsLValueReferenceType(), Type::getAsRValueReferenceType(), Type::getAsMemberPointerType(), Type::getAsTagType(), and Type::getAsRecordType() with their Type::getAs<XXX> equivalents.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76139 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Sema/SemaCXXScopeSpec.cpp b/lib/Sema/SemaCXXScopeSpec.cpp
index a14bcd5..ef8a271 100644
--- a/lib/Sema/SemaCXXScopeSpec.cpp
+++ b/lib/Sema/SemaCXXScopeSpec.cpp
@@ -46,7 +46,7 @@
case NestedNameSpecifier::TypeSpec:
case NestedNameSpecifier::TypeSpecWithTemplate: {
- const TagType *Tag = NNS->getAsType()->getAsTagType();
+ const TagType *Tag = NNS->getAsType()->getAs<TagType>();
assert(Tag && "Non-tag type in nested-name-specifier");
return Tag->getDecl();
} break;
@@ -169,7 +169,7 @@
if (TagDecl *Tag = dyn_cast<TagDecl>(DC)) {
// If we're currently defining this type, then lookup into the
// type is okay: don't complain that it isn't complete yet.
- const TagType *TagT = Context.getTypeDeclType(Tag)->getAsTagType();
+ const TagType *TagT = Context.getTypeDeclType(Tag)->getAs<TagType>();
if (TagT->isBeingDefined())
return false;
diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp
index 92afc34..d797c80 100644
--- a/lib/Sema/SemaDecl.cpp
+++ b/lib/Sema/SemaDecl.cpp
@@ -1151,7 +1151,7 @@
IdResolver.AddDecl(*F);
}
} else if (const RecordType *InnerRecordType
- = (*F)->getType()->getAsRecordType()) {
+ = (*F)->getType()->getAs<RecordType>()) {
RecordDecl *InnerRecord = InnerRecordType->getDecl();
if (InnerRecord->isAnonymousStructOrUnion())
Invalid = Invalid ||
@@ -2814,7 +2814,7 @@
if ((!Var->hasExternalStorage() && !Var->isExternC(Context)) &&
InitType->isRecordType() && !InitType->isDependentType()) {
CXXRecordDecl *RD =
- cast<CXXRecordDecl>(InitType->getAsRecordType()->getDecl());
+ cast<CXXRecordDecl>(InitType->getAs<RecordType>()->getDecl());
CXXConstructorDecl *Constructor = 0;
if (!RequireCompleteType(Var->getLocation(), InitType,
diag::err_invalid_incomplete_type_use))
@@ -4237,7 +4237,7 @@
FD->setInvalidDecl();
EnclosingDecl->setInvalidDecl();
continue;
- } else if (const RecordType *FDTTy = FDTy->getAsRecordType()) {
+ } else if (const RecordType *FDTTy = FDTy->getAs<RecordType>()) {
if (FDTTy->getDecl()->hasFlexibleArrayMember()) {
// If this is a member of a union, then entire union becomes "flexible".
if (Record && Record->isUnion()) {
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp
index 5d05b4c..ea28796 100644
--- a/lib/Sema/SemaDeclAttr.cpp
+++ b/lib/Sema/SemaDeclAttr.cpp
@@ -137,7 +137,7 @@
if (!PT)
return false;
- const RecordType *RT = PT->getPointeeType()->getAsRecordType();
+ const RecordType *RT = PT->getPointeeType()->getAs<RecordType>();
if (!RT)
return false;
diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp
index d533e63..fbc8a90 100644
--- a/lib/Sema/SemaDeclCXX.cpp
+++ b/lib/Sema/SemaDeclCXX.cpp
@@ -384,7 +384,7 @@
return 0;
// If the base class is polymorphic, the new one is, too.
- RecordDecl *BaseDecl = BaseType->getAsRecordType()->getDecl();
+ RecordDecl *BaseDecl = BaseType->getAs<RecordType>()->getDecl();
assert(BaseDecl && "Record type has no declaration");
BaseDecl = BaseDecl->getDefinition(Context);
assert(BaseDecl && "Base type is not incomplete, but has no definition");
@@ -833,7 +833,7 @@
for (CXXRecordDecl::base_class_iterator VBase =
ClassDecl->vbases_begin(),
E = ClassDecl->vbases_end(); VBase != E; ++VBase)
- AllBaseOrMembers.push_back(VBase->getType()->getAsRecordType());
+ AllBaseOrMembers.push_back(VBase->getType()->getAs<RecordType>());
for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin(),
E = ClassDecl->bases_end(); Base != E; ++Base) {
@@ -841,7 +841,7 @@
// first.
if (Base->isVirtual())
continue;
- AllBaseOrMembers.push_back(Base->getType()->getAsRecordType());
+ AllBaseOrMembers.push_back(Base->getType()->getAs<RecordType>());
}
for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(),
@@ -956,7 +956,7 @@
// First, collect the pure virtual methods for the base classes.
for (CXXRecordDecl::base_class_const_iterator Base = RD->bases_begin(),
BaseEnd = RD->bases_end(); Base != BaseEnd; ++Base) {
- if (const RecordType *RT = Base->getType()->getAsRecordType()) {
+ if (const RecordType *RT = Base->getType()->getAs<RecordType>()) {
const CXXRecordDecl *BaseDecl = cast<CXXRecordDecl>(RT->getDecl());
if (BaseDecl && BaseDecl->isAbstract())
Collect(BaseDecl, Methods);
@@ -1019,7 +1019,7 @@
CurrentRD);
}
- const RecordType *RT = T->getAsRecordType();
+ const RecordType *RT = T->getAs<RecordType>();
if (!RT)
return false;
@@ -1150,7 +1150,7 @@
while (const ArrayType *AT = Context.getAsArrayType(FTy))
FTy = AT->getElementType();
- if (const RecordType *RT = FTy->getAsRecordType()) {
+ if (const RecordType *RT = FTy->getAs<RecordType>()) {
CXXRecordDecl *FieldRD = cast<CXXRecordDecl>(RT->getDecl());
if (!FieldRD->hasTrivialConstructor())
@@ -1224,7 +1224,7 @@
for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin();
HasConstCopyConstructor && Base != ClassDecl->bases_end(); ++Base) {
const CXXRecordDecl *BaseClassDecl
- = cast<CXXRecordDecl>(Base->getType()->getAsRecordType()->getDecl());
+ = cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
HasConstCopyConstructor
= BaseClassDecl->hasConstCopyConstructor(Context);
}
@@ -1239,7 +1239,7 @@
QualType FieldType = (*Field)->getType();
if (const ArrayType *Array = Context.getAsArrayType(FieldType))
FieldType = Array->getElementType();
- if (const RecordType *FieldClassType = FieldType->getAsRecordType()) {
+ if (const RecordType *FieldClassType = FieldType->getAs<RecordType>()) {
const CXXRecordDecl *FieldClassDecl
= cast<CXXRecordDecl>(FieldClassType->getDecl());
HasConstCopyConstructor
@@ -1304,7 +1304,7 @@
for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin();
HasConstCopyAssignment && Base != ClassDecl->bases_end(); ++Base) {
const CXXRecordDecl *BaseClassDecl
- = cast<CXXRecordDecl>(Base->getType()->getAsRecordType()->getDecl());
+ = cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
HasConstCopyAssignment = BaseClassDecl->hasConstCopyAssignment(Context);
}
@@ -1318,7 +1318,7 @@
QualType FieldType = (*Field)->getType();
if (const ArrayType *Array = Context.getAsArrayType(FieldType))
FieldType = Array->getElementType();
- if (const RecordType *FieldClassType = FieldType->getAsRecordType()) {
+ if (const RecordType *FieldClassType = FieldType->getAs<RecordType>()) {
const CXXRecordDecl *FieldClassDecl
= cast<CXXRecordDecl>(FieldClassType->getDecl());
HasConstCopyAssignment
@@ -2041,7 +2041,7 @@
for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin(),
E = ClassDecl->bases_end(); Base != E; ++Base) {
CXXRecordDecl *BaseClassDecl
- = cast<CXXRecordDecl>(Base->getType()->getAsRecordType()->getDecl());
+ = cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
if (!BaseClassDecl->hasTrivialConstructor()) {
if (CXXConstructorDecl *BaseCtor =
BaseClassDecl->getDefaultConstructor(Context))
@@ -2061,7 +2061,7 @@
QualType FieldType = Context.getCanonicalType((*Field)->getType());
if (const ArrayType *Array = Context.getAsArrayType(FieldType))
FieldType = Array->getElementType();
- if (const RecordType *FieldClassType = FieldType->getAsRecordType()) {
+ if (const RecordType *FieldClassType = FieldType->getAs<RecordType>()) {
CXXRecordDecl *FieldClassDecl
= cast<CXXRecordDecl>(FieldClassType->getDecl());
if (!FieldClassDecl->hasTrivialConstructor()) {
@@ -2113,7 +2113,7 @@
for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin(),
E = ClassDecl->bases_end(); Base != E; ++Base) {
CXXRecordDecl *BaseClassDecl
- = cast<CXXRecordDecl>(Base->getType()->getAsRecordType()->getDecl());
+ = cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
if (!BaseClassDecl->hasTrivialDestructor()) {
if (CXXDestructorDecl *BaseDtor =
const_cast<CXXDestructorDecl*>(BaseClassDecl->getDestructor(Context)))
@@ -2129,7 +2129,7 @@
QualType FieldType = Context.getCanonicalType((*Field)->getType());
if (const ArrayType *Array = Context.getAsArrayType(FieldType))
FieldType = Array->getElementType();
- if (const RecordType *FieldClassType = FieldType->getAsRecordType()) {
+ if (const RecordType *FieldClassType = FieldType->getAs<RecordType>()) {
CXXRecordDecl *FieldClassDecl
= cast<CXXRecordDecl>(FieldClassType->getDecl());
if (!FieldClassDecl->hasTrivialDestructor()) {
@@ -2165,7 +2165,7 @@
for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin(),
E = ClassDecl->bases_end(); Base != E; ++Base) {
CXXRecordDecl *BaseClassDecl
- = cast<CXXRecordDecl>(Base->getType()->getAsRecordType()->getDecl());
+ = cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
if (CXXMethodDecl *BaseAssignOpMethod =
getAssignOperatorMethod(MethodDecl->getParamDecl(0), BaseClassDecl))
MarkDeclarationReferenced(CurrentLocation, BaseAssignOpMethod);
@@ -2175,7 +2175,7 @@
QualType FieldType = Context.getCanonicalType((*Field)->getType());
if (const ArrayType *Array = Context.getAsArrayType(FieldType))
FieldType = Array->getElementType();
- if (const RecordType *FieldClassType = FieldType->getAsRecordType()) {
+ if (const RecordType *FieldClassType = FieldType->getAs<RecordType>()) {
CXXRecordDecl *FieldClassDecl
= cast<CXXRecordDecl>(FieldClassType->getDecl());
if (CXXMethodDecl *FieldAssignOpMethod =
@@ -2251,7 +2251,7 @@
for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin();
Base != ClassDecl->bases_end(); ++Base) {
CXXRecordDecl *BaseClassDecl
- = cast<CXXRecordDecl>(Base->getType()->getAsRecordType()->getDecl());
+ = cast<CXXRecordDecl>(Base->getType()->getAs<RecordType>()->getDecl());
if (CXXConstructorDecl *BaseCopyCtor =
BaseClassDecl->getCopyConstructor(Context, TypeQuals))
MarkDeclarationReferenced(CurrentLocation, BaseCopyCtor);
@@ -2262,7 +2262,7 @@
QualType FieldType = Context.getCanonicalType((*Field)->getType());
if (const ArrayType *Array = Context.getAsArrayType(FieldType))
FieldType = Array->getElementType();
- if (const RecordType *FieldClassType = FieldType->getAsRecordType()) {
+ if (const RecordType *FieldClassType = FieldType->getAs<RecordType>()) {
CXXRecordDecl *FieldClassDecl
= cast<CXXRecordDecl>(FieldClassType->getDecl());
if (CXXConstructorDecl *FieldCopyCtor =
@@ -2286,7 +2286,7 @@
void Sema::MarkDestructorReferenced(SourceLocation Loc, QualType DeclInitType)
{
CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(
- DeclInitType->getAsRecordType()->getDecl());
+ DeclInitType->getAs<RecordType>()->getDecl());
if (!ClassDecl->hasTrivialDestructor())
if (CXXDestructorDecl *Destructor =
const_cast<CXXDestructorDecl*>(ClassDecl->getDestructor(Context)))
@@ -2402,7 +2402,7 @@
SourceLocation Loc, SourceRange Range,
DeclarationName InitEntity,
InitializationKind Kind) {
- const RecordType *ClassRec = ClassType->getAsRecordType();
+ const RecordType *ClassRec = ClassType->getAs<RecordType>();
assert(ClassRec && "Can only initialize a class type here");
// C++ [dcl.init]p14:
@@ -2652,7 +2652,7 @@
if (!isRValRef && !SuppressUserConversions && T2->isRecordType()) {
// FIXME: Look for conversions in base classes!
CXXRecordDecl *T2RecordDecl
- = dyn_cast<CXXRecordDecl>(T2->getAsRecordType()->getDecl());
+ = dyn_cast<CXXRecordDecl>(T2->getAs<RecordType>()->getDecl());
OverloadCandidateSet CandidateSet;
OverloadedFunctionDecl *Conversions
diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp
index da5e6ba..ff5ead0 100644
--- a/lib/Sema/SemaExpr.cpp
+++ b/lib/Sema/SemaExpr.cpp
@@ -2133,7 +2133,7 @@
// Handle field access to simple records. This also handles access to fields
// of the ObjC 'id' struct.
- if (const RecordType *RTy = BaseType->getAsRecordType()) {
+ if (const RecordType *RTy = BaseType->getAs<RecordType>()) {
RecordDecl *RDecl = RTy->getDecl();
if (RequireCompleteType(OpLoc, BaseType,
diag::err_typecheck_incomplete_tag,
@@ -2937,7 +2937,7 @@
<< castType << castExpr->getSourceRange();
} else if (castType->isUnionType()) {
// GCC cast to union extension
- RecordDecl *RD = castType->getAsRecordType()->getDecl();
+ RecordDecl *RD = castType->getAs<RecordType>()->getDecl();
RecordDecl::field_iterator Field, FieldEnd;
for (Field = RD->field_begin(), FieldEnd = RD->field_end();
Field != FieldEnd; ++Field) {
@@ -3078,8 +3078,8 @@
// If both operands are the same structure or union type, the result is that
// type.
- if (const RecordType *LHSRT = LHSTy->getAsRecordType()) { // C99 6.5.15p3
- if (const RecordType *RHSRT = RHSTy->getAsRecordType())
+ if (const RecordType *LHSRT = LHSTy->getAs<RecordType>()) { // C99 6.5.15p3
+ if (const RecordType *RHSRT = RHSTy->getAs<RecordType>())
if (LHSRT->getDecl() == RHSRT->getDecl())
// "If both the operands have structure or union type, the result has
// that type." This implies that CV qualifiers are dropped.
@@ -5256,7 +5256,7 @@
continue;
}
- const RecordType *RC = Res->getType()->getAsRecordType();
+ const RecordType *RC = Res->getType()->getAs<RecordType>();
if (!RC) {
Res->Destroy(Context);
return ExprError(Diag(OC.LocEnd, diag::err_offsetof_record_type)
diff --git a/lib/Sema/SemaExprCXX.cpp b/lib/Sema/SemaExprCXX.cpp
index b3de60a..8b7baff 100644
--- a/lib/Sema/SemaExprCXX.cpp
+++ b/lib/Sema/SemaExprCXX.cpp
@@ -83,7 +83,7 @@
Expr *E = static_cast<Expr *>(TyOrExpr);
if (E && !E->isTypeDependent() && E->isLvalue(Context) == Expr::LV_Valid) {
QualType T = E->getType();
- if (const RecordType *RecordT = T->getAsRecordType()) {
+ if (const RecordType *RecordT = T->getAs<RecordType>()) {
CXXRecordDecl *RecordD = cast<CXXRecordDecl>(RecordT->getDecl());
if (RecordD->isPolymorphic())
isUnevaluatedOperand = false;
@@ -211,7 +211,7 @@
RParenLoc));
}
- if (const RecordType *RT = Ty->getAsRecordType()) {
+ if (const RecordType *RT = Ty->getAs<RecordType>()) {
CXXRecordDecl *Record = cast<CXXRecordDecl>(RT->getDecl());
// FIXME: We should always create a CXXTemporaryObjectExpr here unless
@@ -414,7 +414,7 @@
if (AllocType->isDependentType()) {
// Skip all the checks.
}
- else if ((RT = AllocType->getAsRecordType()) &&
+ else if ((RT = AllocType->getAs<RecordType>()) &&
!AllocType->isAggregateType()) {
Constructor = PerformInitializationByConstructor(
AllocType, ConsArgs, NumConsArgs,
@@ -516,7 +516,7 @@
IsArray ? OO_Array_New : OO_New);
if (AllocType->isRecordType() && !UseGlobal) {
CXXRecordDecl *Record
- = cast<CXXRecordDecl>(AllocType->getAsRecordType()->getDecl());
+ = cast<CXXRecordDecl>(AllocType->getAs<RecordType>()->getDecl());
// FIXME: We fail to find inherited overloads.
if (FindAllocationOverload(StartLoc, Range, NewName, &AllocArgs[0],
AllocArgs.size(), Record, /*AllowMissing=*/true,
@@ -757,7 +757,7 @@
} else if (Ty->isArrayType()) { // ...or an array.
Diag(StartLoc, diag::err_invalid_use_of_array_type)
<< SourceRange(StartLoc, EqualLoc);
- } else if (const RecordType *RT = Ty->getAsRecordType()) {
+ } else if (const RecordType *RT = Ty->getAs<RecordType>()) {
RecordDecl *RD = RT->getDecl();
// The type-specifier-seq shall not declare a new class...
if (RD->isDefinition() &&
@@ -1051,7 +1051,7 @@
// be of type "pointer to member of T" (where T is a completely-defined
// class type) [...]
QualType RType = rex->getType();
- const MemberPointerType *MemPtr = RType->getAsMemberPointerType();
+ const MemberPointerType *MemPtr = RType->getAs<MemberPointerType>();
if (!MemPtr) {
Diag(Loc, diag::err_bad_memptr_rhs)
<< OpSpelling << RType << rex->getSourceRange();
@@ -1163,8 +1163,8 @@
// the same or one is a base class of the other:
QualType FTy = From->getType();
QualType TTy = To->getType();
- const RecordType *FRec = FTy->getAsRecordType();
- const RecordType *TRec = TTy->getAsRecordType();
+ const RecordType *FRec = FTy->getAs<RecordType>();
+ const RecordType *TRec = TTy->getAs<RecordType>();
bool FDerivedFromT = FRec && TRec && Self.IsDerivedFrom(FTy, TTy);
if (FRec && TRec && (FRec == TRec ||
FDerivedFromT || Self.IsDerivedFrom(TTy, FTy))) {
@@ -1418,8 +1418,8 @@
// containing class, and second-level cv-ness.
// cv-ness is not a union, but must match one of the two operands. (Which,
// frankly, is stupid.)
- const MemberPointerType *LMemPtr = LTy->getAsMemberPointerType();
- const MemberPointerType *RMemPtr = RTy->getAsMemberPointerType();
+ const MemberPointerType *LMemPtr = LTy->getAs<MemberPointerType>();
+ const MemberPointerType *RMemPtr = RTy->getAs<MemberPointerType>();
if (LMemPtr && RHS->isNullPointerConstant(Context)) {
ImpCastExprToType(RHS, LTy);
return LTy;
@@ -1562,7 +1562,7 @@
}
Sema::OwningExprResult Sema::MaybeBindToTemporary(Expr *E) {
- const RecordType *RT = E->getType()->getAsRecordType();
+ const RecordType *RT = E->getType()->getAs<RecordType>();
if (!RT)
return Owned(E);
diff --git a/lib/Sema/SemaInherit.cpp b/lib/Sema/SemaInherit.cpp
index 2f914f1..be235e9 100644
--- a/lib/Sema/SemaInherit.cpp
+++ b/lib/Sema/SemaInherit.cpp
@@ -114,7 +114,7 @@
return false;
Paths.setOrigin(Derived);
- return LookupInBases(cast<CXXRecordDecl>(Derived->getAsRecordType()->getDecl()),
+ return LookupInBases(cast<CXXRecordDecl>(Derived->getAs<RecordType>()->getDecl()),
MemberLookupCriteria(Base), Paths);
}
@@ -156,7 +156,7 @@
if (Paths.isDetectingVirtual() && Paths.DetectedVirtual == 0) {
// If this is the first virtual we find, remember it. If it turns out
// there is no base path here, we'll reset it later.
- Paths.DetectedVirtual = BaseType->getAsRecordType();
+ Paths.DetectedVirtual = BaseType->getAs<RecordType>();
SetVirtual = true;
}
} else
@@ -175,7 +175,7 @@
}
CXXRecordDecl *BaseRecord
- = cast<CXXRecordDecl>(BaseSpec->getType()->getAsRecordType()->getDecl());
+ = cast<CXXRecordDecl>(BaseSpec->getType()->getAs<RecordType>()->getDecl());
// Either look at the base class type or look into the base class
// type to see if we've found a member that meets the search
diff --git a/lib/Sema/SemaInit.cpp b/lib/Sema/SemaInit.cpp
index 52099a3..d92f37f 100644
--- a/lib/Sema/SemaInit.cpp
+++ b/lib/Sema/SemaInit.cpp
@@ -162,7 +162,7 @@
if ((DeclTypeC.getUnqualifiedType() == InitTypeC.getUnqualifiedType()) ||
IsDerivedFrom(InitTypeC, DeclTypeC)) {
const CXXRecordDecl *RD =
- cast<CXXRecordDecl>(DeclType->getAsRecordType()->getDecl());
+ cast<CXXRecordDecl>(DeclType->getAs<RecordType>()->getDecl());
// No need to make a CXXConstructExpr if both the ctor and dtor are
// trivial.
@@ -341,7 +341,7 @@
if (ILE->getSyntacticForm())
Loc = ILE->getSyntacticForm()->getSourceRange().getBegin();
- if (const RecordType *RType = ILE->getType()->getAsRecordType()) {
+ if (const RecordType *RType = ILE->getType()->getAs<RecordType>()) {
unsigned Init = 0, NumInits = ILE->getNumInits();
for (RecordDecl::field_iterator
Field = RType->getDecl()->field_begin(),
@@ -447,7 +447,7 @@
}
int InitListChecker::numStructUnionElements(QualType DeclType) {
- RecordDecl *structDecl = DeclType->getAsRecordType()->getDecl();
+ RecordDecl *structDecl = DeclType->getAs<RecordType>()->getDecl();
int InitializableMembers = 0;
for (RecordDecl::field_iterator
Field = structDecl->field_begin(),
@@ -584,7 +584,7 @@
CheckVectorType(IList, DeclType, Index, StructuredList, StructuredIndex);
} else if (DeclType->isAggregateType()) {
if (DeclType->isRecordType()) {
- RecordDecl *RD = DeclType->getAsRecordType()->getDecl();
+ RecordDecl *RD = DeclType->getAs<RecordType>()->getDecl();
CheckStructUnionTypes(IList, DeclType, RD->field_begin(),
SubobjectIsDesignatorContext, Index,
StructuredList, StructuredIndex,
@@ -939,7 +939,7 @@
InitListExpr *StructuredList,
unsigned &StructuredIndex,
bool TopLevelObject) {
- RecordDecl* structDecl = DeclType->getAsRecordType()->getDecl();
+ RecordDecl* structDecl = DeclType->getAs<RecordType>()->getDecl();
// If the record is invalid, some of it's members are invalid. To avoid
// confusion, we forgo checking the intializer for the entire record.
@@ -950,7 +950,7 @@
if (DeclType->isUnionType() && IList->getNumInits() == 0) {
// Value-initialize the first named member of the union.
- RecordDecl *RD = DeclType->getAsRecordType()->getDecl();
+ RecordDecl *RD = DeclType->getAs<RecordType>()->getDecl();
for (RecordDecl::field_iterator FieldEnd = RD->field_end();
Field != FieldEnd; ++Field) {
if (Field->getDeclName()) {
@@ -965,7 +965,7 @@
// anything except look at designated initializers; That's okay,
// because an error should get printed out elsewhere. It might be
// worthwhile to skip over the rest of the initializer, though.
- RecordDecl *RD = DeclType->getAsRecordType()->getDecl();
+ RecordDecl *RD = DeclType->getAs<RecordType>()->getDecl();
RecordDecl::field_iterator FieldEnd = RD->field_end();
bool InitializedSomething = false;
while (Index < IList->getNumInits()) {
@@ -1204,7 +1204,7 @@
// then the current object (defined below) shall have
// structure or union type and the identifier shall be the
// name of a member of that type.
- const RecordType *RT = CurrentObjectType->getAsRecordType();
+ const RecordType *RT = CurrentObjectType->getAs<RecordType>();
if (!RT) {
SourceLocation Loc = D->getDotLoc();
if (Loc.isInvalid())
@@ -1564,7 +1564,7 @@
}
} else if (const VectorType *VType = CurrentObjectType->getAsVectorType())
NumElements = VType->getNumElements();
- else if (const RecordType *RType = CurrentObjectType->getAsRecordType()) {
+ else if (const RecordType *RType = CurrentObjectType->getAs<RecordType>()) {
RecordDecl *RDecl = RType->getDecl();
if (RDecl->isUnion())
NumElements = 1;
@@ -1758,7 +1758,7 @@
if (const ArrayType *AT = Context.getAsArrayType(Type))
return CheckValueInitialization(AT->getElementType(), Loc);
- if (const RecordType *RT = Type->getAsRecordType()) {
+ if (const RecordType *RT = Type->getAs<RecordType>()) {
if (CXXRecordDecl *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getDecl())) {
// -- if T is a class type (clause 9) with a user-declared
// constructor (12.1), then the default constructor for T is
diff --git a/lib/Sema/SemaLookup.cpp b/lib/Sema/SemaLookup.cpp
index a37be68..1ca3412 100644
--- a/lib/Sema/SemaLookup.cpp
+++ b/lib/Sema/SemaLookup.cpp
@@ -1387,7 +1387,7 @@
for (CXXRecordDecl::base_class_iterator Base = Class->bases_begin(),
BaseEnd = Class->bases_end();
Base != BaseEnd; ++Base) {
- const RecordType *BaseType = Base->getType()->getAsRecordType();
+ const RecordType *BaseType = Base->getType()->getAs<RecordType>();
CXXRecordDecl *BaseDecl = cast<CXXRecordDecl>(BaseType->getDecl());
if (AssociatedClasses.insert(BaseDecl)) {
// Find the associated namespace for this base class.
@@ -1453,7 +1453,7 @@
// member, if any; and its direct and indirect base
// classes. Its associated namespaces are the namespaces in
// which its associated classes are defined.
- if (const RecordType *ClassType = T->getAsRecordType())
+ if (const RecordType *ClassType = T->getAs<RecordType>())
if (CXXRecordDecl *ClassDecl
= dyn_cast<CXXRecordDecl>(ClassType->getDecl())) {
addAssociatedClassesAndNamespaces(ClassDecl, Context,
@@ -1519,7 +1519,7 @@
// associated namespaces and classes are those associated
// with the member type together with those associated with
// X.
- if (const MemberPointerType *MemberPtr = T->getAsMemberPointerType()) {
+ if (const MemberPointerType *MemberPtr = T->getAs<MemberPointerType>()) {
// Handle the type that the pointer to member points to.
addAssociatedClassesAndNamespaces(MemberPtr->getPointeeType(),
Context,
@@ -1527,7 +1527,7 @@
GlobalScope);
// Handle the class type into which this points.
- if (const RecordType *Class = MemberPtr->getClass()->getAsRecordType())
+ if (const RecordType *Class = MemberPtr->getClass()->getAs<RecordType>())
addAssociatedClassesAndNamespaces(cast<CXXRecordDecl>(Class->getDecl()),
Context,
AssociatedNamespaces, AssociatedClasses,
diff --git a/lib/Sema/SemaNamedCast.cpp b/lib/Sema/SemaNamedCast.cpp
index 1fdbcfe..0dedd3a 100644
--- a/lib/Sema/SemaNamedCast.cpp
+++ b/lib/Sema/SemaNamedCast.cpp
@@ -118,7 +118,7 @@
DestType = Self.Context.getCanonicalType(DestType);
QualType SrcType = SrcExpr->getType();
if (const LValueReferenceType *DestTypeTmp =
- DestType->getAsLValueReferenceType()) {
+ DestType->getAs<LValueReferenceType>()) {
if (SrcExpr->isLvalue(Self.Context) != Expr::LV_Valid) {
// Cannot cast non-lvalue to lvalue reference type.
Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_rvalue)
@@ -220,7 +220,7 @@
DestType = Self.Context.getCanonicalType(DestType);
QualType SrcType = SrcExpr->getType();
if (const LValueReferenceType *DestTypeTmp =
- DestType->getAsLValueReferenceType()) {
+ DestType->getAs<LValueReferenceType>()) {
if (SrcExpr->isLvalue(Self.Context) != Expr::LV_Valid) {
// Cannot cast non-lvalue to reference type.
Self.Diag(OpRange.getBegin(), diag::err_bad_cxx_cast_rvalue)
@@ -235,7 +235,7 @@
DestType = Self.Context.getPointerType(DestTypeTmp->getPointeeType());
SrcType = Self.Context.getPointerType(SrcType);
} else if (const RValueReferenceType *DestTypeTmp =
- DestType->getAsRValueReferenceType()) {
+ DestType->getAs<RValueReferenceType>()) {
// Both the reference conversion and the rvalue rules apply.
Self.DefaultFunctionArrayConversion(SrcExpr);
SrcType = SrcExpr->getType();
@@ -253,8 +253,8 @@
// Canonicalize source for comparison.
SrcType = Self.Context.getCanonicalType(SrcType);
- const MemberPointerType *DestMemPtr = DestType->getAsMemberPointerType(),
- *SrcMemPtr = SrcType->getAsMemberPointerType();
+ const MemberPointerType *DestMemPtr = DestType->getAs<MemberPointerType>(),
+ *SrcMemPtr = SrcType->getAs<MemberPointerType>();
if (DestMemPtr && SrcMemPtr) {
// C++ 5.2.10p9: An rvalue of type "pointer to member of X of type T1"
// can be explicitly converted to an rvalue of type "pointer to member
@@ -563,7 +563,7 @@
{
// N2844 5.2.9p3: An lvalue of type "cv1 T1" can be cast to type "rvalue
// reference to cv2 T2" if "cv2 T2" is reference-compatible with "cv1 T1".
- const RValueReferenceType *R = DestType->getAsRValueReferenceType();
+ const RValueReferenceType *R = DestType->getAs<RValueReferenceType>();
if (!R)
return TSC_NotApplicable;
@@ -738,10 +738,10 @@
TryStaticMemberPointerUpcast(Sema &Self, QualType SrcType, QualType DestType,
const SourceRange &OpRange)
{
- const MemberPointerType *SrcMemPtr = SrcType->getAsMemberPointerType();
+ const MemberPointerType *SrcMemPtr = SrcType->getAs<MemberPointerType>();
if (!SrcMemPtr)
return TSC_NotApplicable;
- const MemberPointerType *DestMemPtr = DestType->getAsMemberPointerType();
+ const MemberPointerType *DestMemPtr = DestType->getAs<MemberPointerType>();
if (!DestMemPtr)
return TSC_NotApplicable;
@@ -840,7 +840,7 @@
return;
}
- const RecordType *DestRecord = DestPointee->getAsRecordType();
+ const RecordType *DestRecord = DestPointee->getAs<RecordType>();
if (DestPointee->isVoidType()) {
assert(DestPointer && "Reference to void is not possible");
} else if (DestRecord) {
@@ -880,7 +880,7 @@
SrcPointee = SrcType;
}
- const RecordType *SrcRecord = SrcPointee->getAsRecordType();
+ const RecordType *SrcRecord = SrcPointee->getAs<RecordType>();
if (SrcRecord) {
if (Self.RequireCompleteType(OpRange.getBegin(), SrcPointee,
diag::err_bad_dynamic_cast_incomplete,
diff --git a/lib/Sema/SemaOverload.cpp b/lib/Sema/SemaOverload.cpp
index aef7f18..0a16157 100644
--- a/lib/Sema/SemaOverload.cpp
+++ b/lib/Sema/SemaOverload.cpp
@@ -1178,7 +1178,7 @@
bool Sema::IsMemberPointerConversion(Expr *From, QualType FromType,
QualType ToType, QualType &ConvertedType)
{
- const MemberPointerType *ToTypePtr = ToType->getAsMemberPointerType();
+ const MemberPointerType *ToTypePtr = ToType->getAs<MemberPointerType>();
if (!ToTypePtr)
return false;
@@ -1189,7 +1189,7 @@
}
// Otherwise, both types have to be member pointers.
- const MemberPointerType *FromTypePtr = FromType->getAsMemberPointerType();
+ const MemberPointerType *FromTypePtr = FromType->getAs<MemberPointerType>();
if (!FromTypePtr)
return false;
@@ -1216,11 +1216,11 @@
/// otherwise.
bool Sema::CheckMemberPointerConversion(Expr *From, QualType ToType) {
QualType FromType = From->getType();
- const MemberPointerType *FromPtrType = FromType->getAsMemberPointerType();
+ const MemberPointerType *FromPtrType = FromType->getAs<MemberPointerType>();
if (!FromPtrType)
return false;
- const MemberPointerType *ToPtrType = ToType->getAsMemberPointerType();
+ const MemberPointerType *ToPtrType = ToType->getAs<MemberPointerType>();
assert(ToPtrType && "No member pointer cast has a target type "
"that is not a member pointer.");
@@ -1340,7 +1340,7 @@
bool AllowExplicit, bool ForceRValue)
{
OverloadCandidateSet CandidateSet;
- if (const RecordType *ToRecordType = ToType->getAsRecordType()) {
+ if (const RecordType *ToRecordType = ToType->getAs<RecordType>()) {
if (CXXRecordDecl *ToRecordDecl
= dyn_cast<CXXRecordDecl>(ToRecordType->getDecl())) {
// C++ [over.match.ctor]p1:
@@ -1369,7 +1369,7 @@
if (!AllowConversionFunctions) {
// Don't allow any conversion functions to enter the overload set.
} else if (const RecordType *FromRecordType
- = From->getType()->getAsRecordType()) {
+ = From->getType()->getAs<RecordType>()) {
if (CXXRecordDecl *FromRecordDecl
= dyn_cast<CXXRecordDecl>(FromRecordType->getDecl())) {
// Add all of the conversion functions as candidates.
@@ -2500,7 +2500,7 @@
// (13.3.1.1.1); otherwise, the set of member candidates is
// empty.
// FIXME: Lookup in base classes, too!
- if (const RecordType *T1Rec = T1->getAsRecordType()) {
+ if (const RecordType *T1Rec = T1->getAs<RecordType>()) {
DeclContext::lookup_const_iterator Oper, OperEnd;
for (llvm::tie(Oper, OperEnd) = T1Rec->getDecl()->lookup(OpName);
Oper != OperEnd; ++Oper)
@@ -2668,7 +2668,7 @@
if (!MemberPointerTypes.insert(Ty))
return false;
- if (const MemberPointerType *PointerTy = Ty->getAsMemberPointerType()) {
+ if (const MemberPointerType *PointerTy = Ty->getAs<MemberPointerType>()) {
QualType PointeeTy = PointerTy->getPointeeType();
const Type *ClassTy = PointerTy->getClass();
// FIXME: Optimize this so that we don't keep trying to add the same types.
@@ -2728,7 +2728,7 @@
// If this is a pointer to a class type, add pointers to its bases
// (with the same level of cv-qualification as the original
// derived class, of course).
- if (const RecordType *PointeeRec = PointeeTy->getAsRecordType()) {
+ if (const RecordType *PointeeRec = PointeeTy->getAs<RecordType>()) {
CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(PointeeRec->getDecl());
for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin();
Base != ClassDecl->bases_end(); ++Base) {
@@ -2747,7 +2747,7 @@
} else if (Ty->isEnumeralType()) {
EnumerationTypes.insert(Ty);
} else if (AllowUserConversions) {
- if (const RecordType *TyRec = Ty->getAsRecordType()) {
+ if (const RecordType *TyRec = Ty->getAs<RecordType>()) {
CXXRecordDecl *ClassDecl = cast<CXXRecordDecl>(TyRec->getDecl());
// FIXME: Visit conversion functions in the base classes, too.
OverloadedFunctionDecl *Conversions
@@ -3616,11 +3616,11 @@
bool isRValueReference = false;
bool isPointer = false;
if (const LValueReferenceType *FnTypeRef =
- FnType->getAsLValueReferenceType()) {
+ FnType->getAs<LValueReferenceType>()) {
FnType = FnTypeRef->getPointeeType();
isLValueReference = true;
} else if (const RValueReferenceType *FnTypeRef =
- FnType->getAsRValueReferenceType()) {
+ FnType->getAs<RValueReferenceType>()) {
FnType = FnTypeRef->getPointeeType();
isRValueReference = true;
}
@@ -3678,7 +3678,7 @@
else if (const ReferenceType *ToTypeRef = ToType->getAs<ReferenceType>())
FunctionType = ToTypeRef->getPointeeType();
else if (const MemberPointerType *MemTypePtr =
- ToType->getAsMemberPointerType()) {
+ ToType->getAs<MemberPointerType>()) {
FunctionType = MemTypePtr->getPointeeType();
IsMember = true;
}
@@ -4367,7 +4367,7 @@
SourceLocation *CommaLocs,
SourceLocation RParenLoc) {
assert(Object->getType()->isRecordType() && "Requires object type argument");
- const RecordType *Record = Object->getType()->getAsRecordType();
+ const RecordType *Record = Object->getType()->getAs<RecordType>();
// C++ [over.call.object]p1:
// If the primary-expression E in the function call syntax
@@ -4579,7 +4579,7 @@
// FIXME: look in base classes.
DeclarationName OpName = Context.DeclarationNames.getCXXOperatorName(OO_Arrow);
OverloadCandidateSet CandidateSet;
- const RecordType *BaseRecord = Base->getType()->getAsRecordType();
+ const RecordType *BaseRecord = Base->getType()->getAs<RecordType>();
DeclContext::lookup_const_iterator Oper, OperEnd;
for (llvm::tie(Oper, OperEnd)
diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp
index 9159cf1..9ee4f3f 100644
--- a/lib/Sema/SemaTemplate.cpp
+++ b/lib/Sema/SemaTemplate.cpp
@@ -1329,7 +1329,7 @@
const TagType *Tag = 0;
if (const EnumType *EnumT = Arg->getAsEnumType())
Tag = EnumT;
- else if (const RecordType *RecordT = Arg->getAsRecordType())
+ else if (const RecordType *RecordT = Arg->getAs<RecordType>())
Tag = RecordT;
if (Tag && Tag->getDecl()->getDeclContext()->isFunctionOrMethod())
return Diag(ArgLoc, diag::err_template_arg_local_type)
@@ -1662,7 +1662,7 @@
// the set (13.4).
// Again, C++0x allows a std::nullptr_t value.
(ParamType->isMemberPointerType() &&
- ParamType->getAsMemberPointerType()->getPointeeType()
+ ParamType->getAs<MemberPointerType>()->getPointeeType()
->isFunctionType())) {
if (Context.hasSameUnqualifiedType(ArgType,
ParamType.getNonReferenceType())) {
diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp
index d475538..5c4f6e7 100644
--- a/lib/Sema/SemaTemplateDeduction.cpp
+++ b/lib/Sema/SemaTemplateDeduction.cpp
@@ -410,7 +410,7 @@
// T &
case Type::LValueReference: {
- const LValueReferenceType *ReferenceArg = Arg->getAsLValueReferenceType();
+ const LValueReferenceType *ReferenceArg = Arg->getAs<LValueReferenceType>();
if (!ReferenceArg)
return Sema::TDK_NonDeducedMismatch;
@@ -422,7 +422,7 @@
// T && [C++0x]
case Type::RValueReference: {
- const RValueReferenceType *ReferenceArg = Arg->getAsRValueReferenceType();
+ const RValueReferenceType *ReferenceArg = Arg->getAs<RValueReferenceType>();
if (!ReferenceArg)
return Sema::TDK_NonDeducedMismatch;
@@ -615,7 +615,7 @@
Base != BaseEnd; ++Base) {
assert(Base->getType()->isRecordType() &&
"Base class that isn't a record?");
- ToVisit.push_back(Base->getType()->getAsRecordType());
+ ToVisit.push_back(Base->getType()->getAs<RecordType>());
}
}
diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp
index d69227c..6f28e27 100644
--- a/lib/Sema/SemaType.cpp
+++ b/lib/Sema/SemaType.cpp
@@ -414,7 +414,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".
@@ -524,7 +524,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())
@@ -1207,7 +1207,7 @@
bool Sema::CheckDistantExceptionSpec(QualType T) {
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;
@@ -1392,8 +1392,8 @@
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())) {
@@ -1567,7 +1567,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) {
@@ -1603,7 +1603,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;