Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions clang/include/clang/AST/APValue.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,11 +157,9 @@ class APValue {

void Profile(llvm::FoldingSetNodeID &ID) const;

template <class T>
bool is() const { return Ptr.is<T>(); }
template <class T> bool is() const { return isa<T>(Ptr); }

template <class T>
T get() const { return Ptr.get<T>(); }
template <class T> T get() const { return cast<T>(Ptr); }

template <class T>
T dyn_cast() const { return Ptr.dyn_cast<T>(); }
Expand Down
11 changes: 5 additions & 6 deletions clang/include/clang/AST/Decl.h
Original file line number Diff line number Diff line change
Expand Up @@ -3457,18 +3457,17 @@ class TypedefNameDecl : public TypeDecl, public Redeclarable<TypedefNameDecl> {
using redeclarable_base::isFirstDecl;

bool isModed() const {
return MaybeModedTInfo.getPointer().is<ModedTInfo *>();
return isa<ModedTInfo *>(MaybeModedTInfo.getPointer());
}

TypeSourceInfo *getTypeSourceInfo() const {
return isModed() ? MaybeModedTInfo.getPointer().get<ModedTInfo *>()->first
: MaybeModedTInfo.getPointer().get<TypeSourceInfo *>();
return isModed() ? cast<ModedTInfo *>(MaybeModedTInfo.getPointer())->first
: cast<TypeSourceInfo *>(MaybeModedTInfo.getPointer());
}

QualType getUnderlyingType() const {
return isModed() ? MaybeModedTInfo.getPointer().get<ModedTInfo *>()->second
: MaybeModedTInfo.getPointer()
.get<TypeSourceInfo *>()
return isModed() ? cast<ModedTInfo *>(MaybeModedTInfo.getPointer())->second
: cast<TypeSourceInfo *>(MaybeModedTInfo.getPointer())
->getType();
}

Expand Down
10 changes: 5 additions & 5 deletions clang/include/clang/AST/DeclContextInternals.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class StoredDeclsList {
// want to keep (if any) will be of the form DeclListNode(D, <rest>);
// replace it with just D.
if (NewLast) {
DeclListNode *Node = NewLast->get<DeclListNode*>();
DeclListNode *Node = cast<DeclListNode *>(*NewLast);
*NewLast = Node->D;
C.DeallocateDeclListNode(Node);
}
Expand All @@ -84,11 +84,11 @@ class StoredDeclsList {
if (!Data.getPointer())
// All declarations are erased.
return nullptr;
else if (NewHead.is<NamedDecl *>())
else if (isa<NamedDecl *>(NewHead))
// The list only contains a declaration, the header itself.
return (DeclListNode::Decls *)&Data;
else {
assert(NewLast && NewLast->is<NamedDecl *>() && "Not the tail?");
assert(NewLast && isa<NamedDecl *>(*NewLast) && "Not the tail?");
return NewLast;
}
}
Expand Down Expand Up @@ -207,7 +207,7 @@ class StoredDeclsList {
}

// Append the Decls.
DeclListNode *Node = C.AllocateDeclListNode(Tail->get<NamedDecl *>());
DeclListNode *Node = C.AllocateDeclListNode(cast<NamedDecl *>(*Tail));
Node->Rest = DeclsAsList;
*Tail = Node;
}
Expand Down Expand Up @@ -293,7 +293,7 @@ class StoredDeclsList {
llvm::errs() << '[' << Node->D << "] -> ";
D = Node->Rest;
} else {
llvm::errs() << '[' << D.get<NamedDecl*>() << "]\n";
llvm::errs() << '[' << cast<NamedDecl *>(D) << "]\n";
return;
}
}
Expand Down
17 changes: 8 additions & 9 deletions clang/include/clang/AST/DeclTemplate.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,8 +319,7 @@ class DefaultArgStorage {
const DefaultArgStorage &Storage = Parm->getDefaultArgStorage();
if (auto *Prev = Storage.ValueOrInherited.template dyn_cast<ParmDecl *>())
Parm = Prev;
assert(!Parm->getDefaultArgStorage()
.ValueOrInherited.template is<ParmDecl *>() &&
assert(!isa<ParmDecl *>(Parm->getDefaultArgStorage().ValueOrInherited) &&
"should only be one level of indirection");
return Parm;
}
Expand All @@ -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<ParmDecl*>(); }
bool isInherited() const { return isa<ParmDecl *>(ValueOrInherited); }

/// Get the default argument's value. This does not consider whether the
/// default argument is visible.
Expand All @@ -343,7 +342,7 @@ class DefaultArgStorage {
Storage = &Prev->getDefaultArgStorage();
if (const auto *C = Storage->ValueOrInherited.template dyn_cast<Chain *>())
return C->Value;
return Storage->ValueOrInherited.template get<ArgType>();
return cast<ArgType>(Storage->ValueOrInherited);
}

/// Get the parameter from which we inherit the default argument, if any.
Expand Down Expand Up @@ -379,7 +378,7 @@ class DefaultArgStorage {
Inherited->PrevDeclWithDefaultArg = InheritedFrom;
} else
ValueOrInherited = new (allocateDefaultArgStorageChain(C))
Chain{InheritedFrom, ValueOrInherited.template get<ArgType>()};
Chain{InheritedFrom, cast<ArgType>(ValueOrInherited)};
}

/// Remove the default argument, even if it was inherited.
Expand Down Expand Up @@ -1992,7 +1991,7 @@ class ClassTemplateSpecializationDecl : public CXXRecordDecl,
/// template arguments have been deduced.
void setInstantiationOf(ClassTemplatePartialSpecializationDecl *PartialSpec,
const TemplateArgumentList *TemplateArgs) {
assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
assert(!isa<SpecializedPartialSpecialization *>(SpecializedTemplate) &&
"Already set to a class template partial specialization!");
auto *PS = new (getASTContext()) SpecializedPartialSpecialization();
PS->PartialSpecialization = PartialSpec;
Expand All @@ -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<SpecializedPartialSpecialization*>() &&
assert(!isa<SpecializedPartialSpecialization *>(SpecializedTemplate) &&
"Previously set to a class template partial specialization!");
SpecializedTemplate = TemplDecl;
}
Expand Down Expand Up @@ -2761,7 +2760,7 @@ class VarTemplateSpecializationDecl : public VarDecl,
/// template arguments have been deduced.
void setInstantiationOf(VarTemplatePartialSpecializationDecl *PartialSpec,
const TemplateArgumentList *TemplateArgs) {
assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
assert(!isa<SpecializedPartialSpecialization *>(SpecializedTemplate) &&
"Already set to a variable template partial specialization!");
auto *PS = new (getASTContext()) SpecializedPartialSpecialization();
PS->PartialSpecialization = PartialSpec;
Expand All @@ -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<SpecializedPartialSpecialization *>() &&
assert(!isa<SpecializedPartialSpecialization *>(SpecializedTemplate) &&
"Previously set to a variable template partial specialization!");
SpecializedTemplate = TemplDecl;
}
Expand Down
8 changes: 4 additions & 4 deletions clang/include/clang/AST/ExprConcepts.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,24 +329,24 @@ class ExprRequirement : public Requirement {

bool isSubstitutionFailure() const {
return !isEmpty() &&
TypeConstraintInfo.getPointer().is<SubstitutionDiagnostic *>();
isa<SubstitutionDiagnostic *>(TypeConstraintInfo.getPointer());
}

bool isTypeConstraint() const {
return !isEmpty() &&
TypeConstraintInfo.getPointer().is<TemplateParameterList *>();
isa<TemplateParameterList *>(TypeConstraintInfo.getPointer());
}

SubstitutionDiagnostic *getSubstitutionDiagnostic() const {
assert(isSubstitutionFailure());
return TypeConstraintInfo.getPointer().get<SubstitutionDiagnostic *>();
return cast<SubstitutionDiagnostic *>(TypeConstraintInfo.getPointer());
}

const TypeConstraint *getTypeConstraint() const;

TemplateParameterList *getTypeConstraintTemplateParameterList() const {
assert(isTypeConstraint());
return TypeConstraintInfo.getPointer().get<TemplateParameterList *>();
return cast<TemplateParameterList *>(TypeConstraintInfo.getPointer());
}
};
private:
Expand Down
8 changes: 3 additions & 5 deletions clang/include/clang/AST/ExternalASTSource.h
Original file line number Diff line number Diff line change
Expand Up @@ -462,9 +462,7 @@ struct LazyGenerationalUpdatePtr {
: Value(Value) {}

/// Forcibly set this pointer (which must be lazy) as needing updates.
void markIncomplete() {
Value.template get<LazyData *>()->LastGeneration = 0;
}
void markIncomplete() { cast<LazyData *>(Value)->LastGeneration = 0; }

/// Set the value of this pointer, in the current generation.
void set(T NewValue) {
Expand All @@ -487,14 +485,14 @@ struct LazyGenerationalUpdatePtr {
}
return LazyVal->LastValue;
}
return Value.template get<T>();
return cast<T>(Value);
}

/// Get the most recently computed value of this pointer without updating it.
T getNotUpdated() const {
if (auto *LazyVal = Value.template dyn_cast<LazyData *>())
return LazyVal->LastValue;
return Value.template get<T>();
return cast<T>(Value);
}

void *getOpaqueValue() { return Value.getOpaqueValue(); }
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/AST/Redeclarable.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ class Redeclarable {
return isa<KnownLatest>(Link) ||
// FIXME: 'template' is required on the next line due to an
// apparent clang bug.
cast<NotKnownLatest>(Link).template is<UninitializedLatest>();
isa<UninitializedLatest>(cast<NotKnownLatest>(Link));
}

decl_type *getPrevious(const decl_type *D) const {
Expand Down
6 changes: 3 additions & 3 deletions clang/include/clang/AST/Type.h
Original file line number Diff line number Diff line change
Expand Up @@ -934,11 +934,11 @@ class QualType {
Qualifiers::FastWidth> Value;

const ExtQuals *getExtQualsUnsafe() const {
return Value.getPointer().get<const ExtQuals*>();
return cast<const ExtQuals *>(Value.getPointer());
}

const Type *getTypePtrUnsafe() const {
return Value.getPointer().get<const Type*>();
return cast<const Type *>(Value.getPointer());
}

const ExtQualsTypeCommonBase *getCommonPtr() const {
Expand Down Expand Up @@ -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<const ExtQuals*>();
return isa<const ExtQuals *>(Value.getPointer());
}

/// Retrieve the set of qualifiers local to this particular QualType
Expand Down
Loading