From: Ted Kremenek Date: Fri, 17 Jul 2009 01:20:38 +0000 (+0000) Subject: Replaced Type::getAsLValueReferenceType(), Type::getAsRValueReferenceType(), Type... X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=5cad1f74469d4d8b4fc51fe53a7837778aeb6107;p=clang Replaced Type::getAsLValueReferenceType(), Type::getAsRValueReferenceType(), Type::getAsMemberPointerType(), Type::getAsTagType(), and Type::getAsRecordType() with their Type::getAs equivalents. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@76139 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/Type.h b/include/clang/AST/Type.h index d1bf6929f6..5099c61819 100644 --- a/include/clang/AST/Type.h +++ b/include/clang/AST/Type.h @@ -431,11 +431,6 @@ public: 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; @@ -2152,7 +2147,7 @@ inline bool Type::isMemberPointerType() const { return isa(CanonicalType.getUnqualifiedType()); } inline bool Type::isMemberFunctionPointerType() const { - if (const MemberPointerType* T = getAsMemberPointerType()) + if (const MemberPointerType* T = getAs()) return T->getPointeeType()->isFunctionType(); else return false; diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp index dcb18cb91d..f37ffddc12 100644 --- a/lib/AST/ASTContext.cpp +++ b/lib/AST/ASTContext.cpp @@ -2462,7 +2462,7 @@ QualType ASTContext::getCFConstantStringType() { } void ASTContext::setCFConstantStringType(QualType T) { - const RecordType *Rec = T->getAsRecordType(); + const RecordType *Rec = T->getAs(); assert(Rec && "Invalid CFConstantStringType"); CFConstantStringTypeDecl = Rec->getDecl(); } @@ -2498,7 +2498,7 @@ QualType ASTContext::getObjCFastEnumerationStateType() } void ASTContext::setObjCFastEnumerationStateType(QualType T) { - const RecordType *Rec = T->getAsRecordType(); + const RecordType *Rec = T->getAs(); assert(Rec && "Invalid ObjCFAstEnumerationStateType"); ObjCFastEnumerationStateTypeDecl = Rec->getDecl(); } @@ -2866,7 +2866,7 @@ void ASTContext::getObjCEncodingForTypeImpl(QualType T, std::string& S, return; } - if (const RecordType *RTy = T->getAsRecordType()) { + if (const RecordType *RTy = T->getAs()) { RecordDecl *RDecl = RTy->getDecl(); S += RDecl->isUnion() ? '(' : '{'; // Anonymous structures print as '?' diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp index 728724f1b3..a9f258146e 100644 --- a/lib/AST/Decl.cpp +++ b/lib/AST/Decl.cpp @@ -157,7 +157,7 @@ bool FieldDecl::isAnonymousStructOrUnion() const { if (!isImplicit() || getDeclName()) return false; - if (const RecordType *Record = getType()->getAsRecordType()) + if (const RecordType *Record = getType()->getAs()) return Record->getDecl()->isAnonymousStructOrUnion(); return false; @@ -704,24 +704,24 @@ SourceRange TagDecl::getSourceRange() const { } void TagDecl::startDefinition() { - TagType *TagT = const_cast(TypeForDecl->getAsTagType()); + TagType *TagT = const_cast(TypeForDecl->getAs()); TagT->decl.setPointer(this); - TagT->getAsTagType()->decl.setInt(1); + TagT->getAs()->decl.setInt(1); } void TagDecl::completeDefinition() { assert((!TypeForDecl || - TypeForDecl->getAsTagType()->decl.getPointer() == this) && + TypeForDecl->getAs()->decl.getPointer() == this) && "Attempt to redefine a tag definition?"); IsDefinition = true; - TagType *TagT = const_cast(TypeForDecl->getAsTagType()); + TagType *TagT = const_cast(TypeForDecl->getAs()); TagT->decl.setPointer(this); TagT->decl.setInt(0); } TagDecl* TagDecl::getDefinition(ASTContext& C) const { QualType T = C.getTypeDeclType(const_cast(this)); - TagDecl* D = cast(T->getAsTagType()->getDecl()); + TagDecl* D = cast(T->getAs()->getDecl()); return D->isDefinition() ? D : 0; } diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp index 96ba19b9a6..2d276614f2 100644 --- a/lib/AST/DeclBase.cpp +++ b/lib/AST/DeclBase.cpp @@ -473,7 +473,7 @@ DeclContext *DeclContext::getPrimaryContext() { 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(this)->TypeForDecl->getAsTagType()) + if (const TagType *TagT =cast(this)->TypeForDecl->getAs()) if (TagT->isBeingDefined() || (TagT->getDecl() && TagT->getDecl()->isDefinition())) return TagT->getDecl(); diff --git a/lib/AST/DeclCXX.cpp b/lib/AST/DeclCXX.cpp index 57ac611b2c..f420da14e4 100644 --- a/lib/AST/DeclCXX.cpp +++ b/lib/AST/DeclCXX.cpp @@ -81,7 +81,7 @@ CXXRecordDecl::setBases(ASTContext &C, if (BaseType->isDependentType()) continue; CXXRecordDecl *BaseClassDecl - = cast(BaseType->getAsRecordType()->getDecl()); + = cast(BaseType->getAs()->getDecl()); if (Base->isVirtual()) hasDirectVirtualBase = true; for (CXXRecordDecl::base_class_iterator VBase = @@ -125,7 +125,7 @@ CXXRecordDecl::setBases(ASTContext &C, for (int i = 0; i < vbaseCount; i++) { QualType QT = UniqueVbases[i]->getType(); CXXRecordDecl *VBaseClassDecl - = cast(QT->getAsRecordType()->getDecl()); + = cast(QT->getAs()->getDecl()); this->VBases[i] = *new CXXBaseSpecifier( VBaseClassDecl->getSourceRange(), true, @@ -185,7 +185,7 @@ bool CXXRecordDecl::hasConstCopyAssignment(ASTContext &Context) const { continue; bool AcceptsConst = true; QualType ArgType = FnType->getArgType(0); - if (const LValueReferenceType *Ref = ArgType->getAsLValueReferenceType()) { + if (const LValueReferenceType *Ref = ArgType->getAs()) { ArgType = Ref->getPointeeType(); // Is it a non-const lvalue reference? if (!ArgType.isConstQualified()) @@ -237,7 +237,7 @@ void CXXRecordDecl::addedAssignmentOperator(ASTContext &Context, 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()) ArgType = Ref->getPointeeType(); ArgType = ArgType.getUnqualifiedType(); @@ -433,7 +433,7 @@ CXXConstructorDecl::isCopyConstructor(ASTContext &Context, // Do we have a reference type? Rvalue references don't count. const LValueReferenceType *ParamRefType = - Param->getType()->getAsLValueReferenceType(); + Param->getType()->getAs(); if (!ParamRefType) return false; @@ -503,7 +503,7 @@ CXXDestructorDecl::setBaseOrMemberDestructions(ASTContext &C) { while (const ArrayType *AT = C.getAsArrayType(FieldType)) FieldType = AT->getElementType(); - if (FieldType->getAsRecordType()) { + if (FieldType->getAs()) { CXXBaseOrMemberInitializer *Member = new CXXBaseOrMemberInitializer((*Field), 0, 0, SourceLocation()); AllToDestruct.push_back(Member); @@ -535,12 +535,12 @@ CXXConstructorDecl::setBaseOrMemberInitializers( 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(); unsigned int i = 0; for (i = 0; i < NumInitializers; i++) { CXXBaseOrMemberInitializer *Member = Initializers[i]; if (Member->isBaseInitializer() && - Member->getBaseClass()->getAsRecordType() == T) { + Member->getBaseClass()->getAs() == T) { AllToInit.push_back(Member); break; } @@ -557,12 +557,12 @@ CXXConstructorDecl::setBaseOrMemberInitializers( // 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(); unsigned int i = 0; for (i = 0; i < NumInitializers; i++) { CXXBaseOrMemberInitializer *Member = Initializers[i]; if (Member->isBaseInitializer() && - Member->getBaseClass()->getAsRecordType() == T) { + Member->getBaseClass()->getAs() == T) { AllToInit.push_back(Member); break; } @@ -589,7 +589,7 @@ CXXConstructorDecl::setBaseOrMemberInitializers( while (const ArrayType *AT = C.getAsArrayType(FieldType)) FieldType = AT->getElementType(); - if (FieldType->getAsRecordType()) { + if (FieldType->getAs()) { CXXBaseOrMemberInitializer *Member = new CXXBaseOrMemberInitializer((*Field), 0, 0, SourceLocation()); AllToInit.push_back(Member); diff --git a/lib/AST/DeclPrinter.cpp b/lib/AST/DeclPrinter.cpp index 55d39e5cc8..1711a7cf56 100644 --- a/lib/AST/DeclPrinter.cpp +++ b/lib/AST/DeclPrinter.cpp @@ -353,7 +353,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { } else // FIXME. skip dependent types for now. if (const RecordType *RT = - BMInitializer->getBaseClass()->getAsRecordType()) { + BMInitializer->getBaseClass()->getAs()) { const CXXRecordDecl *BaseDecl = cast(RT->getDecl()); Out << BaseDecl->getNameAsString(); @@ -394,7 +394,7 @@ void DeclPrinter::VisitFunctionDecl(FunctionDecl *D) { } else // FIXME. skip dependent types for now. if (const RecordType *RT = - BMInitializer->getBaseClass()->getAsRecordType()) { + BMInitializer->getBaseClass()->getAs()) { const CXXRecordDecl *BaseDecl = cast(RT->getDecl()); Proto += "~"; diff --git a/lib/AST/DeclarationName.cpp b/lib/AST/DeclarationName.cpp index a17abde777..a55b363a0d 100644 --- a/lib/AST/DeclarationName.cpp +++ b/lib/AST/DeclarationName.cpp @@ -135,7 +135,7 @@ std::string DeclarationName::getAsString() const { case CXXConstructorName: { QualType ClassType = getCXXNameType(); - if (const RecordType *ClassRec = ClassType->getAsRecordType()) + if (const RecordType *ClassRec = ClassType->getAs()) return ClassRec->getDecl()->getNameAsString(); return ClassType.getAsString(); } @@ -143,7 +143,7 @@ std::string DeclarationName::getAsString() const { case CXXDestructorName: { std::string Result = "~"; QualType Type = getCXXNameType(); - if (const RecordType *Rec = Type->getAsRecordType()) + if (const RecordType *Rec = Type->getAs()) Result += Rec->getDecl()->getNameAsString(); else Result += Type.getAsString(); @@ -170,7 +170,7 @@ std::string DeclarationName::getAsString() const { case CXXConversionFunctionName: { std::string Result = "operator "; QualType Type = getCXXNameType(); - if (const RecordType *Rec = Type->getAsRecordType()) + if (const RecordType *Rec = Type->getAs()) Result += Rec->getDecl()->getNameAsString(); else Result += Type.getAsString(); diff --git a/lib/AST/Expr.cpp b/lib/AST/Expr.cpp index 74928bcd76..63a6d3153c 100644 --- a/lib/AST/Expr.cpp +++ b/lib/AST/Expr.cpp @@ -915,7 +915,7 @@ Expr::isModifiableLvalue(ASTContext &Ctx, SourceLocation *Loc) const { if (CT->isIncompleteType()) return MLV_IncompleteType; - if (const RecordType *r = CT->getAsRecordType()) { + if (const RecordType *r = CT->getAs()) { if (r->hasConstFields()) return MLV_ConstQualified; } diff --git a/lib/AST/ExprCXX.cpp b/lib/AST/ExprCXX.cpp index 399c30255a..d5cfef23f8 100644 --- a/lib/AST/ExprCXX.cpp +++ b/lib/AST/ExprCXX.cpp @@ -219,28 +219,28 @@ bool UnaryTypeTraitExpr::EvaluateTrait() const { 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()) { 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()) { // Type traits are only parsed in C++, so we've got CXXRecords. return cast(Record->getDecl())->isPolymorphic(); } return false; case UTT_IsAbstract: - if (const RecordType *RT = QueriedType->getAsRecordType()) + if (const RecordType *RT = QueriedType->getAs()) return cast(RT->getDecl())->isAbstract(); return false; case UTT_HasTrivialConstructor: - if (const RecordType *RT = QueriedType->getAsRecordType()) + if (const RecordType *RT = QueriedType->getAs()) return cast(RT->getDecl())->hasTrivialConstructor(); return false; case UTT_HasTrivialDestructor: - if (const RecordType *RT = QueriedType->getAsRecordType()) + if (const RecordType *RT = QueriedType->getAs()) return cast(RT->getDecl())->hasTrivialDestructor(); return false; } diff --git a/lib/AST/ExprConstant.cpp b/lib/AST/ExprConstant.cpp index 9473e4f48c..d01130372c 100644 --- a/lib/AST/ExprConstant.cpp +++ b/lib/AST/ExprConstant.cpp @@ -230,7 +230,7 @@ APValue LValueExprEvaluator::VisitMemberExpr(MemberExpr *E) { Ty = E->getBase()->getType(); } - RecordDecl *RD = Ty->getAsRecordType()->getDecl(); + RecordDecl *RD = Ty->getAs()->getDecl(); const ASTRecordLayout &RL = Info.Ctx.getASTRecordLayout(RD); FieldDecl *FD = dyn_cast(E->getMemberDecl()); diff --git a/lib/AST/InheritViz.cpp b/lib/AST/InheritViz.cpp index 1188ba5860..3e5dd1a53f 100644 --- a/lib/AST/InheritViz.cpp +++ b/lib/AST/InheritViz.cpp @@ -90,7 +90,7 @@ void InheritanceHierarchyWriter::WriteNode(QualType Type, bool FromVirtual) { // Display the base classes. const CXXRecordDecl *Decl - = static_cast(Type->getAsRecordType()->getDecl()); + = static_cast(Type->getAs()->getDecl()); for (CXXRecordDecl::base_class_const_iterator Base = Decl->bases_begin(); Base != Decl->bases_end(); ++Base) { QualType CanonBaseType = Context.getCanonicalType(Base->getType()); diff --git a/lib/AST/Type.cpp b/lib/AST/Type.cpp index 28c3a8f42a..6114dba148 100644 --- a/lib/AST/Type.cpp +++ b/lib/AST/Type.cpp @@ -192,12 +192,12 @@ bool Type::isDerivedType() const { } bool Type::isClassType() const { - if (const RecordType *RT = getAsRecordType()) + if (const RecordType *RT = getAs()) return RT->getDecl()->isClass(); return false; } bool Type::isStructureType() const { - if (const RecordType *RT = getAsRecordType()) + if (const RecordType *RT = getAs()) return RT->getDecl()->isStruct(); return false; } @@ -208,7 +208,7 @@ bool Type::isVoidPointerType() const { } bool Type::isUnionType() const { - if (const RecordType *RT = getAsRecordType()) + if (const RecordType *RT = getAs()) return RT->getDecl()->isUnion(); return false; } @@ -305,60 +305,6 @@ QualType Type::getPointeeType() const { return QualType(); } -const LValueReferenceType *Type::getAsLValueReferenceType() const { - // If this is directly an lvalue reference type, return it. - if (const LValueReferenceType *RTy = dyn_cast(this)) - return RTy; - - // If the canonical form of this type isn't the right kind, reject it. - if (!isa(CanonicalType)) { - // Look through type qualifiers - if (isa(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(getDesugaredType()); -} - -const RValueReferenceType *Type::getAsRValueReferenceType() const { - // If this is directly an rvalue reference type, return it. - if (const RValueReferenceType *RTy = dyn_cast(this)) - return RTy; - - // If the canonical form of this type isn't the right kind, reject it. - if (!isa(CanonicalType)) { - // Look through type qualifiers - if (isa(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(getDesugaredType()); -} - -const MemberPointerType *Type::getAsMemberPointerType() const { - // If this is directly a member pointer type, return it. - if (const MemberPointerType *MTy = dyn_cast(this)) - return MTy; - - // If the canonical form of this type isn't the right kind, reject it. - if (!isa(CanonicalType)) { - // Look through type qualifiers - if (isa(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(getDesugaredType()); -} - /// isVariablyModifiedType (C99 6.7.5p3) - Return true for variable length /// array types and types that contain variable array types in their /// declarator @@ -379,7 +325,7 @@ bool Type::isVariablyModifiedType() const { return PT->getPointeeType()->isVariablyModifiedType(); if (const ReferenceType *RT = getAs()) return RT->getPointeeType()->isVariablyModifiedType(); - if (const MemberPointerType *PT = getAsMemberPointerType()) + if (const MemberPointerType *PT = getAs()) return PT->getPointeeType()->isVariablyModifiedType(); // A function can return a variably modified type @@ -392,42 +338,6 @@ bool Type::isVariablyModifiedType() const { return false; } -const RecordType *Type::getAsRecordType() const { - // If this is directly a record type, return it. - if (const RecordType *RTy = dyn_cast(this)) - return RTy; - - // If the canonical form of this type isn't the right kind, reject it. - if (!isa(CanonicalType)) { - // Look through type qualifiers - if (isa(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(getDesugaredType()); -} - -const TagType *Type::getAsTagType() const { - // If this is directly a tag type, return it. - if (const TagType *TagTy = dyn_cast(this)) - return TagTy; - - // If the canonical form of this type isn't the right kind, reject it. - if (!isa(CanonicalType)) { - // Look through type qualifiers - if (isa(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(getDesugaredType()); -} - const RecordType *Type::getAsStructureType() const { // If this is directly a structure type, return it. if (const RecordType *RT = dyn_cast(this)) { diff --git a/lib/Analysis/RegionStore.cpp b/lib/Analysis/RegionStore.cpp index 31623b9983..f956ecab7f 100644 --- a/lib/Analysis/RegionStore.cpp +++ b/lib/Analysis/RegionStore.cpp @@ -1201,7 +1201,7 @@ RegionStoreManager::BindStruct(const GRState *state, const TypedRegion* R, QualType T = R->getValueType(getContext()); assert(T->isStructureType()); - const RecordType* RT = T->getAsRecordType(); + const RecordType* RT = T->getAs(); RecordDecl* RD = RT->getDecl(); if (!RD->isDefinition()) diff --git a/lib/Analysis/Store.cpp b/lib/Analysis/Store.cpp index 9147f93eda..66b99a85a3 100644 --- a/lib/Analysis/Store.cpp +++ b/lib/Analysis/Store.cpp @@ -36,7 +36,7 @@ StoreManager::MakeElementRegion(const GRState *state, const MemRegion *region, } static bool IsCompleteType(ASTContext &Ctx, QualType Ty) { - if (const RecordType *RT = Ty->getAsRecordType()) { + if (const RecordType *RT = Ty->getAs()) { const RecordDecl *D = RT->getDecl(); if (!D->getDefinition(Ctx)) return false; diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp index 07f387f83f..9031caf505 100644 --- a/lib/CodeGen/CGCXX.cpp +++ b/lib/CodeGen/CGCXX.cpp @@ -179,7 +179,7 @@ CodeGenFunction::EmitCXXConstructExpr(llvm::Value *Dest, assert(Dest && "Must have a destination!"); const CXXRecordDecl *RD = - cast(E->getType()->getAsRecordType()->getDecl()); + cast(E->getType()->getAs()->getDecl()); if (RD->hasTrivialConstructor()) return; diff --git a/lib/CodeGen/CGExprAgg.cpp b/lib/CodeGen/CGExprAgg.cpp index e4192d66f3..58be86d2cb 100644 --- a/lib/CodeGen/CGExprAgg.cpp +++ b/lib/CodeGen/CGExprAgg.cpp @@ -253,7 +253,7 @@ void AggExprEmitter::VisitBinAssign(const BinaryOperator *E) { } 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()) if (FDTTy->getDecl()->hasObjectMember()) { LValue RHS = CGF.EmitLValue(E->getRHS()); CGF.CGM.getObjCRuntime().EmitGCMemmoveCollectable(CGF, LHS.getAddress(), @@ -441,7 +441,7 @@ void AggExprEmitter::VisitInitListExpr(InitListExpr *E) { // 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()->getDecl(); unsigned CurInitVal = 0; if (E->getType()->isUnionType()) { diff --git a/lib/CodeGen/CGExprConstant.cpp b/lib/CodeGen/CGExprConstant.cpp index 4f1f58fefd..dea207cc72 100644 --- a/lib/CodeGen/CGExprConstant.cpp +++ b/lib/CodeGen/CGExprConstant.cpp @@ -188,7 +188,7 @@ public: llvm::Constant *EmitStructInitialization(InitListExpr *ILE) { const llvm::StructType *SType = cast(ConvertType(ILE->getType())); - RecordDecl *RD = ILE->getType()->getAsRecordType()->getDecl(); + RecordDecl *RD = ILE->getType()->getAs()->getDecl(); std::vector Elts; // Initialize the whole structure to zero. @@ -264,7 +264,7 @@ public: #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()->getDecl(); for (RecordDecl::field_iterator Field = RD->field_begin(), FieldEnd = RD->field_end(); Field != FieldEnd; ++Field) diff --git a/lib/CodeGen/CGObjCMac.cpp b/lib/CodeGen/CGObjCMac.cpp index bb80be961b..02516d7608 100644 --- a/lib/CodeGen/CGObjCMac.cpp +++ b/lib/CodeGen/CGObjCMac.cpp @@ -3072,7 +3072,7 @@ void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCImplementationDecl *OI, if (FQT->isUnionType()) HasUnion = true; - BuildAggrIvarRecordLayout(FQT->getAsRecordType(), + BuildAggrIvarRecordLayout(FQT->getAs(), BytePos + FieldOffset, ForStrongLayout, HasUnion); continue; @@ -3097,7 +3097,7 @@ void CGObjCCommonMac::BuildAggrIvarLayout(const ObjCImplementationDecl *OI, int OldIndex = IvarsInfo.size() - 1; int OldSkIndex = SkipIvars.size() -1; - const RecordType *RT = FQT->getAsRecordType(); + const RecordType *RT = FQT->getAs(); BuildAggrIvarRecordLayout(RT, BytePos + FieldOffset, ForStrongLayout, HasUnion); diff --git a/lib/CodeGen/CodeGenFunction.cpp b/lib/CodeGen/CodeGenFunction.cpp index 842bf8be49..250ccce3cd 100644 --- a/lib/CodeGen/CodeGenFunction.cpp +++ b/lib/CodeGen/CodeGenFunction.cpp @@ -380,7 +380,7 @@ void CodeGenFunction::EmitBranchOnBoolExpr(const Expr *Cond, /// getCGRecordLayout - Return record layout info. const CGRecordLayout *CodeGenFunction::getCGRecordLayout(CodeGenTypes &CGT, QualType Ty) { - const RecordType *RTy = Ty->getAsRecordType(); + const RecordType *RTy = Ty->getAs(); assert (RTy && "Unexpected type. RecordType expected here."); return CGT.getCGRecordLayout(RTy->getDecl()); diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index d502d79d29..adc88a026b 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -1251,7 +1251,7 @@ GetAddrOfConstantCFString(const StringLiteral *Literal) { } QualType CFTy = getContext().getCFConstantStringType(); - RecordDecl *CFRD = CFTy->getAsRecordType()->getDecl(); + RecordDecl *CFRD = CFTy->getAs()->getDecl(); const llvm::StructType *STy = cast(getTypes().ConvertType(CFTy)); diff --git a/lib/CodeGen/CodeGenTypes.cpp b/lib/CodeGen/CodeGenTypes.cpp index e97cbbd66c..2117e6d5b4 100644 --- a/lib/CodeGen/CodeGenTypes.cpp +++ b/lib/CodeGen/CodeGenTypes.cpp @@ -142,12 +142,12 @@ const llvm::Type *CodeGenTypes::ConvertTypeForMem(QualType T) { // and all of the argument types are complete. static const TagType *VerifyFuncTypeComplete(const Type* T) { const FunctionType *FT = cast(T); - if (const TagType* TT = FT->getResultType()->getAsTagType()) + if (const TagType* TT = FT->getResultType()->getAs()) if (!TT->getDecl()->isDefinition()) return TT; if (const FunctionProtoType *FPT = dyn_cast(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()) if (!TT->getDecl()->isDefinition()) return TT; return 0; diff --git a/lib/CodeGen/TargetABIInfo.cpp b/lib/CodeGen/TargetABIInfo.cpp index c3f35453ba..7063327d3a 100644 --- a/lib/CodeGen/TargetABIInfo.cpp +++ b/lib/CodeGen/TargetABIInfo.cpp @@ -68,7 +68,7 @@ static bool isEmptyField(ASTContext &Context, const FieldDecl *FD) { /// 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(); if (!RT) return 0; const RecordDecl *RD = RT->getDecl(); @@ -168,7 +168,7 @@ static bool typeContainsSSEVector(const RecordDecl *RD, ASTContext &Context) { Context.getTypeSize(FD->getType()) >= 128) return true; - if (const RecordType* RT = FD->getType()->getAsRecordType()) + if (const RecordType* RT = FD->getType()->getAs()) if (typeContainsSSEVector(RT->getDecl(), Context)) return true; } @@ -272,7 +272,7 @@ bool X86_32ABIInfo::shouldReturnTypeInRegister(QualType Ty, return shouldReturnTypeInRegister(AT->getElementType(), Context); // Otherwise, it must be a record type. - const RecordType *RT = Ty->getAsRecordType(); + const RecordType *RT = Ty->getAs(); if (!RT) return false; // Structure types are passed in register if all fields would be @@ -385,7 +385,7 @@ unsigned X86_32ABIInfo::getIndirectArgumentAlignment(QualType Ty, ASTContext &Context) { unsigned Align = Context.getTypeAlign(Ty); if (Align < 128) return 0; - if (const RecordType* RT = Ty->getAsRecordType()) + if (const RecordType* RT = Ty->getAs()) if (typeContainsSSEVector(RT->getDecl(), Context)) return 16; return 0; @@ -704,7 +704,7 @@ void X86_64ABIInfo::classify(QualType Ty, 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()) { uint64_t Size = Context.getTypeSize(Ty); // AMD64-ABI 3.2.3p2: Rule 1. If the size of an object is larger diff --git a/lib/Frontend/PCHReader.cpp b/lib/Frontend/PCHReader.cpp index 8c26607b7c..fef2097773 100644 --- a/lib/Frontend/PCHReader.cpp +++ b/lib/Frontend/PCHReader.cpp @@ -1543,7 +1543,7 @@ void PCHReader::InitializeContext(ASTContext &Ctx) { if (const TypedefType *Typedef = FileType->getAsTypedefType()) Context->setFILEDecl(Typedef->getDecl()); else { - const TagType *Tag = FileType->getAsTagType(); + const TagType *Tag = FileType->getAs(); assert(Tag && "Invalid FILE type in PCH file"); Context->setFILEDecl(Tag->getDecl()); } diff --git a/lib/Sema/SemaCXXScopeSpec.cpp b/lib/Sema/SemaCXXScopeSpec.cpp index a14bcd5287..ef8a271fb5 100644 --- a/lib/Sema/SemaCXXScopeSpec.cpp +++ b/lib/Sema/SemaCXXScopeSpec.cpp @@ -46,7 +46,7 @@ DeclContext *Sema::computeDeclContext(const CXXScopeSpec &SS) { case NestedNameSpecifier::TypeSpec: case NestedNameSpecifier::TypeSpecWithTemplate: { - const TagType *Tag = NNS->getAsType()->getAsTagType(); + const TagType *Tag = NNS->getAsType()->getAs(); assert(Tag && "Non-tag type in nested-name-specifier"); return Tag->getDecl(); } break; @@ -169,7 +169,7 @@ bool Sema::RequireCompleteDeclContext(const CXXScopeSpec &SS) { if (TagDecl *Tag = dyn_cast(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(); if (TagT->isBeingDefined()) return false; diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 92afc343f3..d797c80353 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -1151,7 +1151,7 @@ bool Sema::InjectAnonymousStructOrUnionMembers(Scope *S, DeclContext *Owner, IdResolver.AddDecl(*F); } } else if (const RecordType *InnerRecordType - = (*F)->getType()->getAsRecordType()) { + = (*F)->getType()->getAs()) { RecordDecl *InnerRecord = InnerRecordType->getDecl(); if (InnerRecord->isAnonymousStructOrUnion()) Invalid = Invalid || @@ -2814,7 +2814,7 @@ void Sema::ActOnUninitializedDecl(DeclPtrTy dcl, if ((!Var->hasExternalStorage() && !Var->isExternC(Context)) && InitType->isRecordType() && !InitType->isDependentType()) { CXXRecordDecl *RD = - cast(InitType->getAsRecordType()->getDecl()); + cast(InitType->getAs()->getDecl()); CXXConstructorDecl *Constructor = 0; if (!RequireCompleteType(Var->getLocation(), InitType, diag::err_invalid_incomplete_type_use)) @@ -4237,7 +4237,7 @@ void Sema::ActOnFields(Scope* S, FD->setInvalidDecl(); EnclosingDecl->setInvalidDecl(); continue; - } else if (const RecordType *FDTTy = FDTy->getAsRecordType()) { + } else if (const RecordType *FDTTy = FDTy->getAs()) { 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 5d05b4c444..ea28796ea9 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -137,7 +137,7 @@ static inline bool isCFStringType(QualType T, ASTContext &Ctx) { if (!PT) return false; - const RecordType *RT = PT->getPointeeType()->getAsRecordType(); + const RecordType *RT = PT->getPointeeType()->getAs(); if (!RT) return false; diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index d533e63c48..fbc8a90fea 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -384,7 +384,7 @@ Sema::CheckBaseSpecifier(CXXRecordDecl *Class, return 0; // If the base class is polymorphic, the new one is, too. - RecordDecl *BaseDecl = BaseType->getAsRecordType()->getDecl(); + RecordDecl *BaseDecl = BaseType->getAs()->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 @@ void Sema::ActOnMemInitializers(DeclPtrTy ConstructorDecl, 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()); for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin(), E = ClassDecl->bases_end(); Base != E; ++Base) { @@ -841,7 +841,7 @@ void Sema::ActOnMemInitializers(DeclPtrTy ConstructorDecl, // first. if (Base->isVirtual()) continue; - AllBaseOrMembers.push_back(Base->getType()->getAsRecordType()); + AllBaseOrMembers.push_back(Base->getType()->getAs()); } for (CXXRecordDecl::field_iterator Field = ClassDecl->field_begin(), @@ -956,7 +956,7 @@ namespace { // 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()) { const CXXRecordDecl *BaseDecl = cast(RT->getDecl()); if (BaseDecl && BaseDecl->isAbstract()) Collect(BaseDecl, Methods); @@ -1019,7 +1019,7 @@ bool Sema::RequireNonAbstractType(SourceLocation Loc, QualType T, CurrentRD); } - const RecordType *RT = T->getAsRecordType(); + const RecordType *RT = T->getAs(); if (!RT) return false; @@ -1150,7 +1150,7 @@ void Sema::ActOnFinishCXXMemberSpecification(Scope* S, SourceLocation RLoc, while (const ArrayType *AT = Context.getAsArrayType(FTy)) FTy = AT->getElementType(); - if (const RecordType *RT = FTy->getAsRecordType()) { + if (const RecordType *RT = FTy->getAs()) { CXXRecordDecl *FieldRD = cast(RT->getDecl()); if (!FieldRD->hasTrivialConstructor()) @@ -1224,7 +1224,7 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) { for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin(); HasConstCopyConstructor && Base != ClassDecl->bases_end(); ++Base) { const CXXRecordDecl *BaseClassDecl - = cast(Base->getType()->getAsRecordType()->getDecl()); + = cast(Base->getType()->getAs()->getDecl()); HasConstCopyConstructor = BaseClassDecl->hasConstCopyConstructor(Context); } @@ -1239,7 +1239,7 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) { 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()) { const CXXRecordDecl *FieldClassDecl = cast(FieldClassType->getDecl()); HasConstCopyConstructor @@ -1304,7 +1304,7 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) { for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin(); HasConstCopyAssignment && Base != ClassDecl->bases_end(); ++Base) { const CXXRecordDecl *BaseClassDecl - = cast(Base->getType()->getAsRecordType()->getDecl()); + = cast(Base->getType()->getAs()->getDecl()); HasConstCopyAssignment = BaseClassDecl->hasConstCopyAssignment(Context); } @@ -1318,7 +1318,7 @@ void Sema::AddImplicitlyDeclaredMembersToClass(CXXRecordDecl *ClassDecl) { 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()) { const CXXRecordDecl *FieldClassDecl = cast(FieldClassType->getDecl()); HasConstCopyAssignment @@ -2041,7 +2041,7 @@ void Sema::DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin(), E = ClassDecl->bases_end(); Base != E; ++Base) { CXXRecordDecl *BaseClassDecl - = cast(Base->getType()->getAsRecordType()->getDecl()); + = cast(Base->getType()->getAs()->getDecl()); if (!BaseClassDecl->hasTrivialConstructor()) { if (CXXConstructorDecl *BaseCtor = BaseClassDecl->getDefaultConstructor(Context)) @@ -2061,7 +2061,7 @@ void Sema::DefineImplicitDefaultConstructor(SourceLocation CurrentLocation, 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()) { CXXRecordDecl *FieldClassDecl = cast(FieldClassType->getDecl()); if (!FieldClassDecl->hasTrivialConstructor()) { @@ -2113,7 +2113,7 @@ void Sema::DefineImplicitDestructor(SourceLocation CurrentLocation, for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin(), E = ClassDecl->bases_end(); Base != E; ++Base) { CXXRecordDecl *BaseClassDecl - = cast(Base->getType()->getAsRecordType()->getDecl()); + = cast(Base->getType()->getAs()->getDecl()); if (!BaseClassDecl->hasTrivialDestructor()) { if (CXXDestructorDecl *BaseDtor = const_cast(BaseClassDecl->getDestructor(Context))) @@ -2129,7 +2129,7 @@ void Sema::DefineImplicitDestructor(SourceLocation CurrentLocation, 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()) { CXXRecordDecl *FieldClassDecl = cast(FieldClassType->getDecl()); if (!FieldClassDecl->hasTrivialDestructor()) { @@ -2165,7 +2165,7 @@ void Sema::DefineImplicitOverloadedAssign(SourceLocation CurrentLocation, for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin(), E = ClassDecl->bases_end(); Base != E; ++Base) { CXXRecordDecl *BaseClassDecl - = cast(Base->getType()->getAsRecordType()->getDecl()); + = cast(Base->getType()->getAs()->getDecl()); if (CXXMethodDecl *BaseAssignOpMethod = getAssignOperatorMethod(MethodDecl->getParamDecl(0), BaseClassDecl)) MarkDeclarationReferenced(CurrentLocation, BaseAssignOpMethod); @@ -2175,7 +2175,7 @@ void Sema::DefineImplicitOverloadedAssign(SourceLocation CurrentLocation, 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()) { CXXRecordDecl *FieldClassDecl = cast(FieldClassType->getDecl()); if (CXXMethodDecl *FieldAssignOpMethod = @@ -2251,7 +2251,7 @@ void Sema::DefineImplicitCopyConstructor(SourceLocation CurrentLocation, for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin(); Base != ClassDecl->bases_end(); ++Base) { CXXRecordDecl *BaseClassDecl - = cast(Base->getType()->getAsRecordType()->getDecl()); + = cast(Base->getType()->getAs()->getDecl()); if (CXXConstructorDecl *BaseCopyCtor = BaseClassDecl->getCopyConstructor(Context, TypeQuals)) MarkDeclarationReferenced(CurrentLocation, BaseCopyCtor); @@ -2262,7 +2262,7 @@ void Sema::DefineImplicitCopyConstructor(SourceLocation CurrentLocation, 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()) { CXXRecordDecl *FieldClassDecl = cast(FieldClassType->getDecl()); if (CXXConstructorDecl *FieldCopyCtor = @@ -2286,7 +2286,7 @@ void Sema::InitializeVarWithConstructor(VarDecl *VD, void Sema::MarkDestructorReferenced(SourceLocation Loc, QualType DeclInitType) { CXXRecordDecl *ClassDecl = cast( - DeclInitType->getAsRecordType()->getDecl()); + DeclInitType->getAs()->getDecl()); if (!ClassDecl->hasTrivialDestructor()) if (CXXDestructorDecl *Destructor = const_cast(ClassDecl->getDestructor(Context))) @@ -2402,7 +2402,7 @@ Sema::PerformInitializationByConstructor(QualType ClassType, SourceLocation Loc, SourceRange Range, DeclarationName InitEntity, InitializationKind Kind) { - const RecordType *ClassRec = ClassType->getAsRecordType(); + const RecordType *ClassRec = ClassType->getAs(); assert(ClassRec && "Can only initialize a class type here"); // C++ [dcl.init]p14: @@ -2652,7 +2652,7 @@ Sema::CheckReferenceInit(Expr *&Init, QualType DeclType, if (!isRValRef && !SuppressUserConversions && T2->isRecordType()) { // FIXME: Look for conversions in base classes! CXXRecordDecl *T2RecordDecl - = dyn_cast(T2->getAsRecordType()->getDecl()); + = dyn_cast(T2->getAs()->getDecl()); OverloadCandidateSet CandidateSet; OverloadedFunctionDecl *Conversions diff --git a/lib/Sema/SemaExpr.cpp b/lib/Sema/SemaExpr.cpp index da5e6bad03..ff5ead0694 100644 --- a/lib/Sema/SemaExpr.cpp +++ b/lib/Sema/SemaExpr.cpp @@ -2133,7 +2133,7 @@ Sema::ActOnMemberReferenceExpr(Scope *S, ExprArg Base, SourceLocation OpLoc, // 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()) { RecordDecl *RDecl = RTy->getDecl(); if (RequireCompleteType(OpLoc, BaseType, diag::err_typecheck_incomplete_tag, @@ -2937,7 +2937,7 @@ bool Sema::CheckCastTypes(SourceRange TyR, QualType castType, Expr *&castExpr) { << castType << castExpr->getSourceRange(); } else if (castType->isUnionType()) { // GCC cast to union extension - RecordDecl *RD = castType->getAsRecordType()->getDecl(); + RecordDecl *RD = castType->getAs()->getDecl(); RecordDecl::field_iterator Field, FieldEnd; for (Field = RD->field_begin(), FieldEnd = RD->field_end(); Field != FieldEnd; ++Field) { @@ -3078,8 +3078,8 @@ QualType Sema::CheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS, // 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()) { // C99 6.5.15p3 + if (const RecordType *RHSRT = RHSTy->getAs()) 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 @@ Sema::OwningExprResult Sema::ActOnBuiltinOffsetOf(Scope *S, continue; } - const RecordType *RC = Res->getType()->getAsRecordType(); + const RecordType *RC = Res->getType()->getAs(); 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 b3de60ad8a..8b7baff972 100644 --- a/lib/Sema/SemaExprCXX.cpp +++ b/lib/Sema/SemaExprCXX.cpp @@ -83,7 +83,7 @@ Sema::ActOnCXXTypeid(SourceLocation OpLoc, SourceLocation LParenLoc, Expr *E = static_cast(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()) { CXXRecordDecl *RecordD = cast(RecordT->getDecl()); if (RecordD->isPolymorphic()) isUnevaluatedOperand = false; @@ -211,7 +211,7 @@ Sema::ActOnCXXTypeConstructExpr(SourceRange TypeRange, TypeTy *TypeRep, RParenLoc)); } - if (const RecordType *RT = Ty->getAsRecordType()) { + if (const RecordType *RT = Ty->getAs()) { CXXRecordDecl *Record = cast(RT->getDecl()); // FIXME: We should always create a CXXTemporaryObjectExpr here unless @@ -414,7 +414,7 @@ Sema::BuildCXXNew(SourceLocation StartLoc, bool UseGlobal, if (AllocType->isDependentType()) { // Skip all the checks. } - else if ((RT = AllocType->getAsRecordType()) && + else if ((RT = AllocType->getAs()) && !AllocType->isAggregateType()) { Constructor = PerformInitializationByConstructor( AllocType, ConsArgs, NumConsArgs, @@ -516,7 +516,7 @@ bool Sema::FindAllocationFunctions(SourceLocation StartLoc, SourceRange Range, IsArray ? OO_Array_New : OO_New); if (AllocType->isRecordType() && !UseGlobal) { CXXRecordDecl *Record - = cast(AllocType->getAsRecordType()->getDecl()); + = cast(AllocType->getAs()->getDecl()); // FIXME: We fail to find inherited overloads. if (FindAllocationOverload(StartLoc, Range, NewName, &AllocArgs[0], AllocArgs.size(), Record, /*AllowMissing=*/true, @@ -757,7 +757,7 @@ Sema::ActOnCXXConditionDeclarationExpr(Scope *S, SourceLocation StartLoc, } 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()) { RecordDecl *RD = RT->getDecl(); // The type-specifier-seq shall not declare a new class... if (RD->isDefinition() && @@ -1051,7 +1051,7 @@ QualType Sema::CheckPointerToMemberOperands( // 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(); if (!MemPtr) { Diag(Loc, diag::err_bad_memptr_rhs) << OpSpelling << RType << rex->getSourceRange(); @@ -1163,8 +1163,8 @@ static bool TryClassUnification(Sema &Self, Expr *From, Expr *To, // 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(); + const RecordType *TRec = TTy->getAs(); bool FDerivedFromT = FRec && TRec && Self.IsDerivedFrom(FTy, TTy); if (FRec && TRec && (FRec == TRec || FDerivedFromT || Self.IsDerivedFrom(TTy, FTy))) { @@ -1418,8 +1418,8 @@ QualType Sema::CXXCheckConditionalOperands(Expr *&Cond, Expr *&LHS, Expr *&RHS, // 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(); + const MemberPointerType *RMemPtr = RTy->getAs(); if (LMemPtr && RHS->isNullPointerConstant(Context)) { ImpCastExprToType(RHS, LTy); return LTy; @@ -1562,7 +1562,7 @@ QualType Sema::FindCompositePointerType(Expr *&E1, Expr *&E2) { } Sema::OwningExprResult Sema::MaybeBindToTemporary(Expr *E) { - const RecordType *RT = E->getType()->getAsRecordType(); + const RecordType *RT = E->getType()->getAs(); if (!RT) return Owned(E); diff --git a/lib/Sema/SemaInherit.cpp b/lib/Sema/SemaInherit.cpp index 2f914f14a8..be235e9271 100644 --- a/lib/Sema/SemaInherit.cpp +++ b/lib/Sema/SemaInherit.cpp @@ -114,7 +114,7 @@ bool Sema::IsDerivedFrom(QualType Derived, QualType Base, BasePaths &Paths) { return false; Paths.setOrigin(Derived); - return LookupInBases(cast(Derived->getAsRecordType()->getDecl()), + return LookupInBases(cast(Derived->getAs()->getDecl()), MemberLookupCriteria(Base), Paths); } @@ -156,7 +156,7 @@ bool Sema::LookupInBases(CXXRecordDecl *Class, 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(); SetVirtual = true; } } else @@ -175,7 +175,7 @@ bool Sema::LookupInBases(CXXRecordDecl *Class, } CXXRecordDecl *BaseRecord - = cast(BaseSpec->getType()->getAsRecordType()->getDecl()); + = cast(BaseSpec->getType()->getAs()->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 52099a3d90..d92f37fb25 100644 --- a/lib/Sema/SemaInit.cpp +++ b/lib/Sema/SemaInit.cpp @@ -162,7 +162,7 @@ bool Sema::CheckInitializerTypes(Expr *&Init, QualType &DeclType, if ((DeclTypeC.getUnqualifiedType() == InitTypeC.getUnqualifiedType()) || IsDerivedFrom(InitTypeC, DeclTypeC)) { const CXXRecordDecl *RD = - cast(DeclType->getAsRecordType()->getDecl()); + cast(DeclType->getAs()->getDecl()); // No need to make a CXXConstructExpr if both the ctor and dtor are // trivial. @@ -341,7 +341,7 @@ void InitListChecker::FillInValueInitializations(InitListExpr *ILE) { if (ILE->getSyntacticForm()) Loc = ILE->getSyntacticForm()->getSourceRange().getBegin(); - if (const RecordType *RType = ILE->getType()->getAsRecordType()) { + if (const RecordType *RType = ILE->getType()->getAs()) { unsigned Init = 0, NumInits = ILE->getNumInits(); for (RecordDecl::field_iterator Field = RType->getDecl()->field_begin(), @@ -447,7 +447,7 @@ int InitListChecker::numArrayElements(QualType DeclType) { } int InitListChecker::numStructUnionElements(QualType DeclType) { - RecordDecl *structDecl = DeclType->getAsRecordType()->getDecl(); + RecordDecl *structDecl = DeclType->getAs()->getDecl(); int InitializableMembers = 0; for (RecordDecl::field_iterator Field = structDecl->field_begin(), @@ -584,7 +584,7 @@ void InitListChecker::CheckListElementTypes(InitListExpr *IList, CheckVectorType(IList, DeclType, Index, StructuredList, StructuredIndex); } else if (DeclType->isAggregateType()) { if (DeclType->isRecordType()) { - RecordDecl *RD = DeclType->getAsRecordType()->getDecl(); + RecordDecl *RD = DeclType->getAs()->getDecl(); CheckStructUnionTypes(IList, DeclType, RD->field_begin(), SubobjectIsDesignatorContext, Index, StructuredList, StructuredIndex, @@ -939,7 +939,7 @@ void InitListChecker::CheckStructUnionTypes(InitListExpr *IList, InitListExpr *StructuredList, unsigned &StructuredIndex, bool TopLevelObject) { - RecordDecl* structDecl = DeclType->getAsRecordType()->getDecl(); + RecordDecl* structDecl = DeclType->getAs()->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 @@ void InitListChecker::CheckStructUnionTypes(InitListExpr *IList, if (DeclType->isUnionType() && IList->getNumInits() == 0) { // Value-initialize the first named member of the union. - RecordDecl *RD = DeclType->getAsRecordType()->getDecl(); + RecordDecl *RD = DeclType->getAs()->getDecl(); for (RecordDecl::field_iterator FieldEnd = RD->field_end(); Field != FieldEnd; ++Field) { if (Field->getDeclName()) { @@ -965,7 +965,7 @@ void InitListChecker::CheckStructUnionTypes(InitListExpr *IList, // 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()->getDecl(); RecordDecl::field_iterator FieldEnd = RD->field_end(); bool InitializedSomething = false; while (Index < IList->getNumInits()) { @@ -1204,7 +1204,7 @@ InitListChecker::CheckDesignatedInitializer(InitListExpr *IList, // 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(); if (!RT) { SourceLocation Loc = D->getDotLoc(); if (Loc.isInvalid()) @@ -1564,7 +1564,7 @@ InitListChecker::getStructuredSubobjectInit(InitListExpr *IList, unsigned Index, } } else if (const VectorType *VType = CurrentObjectType->getAsVectorType()) NumElements = VType->getNumElements(); - else if (const RecordType *RType = CurrentObjectType->getAsRecordType()) { + else if (const RecordType *RType = CurrentObjectType->getAs()) { RecordDecl *RDecl = RType->getDecl(); if (RDecl->isUnion()) NumElements = 1; @@ -1758,7 +1758,7 @@ bool Sema::CheckValueInitialization(QualType Type, SourceLocation Loc) { if (const ArrayType *AT = Context.getAsArrayType(Type)) return CheckValueInitialization(AT->getElementType(), Loc); - if (const RecordType *RT = Type->getAsRecordType()) { + if (const RecordType *RT = Type->getAs()) { if (CXXRecordDecl *ClassDecl = dyn_cast(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 a37be6898f..1ca3412620 100644 --- a/lib/Sema/SemaLookup.cpp +++ b/lib/Sema/SemaLookup.cpp @@ -1387,7 +1387,7 @@ addAssociatedClassesAndNamespaces(CXXRecordDecl *Class, 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(); CXXRecordDecl *BaseDecl = cast(BaseType->getDecl()); if (AssociatedClasses.insert(BaseDecl)) { // Find the associated namespace for this base class. @@ -1453,7 +1453,7 @@ addAssociatedClassesAndNamespaces(QualType T, // 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()) if (CXXRecordDecl *ClassDecl = dyn_cast(ClassType->getDecl())) { addAssociatedClassesAndNamespaces(ClassDecl, Context, @@ -1519,7 +1519,7 @@ addAssociatedClassesAndNamespaces(QualType T, // 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()) { // Handle the type that the pointer to member points to. addAssociatedClassesAndNamespaces(MemberPtr->getPointeeType(), Context, @@ -1527,7 +1527,7 @@ addAssociatedClassesAndNamespaces(QualType T, GlobalScope); // Handle the class type into which this points. - if (const RecordType *Class = MemberPtr->getClass()->getAsRecordType()) + if (const RecordType *Class = MemberPtr->getClass()->getAs()) addAssociatedClassesAndNamespaces(cast(Class->getDecl()), Context, AssociatedNamespaces, AssociatedClasses, diff --git a/lib/Sema/SemaNamedCast.cpp b/lib/Sema/SemaNamedCast.cpp index 1fdbcfe6a1..0dedd3a4bc 100644 --- a/lib/Sema/SemaNamedCast.cpp +++ b/lib/Sema/SemaNamedCast.cpp @@ -118,7 +118,7 @@ CheckConstCast(Sema &Self, Expr *&SrcExpr, QualType DestType, DestType = Self.Context.getCanonicalType(DestType); QualType SrcType = SrcExpr->getType(); if (const LValueReferenceType *DestTypeTmp = - DestType->getAsLValueReferenceType()) { + DestType->getAs()) { 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 @@ CheckReinterpretCast(Sema &Self, Expr *&SrcExpr, QualType DestType, DestType = Self.Context.getCanonicalType(DestType); QualType SrcType = SrcExpr->getType(); if (const LValueReferenceType *DestTypeTmp = - DestType->getAsLValueReferenceType()) { + DestType->getAs()) { 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 @@ CheckReinterpretCast(Sema &Self, Expr *&SrcExpr, QualType DestType, DestType = Self.Context.getPointerType(DestTypeTmp->getPointeeType()); SrcType = Self.Context.getPointerType(SrcType); } else if (const RValueReferenceType *DestTypeTmp = - DestType->getAsRValueReferenceType()) { + DestType->getAs()) { // Both the reference conversion and the rvalue rules apply. Self.DefaultFunctionArrayConversion(SrcExpr); SrcType = SrcExpr->getType(); @@ -253,8 +253,8 @@ CheckReinterpretCast(Sema &Self, Expr *&SrcExpr, QualType DestType, // Canonicalize source for comparison. SrcType = Self.Context.getCanonicalType(SrcType); - const MemberPointerType *DestMemPtr = DestType->getAsMemberPointerType(), - *SrcMemPtr = SrcType->getAsMemberPointerType(); + const MemberPointerType *DestMemPtr = DestType->getAs(), + *SrcMemPtr = SrcType->getAs(); 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 @@ TryLValueToRValueCast(Sema &Self, Expr *SrcExpr, QualType DestType, { // 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(); if (!R) return TSC_NotApplicable; @@ -738,10 +738,10 @@ TryStaticCastResult TryStaticMemberPointerUpcast(Sema &Self, QualType SrcType, QualType DestType, const SourceRange &OpRange) { - const MemberPointerType *SrcMemPtr = SrcType->getAsMemberPointerType(); + const MemberPointerType *SrcMemPtr = SrcType->getAs(); if (!SrcMemPtr) return TSC_NotApplicable; - const MemberPointerType *DestMemPtr = DestType->getAsMemberPointerType(); + const MemberPointerType *DestMemPtr = DestType->getAs(); if (!DestMemPtr) return TSC_NotApplicable; @@ -840,7 +840,7 @@ CheckDynamicCast(Sema &Self, Expr *&SrcExpr, QualType DestType, return; } - const RecordType *DestRecord = DestPointee->getAsRecordType(); + const RecordType *DestRecord = DestPointee->getAs(); if (DestPointee->isVoidType()) { assert(DestPointer && "Reference to void is not possible"); } else if (DestRecord) { @@ -880,7 +880,7 @@ CheckDynamicCast(Sema &Self, Expr *&SrcExpr, QualType DestType, SrcPointee = SrcType; } - const RecordType *SrcRecord = SrcPointee->getAsRecordType(); + const RecordType *SrcRecord = SrcPointee->getAs(); 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 aef7f181e5..0a161578f8 100644 --- a/lib/Sema/SemaOverload.cpp +++ b/lib/Sema/SemaOverload.cpp @@ -1178,7 +1178,7 @@ bool Sema::CheckPointerConversion(Expr *From, QualType ToType) { bool Sema::IsMemberPointerConversion(Expr *From, QualType FromType, QualType ToType, QualType &ConvertedType) { - const MemberPointerType *ToTypePtr = ToType->getAsMemberPointerType(); + const MemberPointerType *ToTypePtr = ToType->getAs(); if (!ToTypePtr) return false; @@ -1189,7 +1189,7 @@ bool Sema::IsMemberPointerConversion(Expr *From, QualType FromType, } // Otherwise, both types have to be member pointers. - const MemberPointerType *FromTypePtr = FromType->getAsMemberPointerType(); + const MemberPointerType *FromTypePtr = FromType->getAs(); if (!FromTypePtr) return false; @@ -1216,11 +1216,11 @@ bool Sema::IsMemberPointerConversion(Expr *From, QualType FromType, /// otherwise. bool Sema::CheckMemberPointerConversion(Expr *From, QualType ToType) { QualType FromType = From->getType(); - const MemberPointerType *FromPtrType = FromType->getAsMemberPointerType(); + const MemberPointerType *FromPtrType = FromType->getAs(); if (!FromPtrType) return false; - const MemberPointerType *ToPtrType = ToType->getAsMemberPointerType(); + const MemberPointerType *ToPtrType = ToType->getAs(); assert(ToPtrType && "No member pointer cast has a target type " "that is not a member pointer."); @@ -1340,7 +1340,7 @@ bool Sema::IsUserDefinedConversion(Expr *From, QualType ToType, bool AllowExplicit, bool ForceRValue) { OverloadCandidateSet CandidateSet; - if (const RecordType *ToRecordType = ToType->getAsRecordType()) { + if (const RecordType *ToRecordType = ToType->getAs()) { if (CXXRecordDecl *ToRecordDecl = dyn_cast(ToRecordType->getDecl())) { // C++ [over.match.ctor]p1: @@ -1369,7 +1369,7 @@ bool Sema::IsUserDefinedConversion(Expr *From, QualType ToType, if (!AllowConversionFunctions) { // Don't allow any conversion functions to enter the overload set. } else if (const RecordType *FromRecordType - = From->getType()->getAsRecordType()) { + = From->getType()->getAs()) { if (CXXRecordDecl *FromRecordDecl = dyn_cast(FromRecordType->getDecl())) { // Add all of the conversion functions as candidates. @@ -2500,7 +2500,7 @@ void Sema::AddMemberOperatorCandidates(OverloadedOperatorKind Op, // (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()) { DeclContext::lookup_const_iterator Oper, OperEnd; for (llvm::tie(Oper, OperEnd) = T1Rec->getDecl()->lookup(OpName); Oper != OperEnd; ++Oper) @@ -2668,7 +2668,7 @@ BuiltinCandidateTypeSet::AddMemberPointerWithMoreQualifiedTypeVariants( if (!MemberPointerTypes.insert(Ty)) return false; - if (const MemberPointerType *PointerTy = Ty->getAsMemberPointerType()) { + if (const MemberPointerType *PointerTy = Ty->getAs()) { 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 @@ BuiltinCandidateTypeSet::AddTypesConvertedFrom(QualType Ty, // 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()) { CXXRecordDecl *ClassDecl = cast(PointeeRec->getDecl()); for (CXXRecordDecl::base_class_iterator Base = ClassDecl->bases_begin(); Base != ClassDecl->bases_end(); ++Base) { @@ -2747,7 +2747,7 @@ BuiltinCandidateTypeSet::AddTypesConvertedFrom(QualType Ty, } else if (Ty->isEnumeralType()) { EnumerationTypes.insert(Ty); } else if (AllowUserConversions) { - if (const RecordType *TyRec = Ty->getAsRecordType()) { + if (const RecordType *TyRec = Ty->getAs()) { CXXRecordDecl *ClassDecl = cast(TyRec->getDecl()); // FIXME: Visit conversion functions in the base classes, too. OverloadedFunctionDecl *Conversions @@ -3616,11 +3616,11 @@ Sema::PrintOverloadCandidates(OverloadCandidateSet& CandidateSet, bool isRValueReference = false; bool isPointer = false; if (const LValueReferenceType *FnTypeRef = - FnType->getAsLValueReferenceType()) { + FnType->getAs()) { FnType = FnTypeRef->getPointeeType(); isLValueReference = true; } else if (const RValueReferenceType *FnTypeRef = - FnType->getAsRValueReferenceType()) { + FnType->getAs()) { FnType = FnTypeRef->getPointeeType(); isRValueReference = true; } @@ -3678,7 +3678,7 @@ Sema::ResolveAddressOfOverloadedFunction(Expr *From, QualType ToType, else if (const ReferenceType *ToTypeRef = ToType->getAs()) FunctionType = ToTypeRef->getPointeeType(); else if (const MemberPointerType *MemTypePtr = - ToType->getAsMemberPointerType()) { + ToType->getAs()) { FunctionType = MemTypePtr->getPointeeType(); IsMember = true; } @@ -4367,7 +4367,7 @@ Sema::BuildCallToObjectOfClassType(Scope *S, Expr *Object, SourceLocation *CommaLocs, SourceLocation RParenLoc) { assert(Object->getType()->isRecordType() && "Requires object type argument"); - const RecordType *Record = Object->getType()->getAsRecordType(); + const RecordType *Record = Object->getType()->getAs(); // C++ [over.call.object]p1: // If the primary-expression E in the function call syntax @@ -4579,7 +4579,7 @@ Sema::BuildOverloadedArrowExpr(Scope *S, Expr *Base, SourceLocation OpLoc, // 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(); DeclContext::lookup_const_iterator Oper, OperEnd; for (llvm::tie(Oper, OperEnd) diff --git a/lib/Sema/SemaTemplate.cpp b/lib/Sema/SemaTemplate.cpp index 9159cf12d5..9ee4f3fcab 100644 --- a/lib/Sema/SemaTemplate.cpp +++ b/lib/Sema/SemaTemplate.cpp @@ -1329,7 +1329,7 @@ bool Sema::CheckTemplateArgument(TemplateTypeParmDecl *Param, 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()) Tag = RecordT; if (Tag && Tag->getDecl()->getDeclContext()->isFunctionOrMethod()) return Diag(ArgLoc, diag::err_template_arg_local_type) @@ -1662,7 +1662,7 @@ bool Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param, // the set (13.4). // Again, C++0x allows a std::nullptr_t value. (ParamType->isMemberPointerType() && - ParamType->getAsMemberPointerType()->getPointeeType() + ParamType->getAs()->getPointeeType() ->isFunctionType())) { if (Context.hasSameUnqualifiedType(ArgType, ParamType.getNonReferenceType())) { diff --git a/lib/Sema/SemaTemplateDeduction.cpp b/lib/Sema/SemaTemplateDeduction.cpp index d475538586..5c4f6e7969 100644 --- a/lib/Sema/SemaTemplateDeduction.cpp +++ b/lib/Sema/SemaTemplateDeduction.cpp @@ -410,7 +410,7 @@ DeduceTemplateArguments(ASTContext &Context, // T & case Type::LValueReference: { - const LValueReferenceType *ReferenceArg = Arg->getAsLValueReferenceType(); + const LValueReferenceType *ReferenceArg = Arg->getAs(); if (!ReferenceArg) return Sema::TDK_NonDeducedMismatch; @@ -422,7 +422,7 @@ DeduceTemplateArguments(ASTContext &Context, // T && [C++0x] case Type::RValueReference: { - const RValueReferenceType *ReferenceArg = Arg->getAsRValueReferenceType(); + const RValueReferenceType *ReferenceArg = Arg->getAs(); if (!ReferenceArg) return Sema::TDK_NonDeducedMismatch; @@ -615,7 +615,7 @@ DeduceTemplateArguments(ASTContext &Context, 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()); } } diff --git a/lib/Sema/SemaType.cpp b/lib/Sema/SemaType.cpp index d69227cc94..6f28e272c4 100644 --- a/lib/Sema/SemaType.cpp +++ b/lib/Sema/SemaType.cpp @@ -414,7 +414,7 @@ QualType Sema::BuildPointerType(QualType T, unsigned Quals, 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()) { // 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 @@ QualType Sema::BuildArrayType(QualType T, ArrayType::ArraySizeModifier ASM, return QualType(); } - if (const RecordType *EltTy = T->getAsRecordType()) { + if (const RecordType *EltTy = T->getAs()) { // 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::CheckSpecifiedExceptionType(QualType T, const SourceRange &Range) { bool Sema::CheckDistantExceptionSpec(QualType T) { if (const PointerType *PT = T->getAs()) T = PT->getPointeeType(); - else if (const MemberPointerType *PT = T->getAsMemberPointerType()) + else if (const MemberPointerType *PT = T->getAs()) T = PT->getPointeeType(); else return false; @@ -1392,8 +1392,8 @@ bool Sema::UnwrapSimilarPointerTypes(QualType& T1, QualType& T2) { return true; } - const MemberPointerType *T1MPType = T1->getAsMemberPointerType(), - *T2MPType = T2->getAsMemberPointerType(); + const MemberPointerType *T1MPType = T1->getAs(), + *T2MPType = T2->getAs(); if (T1MPType && T2MPType && Context.getCanonicalType(T1MPType->getClass()) == Context.getCanonicalType(T2MPType->getClass())) { @@ -1567,7 +1567,7 @@ bool Sema::RequireCompleteType(SourceLocation Loc, QualType T, unsigned diag, // 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()) { if (ClassTemplateSpecializationDecl *ClassTemplateSpec = dyn_cast(Record->getDecl())) { if (ClassTemplateSpec->getSpecializationKind() == TSK_Undeclared) { @@ -1603,7 +1603,7 @@ bool Sema::RequireCompleteType(SourceLocation Loc, QualType T, unsigned diag, // 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()) Tag = Record; else if (const EnumType *Enum = T->getAsEnumType()) Tag = Enum;