diff --git a/clang/include/clang/AST/APValue.h b/clang/include/clang/AST/APValue.h index 7869ee386689d..4401f3a8ff482 100644 --- a/clang/include/clang/AST/APValue.h +++ b/clang/include/clang/AST/APValue.h @@ -157,11 +157,9 @@ class APValue { void Profile(llvm::FoldingSetNodeID &ID) const; - template - bool is() const { return Ptr.is(); } + template bool is() const { return isa(Ptr); } - template - T get() const { return Ptr.get(); } + template T get() const { return cast(Ptr); } template T dyn_cast() const { return Ptr.dyn_cast(); } diff --git a/clang/include/clang/AST/Decl.h b/clang/include/clang/AST/Decl.h index 88d93a79d00f8..67ee0bb412692 100644 --- a/clang/include/clang/AST/Decl.h +++ b/clang/include/clang/AST/Decl.h @@ -3457,18 +3457,17 @@ class TypedefNameDecl : public TypeDecl, public Redeclarable { using redeclarable_base::isFirstDecl; bool isModed() const { - return MaybeModedTInfo.getPointer().is(); + return isa(MaybeModedTInfo.getPointer()); } TypeSourceInfo *getTypeSourceInfo() const { - return isModed() ? MaybeModedTInfo.getPointer().get()->first - : MaybeModedTInfo.getPointer().get(); + return isModed() ? cast(MaybeModedTInfo.getPointer())->first + : cast(MaybeModedTInfo.getPointer()); } QualType getUnderlyingType() const { - return isModed() ? MaybeModedTInfo.getPointer().get()->second - : MaybeModedTInfo.getPointer() - .get() + return isModed() ? cast(MaybeModedTInfo.getPointer())->second + : cast(MaybeModedTInfo.getPointer()) ->getType(); } diff --git a/clang/include/clang/AST/DeclContextInternals.h b/clang/include/clang/AST/DeclContextInternals.h index e169c48592192..b17b7627ac90c 100644 --- a/clang/include/clang/AST/DeclContextInternals.h +++ b/clang/include/clang/AST/DeclContextInternals.h @@ -70,7 +70,7 @@ class StoredDeclsList { // want to keep (if any) will be of the form DeclListNode(D, ); // replace it with just D. if (NewLast) { - DeclListNode *Node = NewLast->get(); + DeclListNode *Node = cast(*NewLast); *NewLast = Node->D; C.DeallocateDeclListNode(Node); } @@ -84,11 +84,11 @@ class StoredDeclsList { if (!Data.getPointer()) // All declarations are erased. return nullptr; - else if (NewHead.is()) + else if (isa(NewHead)) // The list only contains a declaration, the header itself. return (DeclListNode::Decls *)&Data; else { - assert(NewLast && NewLast->is() && "Not the tail?"); + assert(NewLast && isa(*NewLast) && "Not the tail?"); return NewLast; } } @@ -207,7 +207,7 @@ class StoredDeclsList { } // Append the Decls. - DeclListNode *Node = C.AllocateDeclListNode(Tail->get()); + DeclListNode *Node = C.AllocateDeclListNode(cast(*Tail)); Node->Rest = DeclsAsList; *Tail = Node; } @@ -293,7 +293,7 @@ class StoredDeclsList { llvm::errs() << '[' << Node->D << "] -> "; D = Node->Rest; } else { - llvm::errs() << '[' << D.get() << "]\n"; + llvm::errs() << '[' << cast(D) << "]\n"; return; } } diff --git a/clang/include/clang/AST/DeclTemplate.h b/clang/include/clang/AST/DeclTemplate.h index 44ccf8932a183..d3a466a8617bb 100644 --- a/clang/include/clang/AST/DeclTemplate.h +++ b/clang/include/clang/AST/DeclTemplate.h @@ -319,8 +319,7 @@ class DefaultArgStorage { const DefaultArgStorage &Storage = Parm->getDefaultArgStorage(); if (auto *Prev = Storage.ValueOrInherited.template dyn_cast()) Parm = Prev; - assert(!Parm->getDefaultArgStorage() - .ValueOrInherited.template is() && + assert(!isa(Parm->getDefaultArgStorage().ValueOrInherited) && "should only be one level of indirection"); return Parm; } @@ -333,7 +332,7 @@ class DefaultArgStorage { /// Determine whether the default argument for this parameter was inherited /// from a previous declaration of the same entity. - bool isInherited() const { return ValueOrInherited.template is(); } + bool isInherited() const { return isa(ValueOrInherited); } /// Get the default argument's value. This does not consider whether the /// default argument is visible. @@ -343,7 +342,7 @@ class DefaultArgStorage { Storage = &Prev->getDefaultArgStorage(); if (const auto *C = Storage->ValueOrInherited.template dyn_cast()) return C->Value; - return Storage->ValueOrInherited.template get(); + return cast(Storage->ValueOrInherited); } /// Get the parameter from which we inherit the default argument, if any. @@ -379,7 +378,7 @@ class DefaultArgStorage { Inherited->PrevDeclWithDefaultArg = InheritedFrom; } else ValueOrInherited = new (allocateDefaultArgStorageChain(C)) - Chain{InheritedFrom, ValueOrInherited.template get()}; + Chain{InheritedFrom, cast(ValueOrInherited)}; } /// Remove the default argument, even if it was inherited. @@ -1992,7 +1991,7 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl, /// template arguments have been deduced. void setInstantiationOf(ClassTemplatePartialSpecializationDecl *PartialSpec, const TemplateArgumentList *TemplateArgs) { - assert(!SpecializedTemplate.is() && + assert(!isa(SpecializedTemplate) && "Already set to a class template partial specialization!"); auto *PS = new (getASTContext()) SpecializedPartialSpecialization(); PS->PartialSpecialization = PartialSpec; @@ -2003,7 +2002,7 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl, /// Note that this class template specialization is an instantiation /// of the given class template. void setInstantiationOf(ClassTemplateDecl *TemplDecl) { - assert(!SpecializedTemplate.is() && + assert(!isa(SpecializedTemplate) && "Previously set to a class template partial specialization!"); SpecializedTemplate = TemplDecl; } @@ -2761,7 +2760,7 @@ class VarTemplateSpecializationDecl : public VarDecl, /// template arguments have been deduced. void setInstantiationOf(VarTemplatePartialSpecializationDecl *PartialSpec, const TemplateArgumentList *TemplateArgs) { - assert(!SpecializedTemplate.is() && + assert(!isa(SpecializedTemplate) && "Already set to a variable template partial specialization!"); auto *PS = new (getASTContext()) SpecializedPartialSpecialization(); PS->PartialSpecialization = PartialSpec; @@ -2772,7 +2771,7 @@ class VarTemplateSpecializationDecl : public VarDecl, /// Note that this variable template specialization is an instantiation /// of the given variable template. void setInstantiationOf(VarTemplateDecl *TemplDecl) { - assert(!SpecializedTemplate.is() && + assert(!isa(SpecializedTemplate) && "Previously set to a variable template partial specialization!"); SpecializedTemplate = TemplDecl; } diff --git a/clang/include/clang/AST/ExprConcepts.h b/clang/include/clang/AST/ExprConcepts.h index 86c4155b6a853..f988d40cf73c3 100644 --- a/clang/include/clang/AST/ExprConcepts.h +++ b/clang/include/clang/AST/ExprConcepts.h @@ -329,24 +329,24 @@ class ExprRequirement : public Requirement { bool isSubstitutionFailure() const { return !isEmpty() && - TypeConstraintInfo.getPointer().is(); + isa(TypeConstraintInfo.getPointer()); } bool isTypeConstraint() const { return !isEmpty() && - TypeConstraintInfo.getPointer().is(); + isa(TypeConstraintInfo.getPointer()); } SubstitutionDiagnostic *getSubstitutionDiagnostic() const { assert(isSubstitutionFailure()); - return TypeConstraintInfo.getPointer().get(); + return cast(TypeConstraintInfo.getPointer()); } const TypeConstraint *getTypeConstraint() const; TemplateParameterList *getTypeConstraintTemplateParameterList() const { assert(isTypeConstraint()); - return TypeConstraintInfo.getPointer().get(); + return cast(TypeConstraintInfo.getPointer()); } }; private: diff --git a/clang/include/clang/AST/ExternalASTSource.h b/clang/include/clang/AST/ExternalASTSource.h index 9f968ba05b446..4d7ff822fceb7 100644 --- a/clang/include/clang/AST/ExternalASTSource.h +++ b/clang/include/clang/AST/ExternalASTSource.h @@ -462,9 +462,7 @@ struct LazyGenerationalUpdatePtr { : Value(Value) {} /// Forcibly set this pointer (which must be lazy) as needing updates. - void markIncomplete() { - Value.template get()->LastGeneration = 0; - } + void markIncomplete() { cast(Value)->LastGeneration = 0; } /// Set the value of this pointer, in the current generation. void set(T NewValue) { @@ -487,14 +485,14 @@ struct LazyGenerationalUpdatePtr { } return LazyVal->LastValue; } - return Value.template get(); + return cast(Value); } /// Get the most recently computed value of this pointer without updating it. T getNotUpdated() const { if (auto *LazyVal = Value.template dyn_cast()) return LazyVal->LastValue; - return Value.template get(); + return cast(Value); } void *getOpaqueValue() { return Value.getOpaqueValue(); } diff --git a/clang/include/clang/AST/Redeclarable.h b/clang/include/clang/AST/Redeclarable.h index bba789375cb6e..ee21f11e5f707 100644 --- a/clang/include/clang/AST/Redeclarable.h +++ b/clang/include/clang/AST/Redeclarable.h @@ -116,7 +116,7 @@ class Redeclarable { return isa(Link) || // FIXME: 'template' is required on the next line due to an // apparent clang bug. - cast(Link).template is(); + isa(cast(Link)); } decl_type *getPrevious(const decl_type *D) const { diff --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h index f0eee77c73ef0..09c98f642852f 100644 --- a/clang/include/clang/AST/Type.h +++ b/clang/include/clang/AST/Type.h @@ -934,11 +934,11 @@ class QualType { Qualifiers::FastWidth> Value; const ExtQuals *getExtQualsUnsafe() const { - return Value.getPointer().get(); + return cast(Value.getPointer()); } const Type *getTypePtrUnsafe() const { - return Value.getPointer().get(); + return cast(Value.getPointer()); } const ExtQualsTypeCommonBase *getCommonPtr() const { @@ -1064,7 +1064,7 @@ class QualType { /// "non-fast" qualifiers, e.g., those that are stored in an ExtQualType /// instance. bool hasLocalNonFastQualifiers() const { - return Value.getPointer().is(); + return isa(Value.getPointer()); } /// Retrieve the set of qualifiers local to this particular QualType