const FunctionType *getAsFunctionType() const;
const FunctionNoProtoType *getAsFunctionNoProtoType() const;
const FunctionProtoType *getAsFunctionProtoType() const;
- const LValueReferenceType *getAsLValueReferenceType() const;
- const RValueReferenceType *getAsRValueReferenceType() const;
- const MemberPointerType *getAsMemberPointerType() const;
- const TagType *getAsTagType() const;
- const RecordType *getAsRecordType() const;
const RecordType *getAsStructureType() const;
/// NOTE: getAs*ArrayType are methods on ASTContext.
const TypedefType *getAsTypedefType() const;
return isa<MemberPointerType>(CanonicalType.getUnqualifiedType());
}
inline bool Type::isMemberFunctionPointerType() const {
- if (const MemberPointerType* T = getAsMemberPointerType())
+ if (const MemberPointerType* T = getAs<MemberPointerType>())
return T->getPointeeType()->isFunctionType();
else
return false;
}
void ASTContext::setCFConstantStringType(QualType T) {
- const RecordType *Rec = T->getAsRecordType();
+ const RecordType *Rec = T->getAs<RecordType>();
assert(Rec && "Invalid CFConstantStringType");
CFConstantStringTypeDecl = Rec->getDecl();
}
}
void ASTContext::setObjCFastEnumerationStateType(QualType T) {
- const RecordType *Rec = T->getAsRecordType();
+ const RecordType *Rec = T->getAs<RecordType>();
assert(Rec && "Invalid ObjCFAstEnumerationStateType");
ObjCFastEnumerationStateTypeDecl = Rec->getDecl();
}
return;
}
- if (const RecordType *RTy = T->getAsRecordType()) {
+ if (const RecordType *RTy = T->getAs<RecordType>()) {
RecordDecl *RDecl = RTy->getDecl();
S += RDecl->isUnion() ? '(' : '{';
// Anonymous structures print as '?'
if (!isImplicit() || getDeclName())
return false;
- if (const RecordType *Record = getType()->getAsRecordType())
+ if (const RecordType *Record = getType()->getAs<RecordType>())
return Record->getDecl()->isAnonymousStructOrUnion();
return false;
}
void TagDecl::startDefinition() {
- TagType *TagT = const_cast<TagType *>(TypeForDecl->getAsTagType());
+ TagType *TagT = const_cast<TagType *>(TypeForDecl->getAs<TagType>());
TagT->decl.setPointer(this);
- TagT->getAsTagType()->decl.setInt(1);
+ TagT->getAs<TagType>()->decl.setInt(1);
}
void TagDecl::completeDefinition() {
assert((!TypeForDecl ||
- TypeForDecl->getAsTagType()->decl.getPointer() == this) &&
+ TypeForDecl->getAs<TagType>()->decl.getPointer() == this) &&
"Attempt to redefine a tag definition?");
IsDefinition = true;
- TagType *TagT = const_cast<TagType *>(TypeForDecl->getAsTagType());
+ TagType *TagT = const_cast<TagType *>(TypeForDecl->getAs<TagType>());
TagT->decl.setPointer(this);
TagT->decl.setInt(0);
}
TagDecl* TagDecl::getDefinition(ASTContext& C) const {
QualType T = C.getTypeDeclType(const_cast<TagDecl*>(this));
- TagDecl* D = cast<TagDecl>(T->getAsTagType()->getDecl());
+ TagDecl* D = cast<TagDecl>(T->getAs<TagType>()->getDecl());
return D->isDefinition() ? D : 0;
}
if (DeclKind >= Decl::TagFirst && DeclKind <= Decl::TagLast) {
// If this is a tag type that has a definition or is currently
// being defined, that definition is our primary context.
- if (const TagType *TagT =cast<TagDecl>(this)->TypeForDecl->getAsTagType())
+ if (const TagType *TagT =cast<TagDecl>(this)->TypeForDecl->getAs<TagType>())
if (TagT->isBeingDefined() ||
(TagT->getDecl() && TagT->getDecl()->isDefinition()))
return TagT->getDecl();
if (BaseType->isDependentType())
continue;
CXXRecordDecl *BaseClassDecl
- = cast<CXXRecordDecl>(BaseType->getAsRecordType()->getDecl());
+ = cast<CXXRecordDecl>(BaseType->getAs<RecordType>()->getDecl());
if (Base->isVirtual())
hasDirectVirtualBase = true;
for (CXXRecordDecl::base_class_iterator VBase =
for (int i = 0; i < vbaseCount; i++) {
QualType QT = UniqueVbases[i]->getType();
CXXRecordDecl *VBaseClassDecl
- = cast<CXXRecordDecl>(QT->getAsRecordType()->getDecl());
+ = cast<CXXRecordDecl>(QT->getAs<RecordType>()->getDecl());
this->VBases[i] =
*new CXXBaseSpecifier(
VBaseClassDecl->getSourceRange(), true,
continue;
bool AcceptsConst = true;
QualType ArgType = FnType->getArgType(0);
- if (const LValueReferenceType *Ref = ArgType->getAsLValueReferenceType()) {
+ if (const LValueReferenceType *Ref = ArgType->getAs<LValueReferenceType>()) {
ArgType = Ref->getPointeeType();
// Is it a non-const lvalue reference?
if (!ArgType.isConstQualified())
assert(FnType && "Overloaded operator has no proto function type.");
assert(FnType->getNumArgs() == 1 && !FnType->isVariadic());
QualType ArgType = FnType->getArgType(0);
- if (const LValueReferenceType *Ref = ArgType->getAsLValueReferenceType())
+ if (const LValueReferenceType *Ref = ArgType->getAs<LValueReferenceType>())
ArgType = Ref->getPointeeType();
ArgType = ArgType.getUnqualifiedType();
// Do we have a reference type? Rvalue references don't count.
const LValueReferenceType *ParamRefType =
- Param->getType()->getAsLValueReferenceType();
+ Param->getType()->getAs<LValueReferenceType>();
if (!ParamRefType)
return false;
while (const ArrayType *AT = C.getAsArrayType(FieldType))
FieldType = AT->getElementType();
- if (FieldType->getAsRecordType()) {
+ if (FieldType->getAs<RecordType>()) {
CXXBaseOrMemberInitializer *Member =
new CXXBaseOrMemberInitializer((*Field), 0, 0, SourceLocation());
AllToDestruct.push_back(Member);
for (CXXRecordDecl::base_class_iterator VBase =
ClassDecl->vbases_begin(),
E = ClassDecl->vbases_end(); VBase != E; ++VBase) {
- const Type * T = VBase->getType()->getAsRecordType();
+ const Type * T = VBase->getType()->getAs<RecordType>();
unsigned int i = 0;
for (i = 0; i < NumInitializers; i++) {
CXXBaseOrMemberInitializer *Member = Initializers[i];
if (Member->isBaseInitializer() &&
- Member->getBaseClass()->getAsRecordType() == T) {
+ Member->getBaseClass()->getAs<RecordType>() == T) {
AllToInit.push_back(Member);
break;
}
// Virtuals are in the virtual base list and already constructed.
if (Base->isVirtual())
continue;
- const Type * T = Base->getType()->getAsRecordType();
+ const Type * T = Base->getType()->getAs<RecordType>();
unsigned int i = 0;
for (i = 0; i < NumInitializers; i++) {
CXXBaseOrMemberInitializer *Member = Initializers[i];
if (Member->isBaseInitializer() &&
- Member->getBaseClass()->getAsRecordType() == T) {
+ Member->getBaseClass()->getAs<RecordType>() == T) {
AllToInit.push_back(Member);
break;
}
while (const ArrayType *AT = C.getAsArrayType(FieldType))
FieldType = AT->getElementType();
- if (FieldType->getAsRecordType()) {
+ if (FieldType->getAs<RecordType>()) {
CXXBaseOrMemberInitializer *Member =
new CXXBaseOrMemberInitializer((*Field), 0, 0, SourceLocation());
AllToInit.push_back(Member);
}
else // FIXME. skip dependent types for now.
if (const RecordType *RT =
- BMInitializer->getBaseClass()->getAsRecordType()) {
+ BMInitializer->getBaseClass()->getAs<RecordType>()) {
const CXXRecordDecl *BaseDecl =
cast<CXXRecordDecl>(RT->getDecl());
Out << BaseDecl->getNameAsString();
}
else // FIXME. skip dependent types for now.
if (const RecordType *RT =
- BMInitializer->getBaseClass()->getAsRecordType()) {
+ BMInitializer->getBaseClass()->getAs<RecordType>()) {
const CXXRecordDecl *BaseDecl =
cast<CXXRecordDecl>(RT->getDecl());
Proto += "~";
case CXXConstructorName: {
QualType ClassType = getCXXNameType();
- if (const RecordType *ClassRec = ClassType->getAsRecordType())
+ if (const RecordType *ClassRec = ClassType->getAs<RecordType>())
return ClassRec->getDecl()->getNameAsString();
return ClassType.getAsString();
}
case CXXDestructorName: {
std::string Result = "~";
QualType Type = getCXXNameType();
- if (const RecordType *Rec = Type->getAsRecordType())
+ if (const RecordType *Rec = Type->getAs<RecordType>())
Result += Rec->getDecl()->getNameAsString();
else
Result += Type.getAsString();
case CXXConversionFunctionName: {
std::string Result = "operator ";
QualType Type = getCXXNameType();
- if (const RecordType *Rec = Type->getAsRecordType())
+ if (const RecordType *Rec = Type->getAs<RecordType>())
Result += Rec->getDecl()->getNameAsString();
else
Result += Type.getAsString();
if (CT->isIncompleteType())
return MLV_IncompleteType;
- if (const RecordType *r = CT->getAsRecordType()) {
+ if (const RecordType *r = CT->getAs<RecordType>()) {
if (r->hasConstFields())
return MLV_ConstQualified;
}
case UTT_IsPOD: return QueriedType->isPODType();
case UTT_IsClass: // Fallthrough
case UTT_IsUnion:
- if (const RecordType *Record = QueriedType->getAsRecordType()) {
+ if (const RecordType *Record = QueriedType->getAs<RecordType>()) {
bool Union = Record->getDecl()->isUnion();
return UTT == UTT_IsUnion ? Union : !Union;
}
return false;
case UTT_IsEnum: return QueriedType->isEnumeralType();
case UTT_IsPolymorphic:
- if (const RecordType *Record = QueriedType->getAsRecordType()) {
+ if (const RecordType *Record = QueriedType->getAs<RecordType>()) {
// Type traits are only parsed in C++, so we've got CXXRecords.
return cast<CXXRecordDecl>(Record->getDecl())->isPolymorphic();
}
return false;
case UTT_IsAbstract:
- if (const RecordType *RT = QueriedType->getAsRecordType())
+ if (const RecordType *RT = QueriedType->getAs<RecordType>())
return cast<CXXRecordDecl>(RT->getDecl())->isAbstract();
return false;
case UTT_HasTrivialConstructor:
- if (const RecordType *RT = QueriedType->getAsRecordType())
+ if (const RecordType *RT = QueriedType->getAs<RecordType>())
return cast<CXXRecordDecl>(RT->getDecl())->hasTrivialConstructor();
return false;
case UTT_HasTrivialDestructor:
- if (const RecordType *RT = QueriedType->getAsRecordType())
+ if (const RecordType *RT = QueriedType->getAs<RecordType>())
return cast<CXXRecordDecl>(RT->getDecl())->hasTrivialDestructor();
return false;
}
Ty = E->getBase()->getType();
}
- RecordDecl *RD = Ty->getAsRecordType()->getDecl();
+ RecordDecl *RD = Ty->getAs<RecordType>()->getDecl();
const ASTRecordLayout &RL = Info.Ctx.getASTRecordLayout(RD);
FieldDecl *FD = dyn_cast<FieldDecl>(E->getMemberDecl());
// Display the base classes.
const CXXRecordDecl *Decl
- = static_cast<const CXXRecordDecl *>(Type->getAsRecordType()->getDecl());
+ = static_cast<const CXXRecordDecl *>(Type->getAs<RecordType>()->getDecl());
for (CXXRecordDecl::base_class_const_iterator Base = Decl->bases_begin();
Base != Decl->bases_end(); ++Base) {
QualType CanonBaseType = Context.getCanonicalType(Base->getType());
}
bool Type::isClassType() const {
- if (const RecordType *RT = getAsRecordType())
+ if (const RecordType *RT = getAs<RecordType>())
return RT->getDecl()->isClass();
return false;
}
bool Type::isStructureType() const {
- if (const RecordType *RT = getAsRecordType())
+ if (const RecordType *RT = getAs<RecordType>())
return RT->getDecl()->isStruct();
return false;
}
}
bool Type::isUnionType() const {
- if (const RecordType *RT = getAsRecordType())
+ if (const RecordType *RT = getAs<RecordType>())
return RT->getDecl()->isUnion();
return false;
}
return QualType();
}
-const LValueReferenceType *Type::getAsLValueReferenceType() const {
- // If this is directly an lvalue reference type, return it.
- if (const LValueReferenceType *RTy = dyn_cast<LValueReferenceType>(this))
- return RTy;
-
- // If the canonical form of this type isn't the right kind, reject it.
- if (!isa<LValueReferenceType>(CanonicalType)) {
- // Look through type qualifiers
- if (isa<LValueReferenceType>(CanonicalType.getUnqualifiedType()))
- return CanonicalType.getUnqualifiedType()->getAsLValueReferenceType();
- return 0;
- }
-
- // If this is a typedef for an lvalue reference type, strip the typedef off
- // without losing all typedef information.
- return cast<LValueReferenceType>(getDesugaredType());
-}
-
-const RValueReferenceType *Type::getAsRValueReferenceType() const {
- // If this is directly an rvalue reference type, return it.
- if (const RValueReferenceType *RTy = dyn_cast<RValueReferenceType>(this))
- return RTy;
-
- // If the canonical form of this type isn't the right kind, reject it.
- if (!isa<RValueReferenceType>(CanonicalType)) {
- // Look through type qualifiers
- if (isa<RValueReferenceType>(CanonicalType.getUnqualifiedType()))
- return CanonicalType.getUnqualifiedType()->getAsRValueReferenceType();
- return 0;
- }
-
- // If this is a typedef for an rvalue reference type, strip the typedef off
- // without losing all typedef information.
- return cast<RValueReferenceType>(getDesugaredType());
-}
-
-const MemberPointerType *Type::getAsMemberPointerType() const {
- // If this is directly a member pointer type, return it.
- if (const MemberPointerType *MTy = dyn_cast<MemberPointerType>(this))
- return MTy;
-
- // If the canonical form of this type isn't the right kind, reject it.
- if (!isa<MemberPointerType>(CanonicalType)) {
- // Look through type qualifiers
- if (isa<MemberPointerType>(CanonicalType.getUnqualifiedType()))
- return CanonicalType.getUnqualifiedType()->getAsMemberPointerType();
- return 0;
- }
-
- // If this is a typedef for a member pointer type, strip the typedef off
- // without losing all typedef information.
- return cast<MemberPointerType>(getDesugaredType());
-}
-
/// isVariablyModifiedType (C99 6.7.5p3) - Return true for variable length
/// array types and types that contain variable array types in their
/// declarator
return PT->getPointeeType()->isVariablyModifiedType();
if (const ReferenceType *RT = getAs<ReferenceType>())
return RT->getPointeeType()->isVariablyModifiedType();
- if (const MemberPointerType *PT = getAsMemberPointerType())
+ if (const MemberPointerType *PT = getAs<MemberPointerType>())
return PT->getPointeeType()->isVariablyModifiedType();
// A function can return a variably modified type
return false;
}
-const RecordType *Type::getAsRecordType() const {
- // If this is directly a record type, return it.
- if (const RecordType *RTy = dyn_cast<RecordType>(this))
- return RTy;
-
- // If the canonical form of this type isn't the right kind, reject it.
- if (!isa<RecordType>(CanonicalType)) {
- // Look through type qualifiers
- if (isa<RecordType>(CanonicalType.getUnqualifiedType()))
- return CanonicalType.getUnqualifiedType()->getAsRecordType();
- return 0;
- }
-
- // If this is a typedef for a record type, strip the typedef off without
- // losing all typedef information.
- return cast<RecordType>(getDesugaredType());
-}
-
-const TagType *Type::getAsTagType() const {
- // If this is directly a tag type, return it.
- if (const TagType *TagTy = dyn_cast<TagType>(this))
- return TagTy;
-
- // If the canonical form of this type isn't the right kind, reject it.
- if (!isa<TagType>(CanonicalType)) {
- // Look through type qualifiers
- if (isa<TagType>(CanonicalType.getUnqualifiedType()))
- return CanonicalType.getUnqualifiedType()->getAsTagType();
- return 0;
- }
-
- // If this is a typedef for a tag type, strip the typedef off without
- // losing all typedef information.
- return cast<TagType>(getDesugaredType());
-}
-
const RecordType *Type::getAsStructureType() const {
// If this is directly a structure type, return it.
if (const RecordType *RT = dyn_cast<RecordType>(this)) {
QualType T = R->getValueType(getContext());
assert(T->isStructureType());
- const RecordType* RT = T->getAsRecordType();
+ const RecordType* RT = T->getAs<RecordType>();
RecordDecl* RD = RT->getDecl();
if (!RD->isDefinition())
}
static bool IsCompleteType(ASTContext &Ctx, QualType Ty) {
- if (const RecordType *RT = Ty->getAsRecordType()) {
+ if (const RecordType *RT = Ty->getAs<RecordType>()) {
const RecordDecl *D = RT->getDecl();
if (!D->getDefinition(Ctx))
return false;
assert(Dest && "Must have a destination!");
const CXXRecordDecl *RD =
- cast<CXXRecordDecl>(E->getType()->getAsRecordType()->getDecl());
+ cast<CXXRecordDecl>(E->getType()->getAs<RecordType>()->getDecl());
if (RD->hasTrivialConstructor())
return;
} else {
if (CGF.getContext().getLangOptions().NeXTRuntime) {
QualType LHSTy = E->getLHS()->getType();
- if (const RecordType *FDTTy = LHSTy.getTypePtr()->getAsRecordType())
+ if (const RecordType *FDTTy = LHSTy.getTypePtr()->getAs<RecordType>())
if (FDTTy->getDecl()->hasObjectMember()) {
LValue RHS = CGF.EmitLValue(E->getRHS());
CGF.CGM.getObjCRuntime().EmitGCMemmoveCollectable(CGF, LHS.getAddress(),
// the disadvantage is that the generated code is more difficult for
// the optimizer, especially with bitfields.
unsigned NumInitElements = E->getNumInits();
- RecordDecl *SD = E->getType()->getAsRecordType()->getDecl();
+ RecordDecl *SD = E->getType()->getAs<RecordType>()->getDecl();
unsigned CurInitVal = 0;
if (E->getType()->isUnionType()) {
llvm::Constant *EmitStructInitialization(InitListExpr *ILE) {
const llvm::StructType *SType =
cast<llvm::StructType>(ConvertType(ILE->getType()));
- RecordDecl *RD = ILE->getType()->getAsRecordType()->getDecl();
+ RecordDecl *RD = ILE->getType()->getAs<RecordType>()->getDecl();
std::vector<llvm::Constant*> Elts;
// Initialize the whole structure to zero.
#ifndef NDEBUG
// Make sure that it's really an empty and not a failure of
// semantic analysis.
- RecordDecl *RD = ILE->getType()->getAsRecordType()->getDecl();
+ RecordDecl *RD = ILE->getType()->getAs<RecordType>()->getDecl();
for (RecordDecl::field_iterator Field = RD->field_begin(),
FieldEnd = RD->field_end();
Field != FieldEnd; ++Field)
if (FQT->isUnionType())
HasUnion = true;
- BuildAggrIvarRecordLayout(FQT->getAsRecordType(),
+ BuildAggrIvarRecordLayout(FQT->getAs<RecordType>(),
BytePos + FieldOffset,
ForStrongLayout, HasUnion);
continue;
int OldIndex = IvarsInfo.size() - 1;
int OldSkIndex = SkipIvars.size() -1;
- const RecordType *RT = FQT->getAsRecordType();
+ const RecordType *RT = FQT->getAs<RecordType>();
BuildAggrIvarRecordLayout(RT, BytePos + FieldOffset,
ForStrongLayout, HasUnion);
/// getCGRecordLayout - Return record layout info.
const CGRecordLayout *CodeGenFunction::getCGRecordLayout(CodeGenTypes &CGT,
QualType Ty) {
- const RecordType *RTy = Ty->getAsRecordType();
+ const RecordType *RTy = Ty->getAs<RecordType>();
assert (RTy && "Unexpected type. RecordType expected here.");
return CGT.getCGRecordLayout(RTy->getDecl());
}
QualType CFTy = getContext().getCFConstantStringType();
- RecordDecl *CFRD = CFTy->getAsRecordType()->getDecl();
+ RecordDecl *CFRD = CFTy->getAs<RecordType>()->getDecl();
const llvm::StructType *STy =
cast<llvm::StructType>(getTypes().ConvertType(CFTy));
// and all of the argument types are complete.
static const TagType *VerifyFuncTypeComplete(const Type* T) {
const FunctionType *FT = cast<FunctionType>(T);
- if (const TagType* TT = FT->getResultType()->getAsTagType())
+ if (const TagType* TT = FT->getResultType()->getAs<TagType>())
if (!TT->getDecl()->isDefinition())
return TT;
if (const FunctionProtoType *FPT = dyn_cast<FunctionProtoType>(T))
for (unsigned i = 0; i < FPT->getNumArgs(); i++)
- if (const TagType* TT = FPT->getArgType(i)->getAsTagType())
+ if (const TagType* TT = FPT->getArgType(i)->getAs<TagType>())
if (!TT->getDecl()->isDefinition())
return TT;
return 0;
/// fields. Note that a structure with a flexible array member is not
/// considered empty.
static bool isEmptyRecord(ASTContext &Context, QualType T) {
- const RecordType *RT = T->getAsRecordType();
+ const RecordType *RT = T->getAs<RecordType>();
if (!RT)
return 0;
const RecordDecl *RD = RT->getDecl();
Context.getTypeSize(FD->getType()) >= 128)
return true;
- if (const RecordType* RT = FD->getType()->getAsRecordType())
+ if (const RecordType* RT = FD->getType()->getAs<RecordType>())
if (typeContainsSSEVector(RT->getDecl(), Context))
return true;
}
return shouldReturnTypeInRegister(AT->getElementType(), Context);
// Otherwise, it must be a record type.
- const RecordType *RT = Ty->getAsRecordType();
+ const RecordType *RT = Ty->getAs<RecordType>();
if (!RT) return false;
// Structure types are passed in register if all fields would be
ASTContext &Context) {
unsigned Align = Context.getTypeAlign(Ty);
if (Align < 128) return 0;
- if (const RecordType* RT = Ty->getAsRecordType())
+ if (const RecordType* RT = Ty->getAs<RecordType>())
if (typeContainsSSEVector(RT->getDecl(), Context))
return 16;
return 0;
if (Hi == Memory)
Lo = Memory;
assert((Hi != SSEUp || Lo == SSE) && "Invalid SSEUp array classification.");
- } else if (const RecordType *RT = Ty->getAsRecordType()) {
+ } else if (const RecordType *RT = Ty->getAs<RecordType>()) {
uint64_t Size = Context.getTypeSize(Ty);
// AMD64-ABI 3.2.3p2: Rule 1. If the size of an object is larger
if (const TypedefType *Typedef = FileType->getAsTypedefType())
Context->setFILEDecl(Typedef->getDecl());
else {
- const TagType *Tag = FileType->getAsTagType();
+ const TagType *Tag = FileType->getAs<TagType>();
assert(Tag && "Invalid FILE type in PCH file");
Context->setFILEDecl(Tag->getDecl());
}
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;
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;
IdResolver.AddDecl(*F);
}
} else if (const RecordType *InnerRecordType
- = (*F)->getType()->getAsRecordType()) {
+ = (*F)->getType()->getAs<RecordType>()) {
RecordDecl *InnerRecord = InnerRecordType->getDecl();
if (InnerRecord->isAnonymousStructOrUnion())
Invalid = Invalid ||
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))
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()) {
if (!PT)
return false;
- const RecordType *RT = PT->getPointeeType()->getAsRecordType();
+ const RecordType *RT = PT->getPointeeType()->getAs<RecordType>();
if (!RT)
return false;
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");
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) {
// 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(),
// 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);
CurrentRD);
}
- const RecordType *RT = T->getAsRecordType();
+ const RecordType *RT = T->getAs<RecordType>();
if (!RT)
return false;
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())
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);
}
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
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);
}
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
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))
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()) {
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)))
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()) {
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);
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 =
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);
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 =
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)))
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:
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
// 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,
<< 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) {
// 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.
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)
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;
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
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,
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,
} 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() &&
// 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();
// 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))) {
// 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;
}
Sema::OwningExprResult Sema::MaybeBindToTemporary(Expr *E) {
- const RecordType *RT = E->getType()->getAsRecordType();
+ const RecordType *RT = E->getType()->getAs<RecordType>();
if (!RT)
return Owned(E);
return false;
Paths.setOrigin(Derived);
- return LookupInBases(cast<CXXRecordDecl>(Derived->getAsRecordType()->getDecl()),
+ return LookupInBases(cast<CXXRecordDecl>(Derived->getAs<RecordType>()->getDecl()),
MemberLookupCriteria(Base), Paths);
}
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
}
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
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.
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(),
}
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(),
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,
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.
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()) {
// 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()) {
// 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())
}
} 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;
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
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.
// 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,
// 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,
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,
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)
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)
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();
// 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
{
// 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;
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;
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) {
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,
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;
}
// Otherwise, both types have to be member pointers.
- const MemberPointerType *FromTypePtr = FromType->getAsMemberPointerType();
+ const MemberPointerType *FromTypePtr = FromType->getAs<MemberPointerType>();
if (!FromTypePtr)
return false;
/// 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.");
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:
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.
// (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)
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.
// 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) {
} 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
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;
}
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;
}
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
// 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)
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)
// 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())) {
// T &
case Type::LValueReference: {
- const LValueReferenceType *ReferenceArg = Arg->getAsLValueReferenceType();
+ const LValueReferenceType *ReferenceArg = Arg->getAs<LValueReferenceType>();
if (!ReferenceArg)
return Sema::TDK_NonDeducedMismatch;
// T && [C++0x]
case Type::RValueReference: {
- const RValueReferenceType *ReferenceArg = Arg->getAsRValueReferenceType();
+ const RValueReferenceType *ReferenceArg = Arg->getAs<RValueReferenceType>();
if (!ReferenceArg)
return Sema::TDK_NonDeducedMismatch;
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>());
}
}
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".
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())
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;
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())) {
// 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) {
// 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;