diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 8c39ef3d5a9fa..88d93a79d00f8 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -747,9 +747,9 @@ class DeclaratorDecl : public ValueDecl { /// ignoring outer template declarations. SourceLocation InnerLocStart; - bool hasExtInfo() const { return DeclInfo.is(); } - ExtInfo *getExtInfo() { return DeclInfo.get(); } - const ExtInfo *getExtInfo() const { return DeclInfo.get(); } + bool hasExtInfo() const { return isa(DeclInfo); } + ExtInfo *getExtInfo() { return cast(DeclInfo); } + const ExtInfo *getExtInfo() const { return cast(DeclInfo); } protected: DeclaratorDecl(Kind DK, DeclContext *DC, SourceLocation L, @@ -762,9 +762,8 @@ class DeclaratorDecl : public ValueDecl { friend class ASTDeclWriter; TypeSourceInfo *getTypeSourceInfo() const { - return hasExtInfo() - ? getExtInfo()->TInfo - : DeclInfo.get(); + return hasExtInfo() ? getExtInfo()->TInfo + : cast(DeclInfo); } void setTypeSourceInfo(TypeSourceInfo *TI) { @@ -3587,10 +3586,10 @@ class TagDecl : public TypeDecl, /// otherwise, it is a null (TypedefNameDecl) pointer. llvm::PointerUnion TypedefNameDeclOrQualifier; - bool hasExtInfo() const { return TypedefNameDeclOrQualifier.is(); } - ExtInfo *getExtInfo() { return TypedefNameDeclOrQualifier.get(); } + bool hasExtInfo() const { return isa(TypedefNameDeclOrQualifier); } + ExtInfo *getExtInfo() { return cast(TypedefNameDeclOrQualifier); } const ExtInfo *getExtInfo() const { - return TypedefNameDeclOrQualifier.get(); + return cast(TypedefNameDeclOrQualifier); } protected: @@ -3793,7 +3792,7 @@ class TagDecl : public TypeDecl, TypedefNameDecl *getTypedefNameForAnonDecl() const { return hasExtInfo() ? nullptr - : TypedefNameDeclOrQualifier.get(); + : cast(TypedefNameDeclOrQualifier); } void setTypedefNameForAnonDecl(TypedefNameDecl *TDD); @@ -4011,7 +4010,7 @@ class EnumDecl : public TagDecl { return QualType(); if (const Type *T = IntegerType.dyn_cast()) return QualType(T, 0); - return IntegerType.get()->getType().getUnqualifiedType(); + return cast(IntegerType)->getType().getUnqualifiedType(); } /// Set the underlying integer type. diff --git a/clang/include/clang/AST/DeclBase.h b/clang/include/clang/AST/DeclBase.h index a3447d1990975..82932e098c86f 100644 --- a/clang/include/clang/AST/DeclBase.h +++ b/clang/include/clang/AST/DeclBase.h @@ -271,16 +271,12 @@ class alignas(8) Decl { /// // LexicalDC == global namespace llvm::PointerUnion DeclCtx; - bool isInSemaDC() const { return DeclCtx.is(); } - bool isOutOfSemaDC() const { return DeclCtx.is(); } + bool isInSemaDC() const { return isa(DeclCtx); } + bool isOutOfSemaDC() const { return isa(DeclCtx); } - MultipleDC *getMultipleDC() const { - return DeclCtx.get(); - } + MultipleDC *getMultipleDC() const { return cast(DeclCtx); } - DeclContext *getSemanticDC() const { - return DeclCtx.get(); - } + DeclContext *getSemanticDC() const { return cast(DeclCtx); } /// Loc - The location of this decl. SourceLocation Loc; @@ -1340,7 +1336,7 @@ class DeclListNode { assert(Ptr && "dereferencing end() iterator"); if (DeclListNode *CurNode = Ptr.dyn_cast()) return CurNode->D; - return Ptr.get(); + return cast(Ptr); } void operator->() const { } // Unsupported. bool operator==(const iterator &X) const { return Ptr == X.Ptr; } diff --git a/clang/include/clang/AST/DeclCXX.h b/clang/include/clang/AST/DeclCXX.h index e389b5cd6df5b..c232556edeff7 100644 --- a/clang/include/clang/AST/DeclCXX.h +++ b/clang/include/clang/AST/DeclCXX.h @@ -2388,19 +2388,19 @@ class CXXCtorInitializer final { /// Determine whether this initializer is initializing a base class. bool isBaseInitializer() const { - return Initializee.is() && !IsDelegating; + return isa(Initializee) && !IsDelegating; } /// Determine whether this initializer is initializing a non-static /// data member. - bool isMemberInitializer() const { return Initializee.is(); } + bool isMemberInitializer() const { return isa(Initializee); } bool isAnyMemberInitializer() const { return isMemberInitializer() || isIndirectMemberInitializer(); } bool isIndirectMemberInitializer() const { - return Initializee.is(); + return isa(Initializee); } /// Determine whether this initializer is an implicit initializer @@ -2416,7 +2416,7 @@ class CXXCtorInitializer final { /// Determine whether this initializer is creating a delegating /// constructor. bool isDelegatingInitializer() const { - return Initializee.is() && IsDelegating; + return isa(Initializee) && IsDelegating; } /// Determine whether this initializer is a pack expansion. @@ -2457,21 +2457,21 @@ class CXXCtorInitializer final { /// non-static data member being initialized. Otherwise, returns null. FieldDecl *getMember() const { if (isMemberInitializer()) - return Initializee.get(); + return cast(Initializee); return nullptr; } FieldDecl *getAnyMember() const { if (isMemberInitializer()) - return Initializee.get(); + return cast(Initializee); if (isIndirectMemberInitializer()) - return Initializee.get()->getAnonField(); + return cast(Initializee)->getAnonField(); return nullptr; } IndirectFieldDecl *getIndirectMember() const { if (isIndirectMemberInitializer()) - return Initializee.get(); + return cast(Initializee); return nullptr; } diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index dd92d40b80423..44ccf8932a183 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -1965,7 +1965,7 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl, SpecializedTemplate.dyn_cast()) return PartialSpec->PartialSpecialization; - return SpecializedTemplate.get(); + return cast(SpecializedTemplate); } /// Retrieve the set of template arguments that should be used @@ -2013,7 +2013,7 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl, const ASTTemplateArgumentListInfo *getTemplateArgsAsWritten() const { if (auto *Info = ExplicitInfo.dyn_cast()) return Info->TemplateArgsAsWritten; - return ExplicitInfo.get(); + return cast(ExplicitInfo); } /// Set the template argument list as written in the sources. @@ -2734,7 +2734,7 @@ class VarTemplateSpecializationDecl : public VarDecl, SpecializedTemplate.dyn_cast()) return PartialSpec->PartialSpecialization; - return SpecializedTemplate.get(); + return cast(SpecializedTemplate); } /// Retrieve the set of template arguments that should be used @@ -2782,7 +2782,7 @@ class VarTemplateSpecializationDecl : public VarDecl, const ASTTemplateArgumentListInfo *getTemplateArgsAsWritten() const { if (auto *Info = ExplicitInfo.dyn_cast()) return Info->TemplateArgsAsWritten; - return ExplicitInfo.get(); + return cast(ExplicitInfo); } /// Set the template argument list as written in the sources. @@ -3309,7 +3309,7 @@ inline NamedDecl *getAsNamedDecl(TemplateParameter P) { return PD; if (auto *PD = P.dyn_cast()) return PD; - return P.get(); + return cast(P); } inline TemplateDecl *getAsTypeTemplateDecl(Decl *D) { diff --git a/clang/include/clang/AST/ExprCXX.h b/clang/include/clang/AST/ExprCXX.h index 1a24b8857674c..4cec89c979f77 100644 --- a/clang/include/clang/AST/ExprCXX.h +++ b/clang/include/clang/AST/ExprCXX.h @@ -878,7 +878,7 @@ class CXXTypeidExpr : public Expr { /// object. This is not a strong guarantee. bool isMostDerived(const ASTContext &Context) const; - bool isTypeOperand() const { return Operand.is(); } + bool isTypeOperand() const { return isa(Operand); } /// Retrieves the type operand of this typeid() expression after /// various required adjustments (removing reference types, cv-qualifiers). @@ -887,11 +887,11 @@ class CXXTypeidExpr : public Expr { /// Retrieve source information for the type operand. TypeSourceInfo *getTypeOperandSourceInfo() const { assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)"); - return Operand.get(); + return cast(Operand); } Expr *getExprOperand() const { assert(!isTypeOperand() && "Cannot call getExprOperand for typeid(type)"); - return static_cast(Operand.get()); + return static_cast(cast(Operand)); } SourceLocation getBeginLoc() const LLVM_READONLY { return Range.getBegin(); } @@ -1093,7 +1093,7 @@ class CXXUuidofExpr : public Expr { Operand = (TypeSourceInfo*)nullptr; } - bool isTypeOperand() const { return Operand.is(); } + bool isTypeOperand() const { return isa(Operand); } /// Retrieves the type operand of this __uuidof() expression after /// various required adjustments (removing reference types, cv-qualifiers). @@ -1102,11 +1102,11 @@ class CXXUuidofExpr : public Expr { /// Retrieve source information for the type operand. TypeSourceInfo *getTypeOperandSourceInfo() const { assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)"); - return Operand.get(); + return cast(Operand); } Expr *getExprOperand() const { assert(!isTypeOperand() && "Cannot call getExprOperand for __uuidof(type)"); - return static_cast(Operand.get()); + return static_cast(cast(Operand)); } MSGuidDecl *getGuidDecl() const { return Guid; } @@ -4750,24 +4750,24 @@ class MaterializeTemporaryExpr : public Expr { /// be materialized into a glvalue. Expr *getSubExpr() const { return cast( - State.is() - ? State.get() - : State.get()->getTemporaryExpr()); + isa(State) + ? cast(State) + : cast(State)->getTemporaryExpr()); } /// Retrieve the storage duration for the materialized temporary. StorageDuration getStorageDuration() const { - return State.is() ? SD_FullExpression - : State.get() + return isa(State) ? SD_FullExpression + : cast(State) ->getStorageDuration(); } /// Get the storage for the constant value of a materialized temporary /// of static storage duration. APValue *getOrCreateValue(bool MayCreate) const { - assert(State.is() && + assert(isa(State) && "the temporary has not been lifetime extended"); - return State.get()->getOrCreateValue( + return cast(State)->getOrCreateValue( MayCreate); } @@ -4782,8 +4782,8 @@ class MaterializeTemporaryExpr : public Expr { /// Get the declaration which triggered the lifetime-extension of this /// temporary, if any. ValueDecl *getExtendingDecl() { - return State.is() ? nullptr - : State.get() + return isa(State) ? nullptr + : cast(State) ->getExtendingDecl(); } const ValueDecl *getExtendingDecl() const { @@ -4793,8 +4793,8 @@ class MaterializeTemporaryExpr : public Expr { void setExtendingDecl(ValueDecl *ExtendedBy, unsigned ManglingNumber); unsigned getManglingNumber() const { - return State.is() ? 0 - : State.get() + return isa(State) ? 0 + : cast(State) ->getManglingNumber(); } @@ -4820,17 +4820,17 @@ class MaterializeTemporaryExpr : public Expr { // Iterators child_range children() { - return State.is() + return isa(State) ? child_range(State.getAddrOfPtr1(), State.getAddrOfPtr1() + 1) - : State.get()->childrenExpr(); + : cast(State)->childrenExpr(); } const_child_range children() const { - return State.is() + return isa(State) ? const_child_range(State.getAddrOfPtr1(), State.getAddrOfPtr1() + 1) : const_cast( - State.get()) + cast(State)) ->childrenExpr(); } }; diff --git a/clang/include/clang/AST/ExprConcepts.h b/clang/include/clang/AST/ExprConcepts.h index f3e32ce396198..86c4155b6a853 100644 --- a/clang/include/clang/AST/ExprConcepts.h +++ b/clang/include/clang/AST/ExprConcepts.h @@ -261,13 +261,13 @@ class TypeRequirement : public Requirement { assert(Status == SS_SubstitutionFailure && "Attempted to get substitution diagnostic when there has been no " "substitution failure."); - return Value.get(); + return cast(Value); } TypeSourceInfo *getType() const { assert(!isSubstitutionFailure() && "Attempted to get type when there has been a substitution failure."); - return Value.get(); + return cast(Value); } static bool classof(const Requirement *R) { @@ -409,14 +409,14 @@ class ExprRequirement : public Requirement { assert(isExprSubstitutionFailure() && "Attempted to get expression substitution diagnostic when there has " "been no expression substitution failure"); - return Value.get(); + return cast(Value); } Expr *getExpr() const { assert(!isExprSubstitutionFailure() && "ExprRequirement has no expression because there has been a " "substitution failure."); - return Value.get(); + return cast(Value); } static bool classof(const Requirement *R) { diff --git a/clang/include/clang/AST/ExprObjC.h b/clang/include/clang/AST/ExprObjC.h index f833916c91aa5..1fccc26069582 100644 --- a/clang/include/clang/AST/ExprObjC.h +++ b/clang/include/clang/AST/ExprObjC.h @@ -752,28 +752,24 @@ class ObjCPropertyRefExpr : public Expr { setMethodRefFlag(MethodRef_Setter, val); } - const Expr *getBase() const { - return cast(Receiver.get()); - } - Expr *getBase() { - return cast(Receiver.get()); - } + const Expr *getBase() const { return cast(cast(Receiver)); } + Expr *getBase() { return cast(cast(Receiver)); } SourceLocation getLocation() const { return IdLoc; } SourceLocation getReceiverLocation() const { return ReceiverLoc; } QualType getSuperReceiverType() const { - return QualType(Receiver.get(), 0); + return QualType(cast(Receiver), 0); } ObjCInterfaceDecl *getClassReceiver() const { - return Receiver.get(); + return cast(Receiver); } - bool isObjectReceiver() const { return Receiver.is(); } - bool isSuperReceiver() const { return Receiver.is(); } - bool isClassReceiver() const { return Receiver.is(); } + bool isObjectReceiver() const { return isa(Receiver); } + bool isSuperReceiver() const { return isa(Receiver); } + bool isClassReceiver() const { return isa(Receiver); } /// Determine the type of the base, regardless of the kind of receiver. QualType getReceiverType(const ASTContext &ctx) const; @@ -787,7 +783,7 @@ class ObjCPropertyRefExpr : public Expr { // Iterators child_range children() { - if (Receiver.is()) { + if (isa(Receiver)) { Stmt **begin = reinterpret_cast(&Receiver); // hack! return child_range(begin, begin+1); } diff --git a/clang/include/clang/AST/Redeclarable.h b/clang/include/clang/AST/Redeclarable.h index 8d320a9ced279..bba789375cb6e 100644 --- a/clang/include/clang/AST/Redeclarable.h +++ b/clang/include/clang/AST/Redeclarable.h @@ -113,25 +113,24 @@ class Redeclarable { DeclLink(PreviousTag, decl_type *D) : Link(NotKnownLatest(Previous(D))) {} bool isFirst() const { - return Link.is() || + return isa(Link) || // FIXME: 'template' is required on the next line due to an // apparent clang bug. - Link.get().template is(); + cast(Link).template is(); } decl_type *getPrevious(const decl_type *D) const { - if (Link.is()) { - NotKnownLatest NKL = Link.get(); - if (NKL.is()) - return static_cast(NKL.get()); + if (NotKnownLatest NKL = dyn_cast(Link)) { + if (auto *Prev = dyn_cast(NKL)) + return static_cast(Prev); // Allocate the generational 'most recent' cache now, if needed. Link = KnownLatest(*reinterpret_cast( - NKL.get()), + cast(NKL)), const_cast(D)); } - return static_cast(Link.get().get(D)); + return static_cast(cast(Link).get(D)); } void setPrevious(decl_type *D) { @@ -141,25 +140,24 @@ class Redeclarable { void setLatest(decl_type *D) { assert(isFirst() && "decl became canonical unexpectedly"); - if (Link.is()) { - NotKnownLatest NKL = Link.get(); + if (NotKnownLatest NKL = dyn_cast(Link)) { Link = KnownLatest(*reinterpret_cast( - NKL.get()), + cast(NKL)), D); } else { - auto Latest = Link.get(); + auto Latest = cast(Link); Latest.set(D); Link = Latest; } } - void markIncomplete() { Link.get().markIncomplete(); } + void markIncomplete() { cast(Link).markIncomplete(); } Decl *getLatestNotUpdated() const { assert(isFirst() && "expected a canonical decl"); - if (Link.is()) + if (isa(Link)) return nullptr; - return Link.get().getNotUpdated(); + return cast(Link).getNotUpdated(); } }; diff --git a/clang/include/clang/AST/TemplateBase.h b/clang/include/clang/AST/TemplateBase.h index a8f0263d5505a..9d0ee24a4f5e3 100644 --- a/clang/include/clang/AST/TemplateBase.h +++ b/clang/include/clang/AST/TemplateBase.h @@ -484,7 +484,7 @@ struct TemplateArgumentLocInfo { Pointer; TemplateTemplateArgLocInfo *getTemplate() const { - return Pointer.get(); + return cast(Pointer); } public: @@ -499,10 +499,10 @@ struct TemplateArgumentLocInfo { SourceLocation EllipsisLoc); TypeSourceInfo *getAsTypeSourceInfo() const { - return Pointer.get(); + return cast(Pointer); } - Expr *getAsExpr() const { return Pointer.get(); } + Expr *getAsExpr() const { return cast(Pointer); } NestedNameSpecifierLoc getTemplateQualifierLoc() const { const auto *Template = getTemplate();