forked from OSchip/llvm-project
[AST] Fix some Clang-tidy modernize-use-auto warnings; other minor fixes (NFC).
llvm-svn: 328826
This commit is contained in:
parent
54d44bf14c
commit
309e29d532
|
@ -299,7 +299,7 @@ class DefaultArgStorage {
|
|||
|
||||
static ParmDecl *getParmOwningDefaultArg(ParmDecl *Parm) {
|
||||
const DefaultArgStorage &Storage = Parm->getDefaultArgStorage();
|
||||
if (auto *Prev = Storage.ValueOrInherited.template dyn_cast<ParmDecl*>())
|
||||
if (auto *Prev = Storage.ValueOrInherited.template dyn_cast<ParmDecl *>())
|
||||
Parm = Prev;
|
||||
assert(!Parm->getDefaultArgStorage()
|
||||
.ValueOrInherited.template is<ParmDecl *>() &&
|
||||
|
@ -321,9 +321,9 @@ public:
|
|||
/// default argument is visible.
|
||||
ArgType get() const {
|
||||
const DefaultArgStorage *Storage = this;
|
||||
if (auto *Prev = ValueOrInherited.template dyn_cast<ParmDecl*>())
|
||||
if (const auto *Prev = ValueOrInherited.template dyn_cast<ParmDecl *>())
|
||||
Storage = &Prev->getDefaultArgStorage();
|
||||
if (auto *C = Storage->ValueOrInherited.template dyn_cast<Chain*>())
|
||||
if (const auto *C = Storage->ValueOrInherited.template dyn_cast<Chain *>())
|
||||
return C->Value;
|
||||
return Storage->ValueOrInherited.template get<ArgType>();
|
||||
}
|
||||
|
@ -331,9 +331,9 @@ public:
|
|||
/// Get the parameter from which we inherit the default argument, if any.
|
||||
/// This is the parameter on which the default argument was actually written.
|
||||
const ParmDecl *getInheritedFrom() const {
|
||||
if (auto *D = ValueOrInherited.template dyn_cast<ParmDecl*>())
|
||||
if (const auto *D = ValueOrInherited.template dyn_cast<ParmDecl *>())
|
||||
return D;
|
||||
if (auto *C = ValueOrInherited.template dyn_cast<Chain*>())
|
||||
if (const auto *C = ValueOrInherited.template dyn_cast<Chain *>())
|
||||
return C->PrevDeclWithDefaultArg;
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -443,7 +443,7 @@ public:
|
|||
}
|
||||
|
||||
Expr *getAssociatedConstraints() const {
|
||||
const TemplateDecl *const C = cast<TemplateDecl>(getCanonicalDecl());
|
||||
const auto *const C = cast<TemplateDecl>(getCanonicalDecl());
|
||||
const auto *const CTDI =
|
||||
C->TemplateParams.dyn_cast<ConstrainedTemplateDeclInfo *>();
|
||||
return CTDI ? CTDI->getAssociatedConstraints() : nullptr;
|
||||
|
@ -466,6 +466,7 @@ public:
|
|||
|
||||
protected:
|
||||
NamedDecl *TemplatedDecl;
|
||||
|
||||
/// \brief The template parameter list and optional requires-clause
|
||||
/// associated with this declaration; alternatively, a
|
||||
/// \c ConstrainedTemplateDeclInfo if the associated constraints of the
|
||||
|
@ -1621,7 +1622,7 @@ public:
|
|||
}
|
||||
|
||||
SourceRange getSourceRange() const override LLVM_READONLY {
|
||||
return SourceRange();
|
||||
return {};
|
||||
}
|
||||
|
||||
BuiltinTemplateKind getBuiltinTemplateKind() const { return BTK; }
|
||||
|
@ -1789,8 +1790,8 @@ public:
|
|||
llvm::PointerUnion<ClassTemplateDecl *,
|
||||
ClassTemplatePartialSpecializationDecl *>
|
||||
getSpecializedTemplateOrPartial() const {
|
||||
if (SpecializedPartialSpecialization *PartialSpec
|
||||
= SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
|
||||
if (const auto *PartialSpec =
|
||||
SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
|
||||
return PartialSpec->PartialSpecialization;
|
||||
|
||||
return SpecializedTemplate.get<ClassTemplateDecl*>();
|
||||
|
@ -1808,8 +1809,8 @@ public:
|
|||
/// deduced template arguments for the class template partial specialization
|
||||
/// itself.
|
||||
const TemplateArgumentList &getTemplateInstantiationArgs() const {
|
||||
if (SpecializedPartialSpecialization *PartialSpec
|
||||
= SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
|
||||
if (const auto *PartialSpec =
|
||||
SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
|
||||
return *PartialSpec->TemplateArgs;
|
||||
|
||||
return getTemplateArgs();
|
||||
|
@ -1822,8 +1823,7 @@ public:
|
|||
const TemplateArgumentList *TemplateArgs) {
|
||||
assert(!SpecializedTemplate.is<SpecializedPartialSpecialization*>() &&
|
||||
"Already set to a class template partial specialization!");
|
||||
SpecializedPartialSpecialization *PS
|
||||
= new (getASTContext()) SpecializedPartialSpecialization();
|
||||
auto *PS = new (getASTContext()) SpecializedPartialSpecialization();
|
||||
PS->PartialSpecialization = PartialSpec;
|
||||
PS->TemplateArgs = TemplateArgs;
|
||||
SpecializedTemplate = PS;
|
||||
|
@ -1984,7 +1984,7 @@ public:
|
|||
/// \c Outer<float>::Inner<U*>, this function would return
|
||||
/// \c Outer<T>::Inner<U*>.
|
||||
ClassTemplatePartialSpecializationDecl *getInstantiatedFromMember() const {
|
||||
const ClassTemplatePartialSpecializationDecl *First =
|
||||
const auto *First =
|
||||
cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
|
||||
return First->InstantiatedFromMember.getPointer();
|
||||
}
|
||||
|
@ -1995,8 +1995,7 @@ public:
|
|||
|
||||
void setInstantiatedFromMember(
|
||||
ClassTemplatePartialSpecializationDecl *PartialSpec) {
|
||||
ClassTemplatePartialSpecializationDecl *First =
|
||||
cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
|
||||
auto *First = cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
|
||||
First->InstantiatedFromMember.setPointer(PartialSpec);
|
||||
}
|
||||
|
||||
|
@ -2017,15 +2016,14 @@ public:
|
|||
/// struct X<int>::Inner<T*> { /* ... */ };
|
||||
/// \endcode
|
||||
bool isMemberSpecialization() {
|
||||
ClassTemplatePartialSpecializationDecl *First =
|
||||
const auto *First =
|
||||
cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
|
||||
return First->InstantiatedFromMember.getInt();
|
||||
}
|
||||
|
||||
/// \brief Note that this member template is a specialization.
|
||||
void setMemberSpecialization() {
|
||||
ClassTemplatePartialSpecializationDecl *First =
|
||||
cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
|
||||
auto *First = cast<ClassTemplatePartialSpecializationDecl>(getFirstDecl());
|
||||
assert(First->InstantiatedFromMember.getPointer() &&
|
||||
"Only member templates can be member template specializations");
|
||||
return First->InstantiatedFromMember.setInt(true);
|
||||
|
@ -2627,7 +2625,7 @@ public:
|
|||
/// specialization which was specialized by this.
|
||||
llvm::PointerUnion<VarTemplateDecl *, VarTemplatePartialSpecializationDecl *>
|
||||
getSpecializedTemplateOrPartial() const {
|
||||
if (SpecializedPartialSpecialization *PartialSpec =
|
||||
if (const auto *PartialSpec =
|
||||
SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
|
||||
return PartialSpec->PartialSpecialization;
|
||||
|
||||
|
@ -2646,7 +2644,7 @@ public:
|
|||
/// return deduced template arguments for the variable template partial
|
||||
/// specialization itself.
|
||||
const TemplateArgumentList &getTemplateInstantiationArgs() const {
|
||||
if (SpecializedPartialSpecialization *PartialSpec =
|
||||
if (const auto *PartialSpec =
|
||||
SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
|
||||
return *PartialSpec->TemplateArgs;
|
||||
|
||||
|
@ -2660,8 +2658,7 @@ public:
|
|||
const TemplateArgumentList *TemplateArgs) {
|
||||
assert(!SpecializedTemplate.is<SpecializedPartialSpecialization *>() &&
|
||||
"Already set to a variable template partial specialization!");
|
||||
SpecializedPartialSpecialization *PS =
|
||||
new (getASTContext()) SpecializedPartialSpecialization();
|
||||
auto *PS = new (getASTContext()) SpecializedPartialSpecialization();
|
||||
PS->PartialSpecialization = PartialSpec;
|
||||
PS->TemplateArgs = TemplateArgs;
|
||||
SpecializedTemplate = PS;
|
||||
|
@ -2815,15 +2812,14 @@ public:
|
|||
/// \c Outer<float>::Inner<U*>, this function would return
|
||||
/// \c Outer<T>::Inner<U*>.
|
||||
VarTemplatePartialSpecializationDecl *getInstantiatedFromMember() const {
|
||||
const VarTemplatePartialSpecializationDecl *First =
|
||||
const auto *First =
|
||||
cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
|
||||
return First->InstantiatedFromMember.getPointer();
|
||||
}
|
||||
|
||||
void
|
||||
setInstantiatedFromMember(VarTemplatePartialSpecializationDecl *PartialSpec) {
|
||||
VarTemplatePartialSpecializationDecl *First =
|
||||
cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
|
||||
auto *First = cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
|
||||
First->InstantiatedFromMember.setPointer(PartialSpec);
|
||||
}
|
||||
|
||||
|
@ -2844,15 +2840,14 @@ public:
|
|||
/// U* X<int>::Inner<T*> = (T*)(0) + 1;
|
||||
/// \endcode
|
||||
bool isMemberSpecialization() {
|
||||
VarTemplatePartialSpecializationDecl *First =
|
||||
const auto *First =
|
||||
cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
|
||||
return First->InstantiatedFromMember.getInt();
|
||||
}
|
||||
|
||||
/// \brief Note that this member template is a specialization.
|
||||
void setMemberSpecialization() {
|
||||
VarTemplatePartialSpecializationDecl *First =
|
||||
cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
|
||||
auto *First = cast<VarTemplatePartialSpecializationDecl>(getFirstDecl());
|
||||
assert(First->InstantiatedFromMember.getPointer() &&
|
||||
"Only member templates can be member template specializations");
|
||||
return First->InstantiatedFromMember.setInt(true);
|
||||
|
@ -3021,11 +3016,11 @@ public:
|
|||
};
|
||||
|
||||
inline NamedDecl *getAsNamedDecl(TemplateParameter P) {
|
||||
if (auto *PD = P.dyn_cast<TemplateTypeParmDecl*>())
|
||||
if (auto *PD = P.dyn_cast<TemplateTypeParmDecl *>())
|
||||
return PD;
|
||||
if (auto *PD = P.dyn_cast<NonTypeTemplateParmDecl*>())
|
||||
if (auto *PD = P.dyn_cast<NonTypeTemplateParmDecl *>())
|
||||
return PD;
|
||||
return P.get<TemplateTemplateParmDecl*>();
|
||||
return P.get<TemplateTemplateParmDecl *>();
|
||||
}
|
||||
|
||||
inline TemplateDecl *getAsTypeTemplateDecl(Decl *D) {
|
||||
|
|
|
@ -667,8 +667,7 @@ class QualType {
|
|||
|
||||
const ExtQualsTypeCommonBase *getCommonPtr() const {
|
||||
assert(!isNull() && "Cannot retrieve a NULL type pointer");
|
||||
uintptr_t CommonPtrVal
|
||||
= reinterpret_cast<uintptr_t>(Value.getOpaqueValue());
|
||||
auto CommonPtrVal = reinterpret_cast<uintptr_t>(Value.getOpaqueValue());
|
||||
CommonPtrVal &= ~(uintptr_t)((1 << TypeAlignmentInBits) - 1);
|
||||
return reinterpret_cast<ExtQualsTypeCommonBase*>(CommonPtrVal);
|
||||
}
|
||||
|
@ -3544,7 +3543,7 @@ private:
|
|||
assert(hasExtParameterInfos());
|
||||
|
||||
// Find the end of the exception specification.
|
||||
const char *ptr = reinterpret_cast<const char *>(exception_begin());
|
||||
const auto *ptr = reinterpret_cast<const char *>(exception_begin());
|
||||
ptr += getExceptionSpecSize();
|
||||
|
||||
return reinterpret_cast<const ExtParameterInfo *>(ptr);
|
||||
|
@ -5499,8 +5498,8 @@ public:
|
|||
|
||||
inline ObjCInterfaceDecl *ObjCObjectType::getInterface() const {
|
||||
QualType baseType = getBaseType();
|
||||
while (const ObjCObjectType *ObjT = baseType->getAs<ObjCObjectType>()) {
|
||||
if (const ObjCInterfaceType *T = dyn_cast<ObjCInterfaceType>(ObjT))
|
||||
while (const auto *ObjT = baseType->getAs<ObjCObjectType>()) {
|
||||
if (const auto *T = dyn_cast<ObjCInterfaceType>(ObjT))
|
||||
return T->getDecl();
|
||||
|
||||
baseType = ObjT->getBaseType();
|
||||
|
@ -5922,10 +5921,10 @@ inline Qualifiers::GC QualType::getObjCGCAttr() const {
|
|||
}
|
||||
|
||||
inline FunctionType::ExtInfo getFunctionExtInfo(const Type &t) {
|
||||
if (const PointerType *PT = t.getAs<PointerType>()) {
|
||||
if (const FunctionType *FT = PT->getPointeeType()->getAs<FunctionType>())
|
||||
if (const auto *PT = t.getAs<PointerType>()) {
|
||||
if (const auto *FT = PT->getPointeeType()->getAs<FunctionType>())
|
||||
return FT->getExtInfo();
|
||||
} else if (const FunctionType *FT = t.getAs<FunctionType>())
|
||||
} else if (const auto *FT = t.getAs<FunctionType>())
|
||||
return FT->getExtInfo();
|
||||
|
||||
return FunctionType::ExtInfo();
|
||||
|
@ -5970,7 +5969,7 @@ inline bool QualType::isAtLeastAsQualifiedAs(QualType other) const {
|
|||
/// analysis, the expression designates the object or function
|
||||
/// denoted by the reference, and the expression is an lvalue.
|
||||
inline QualType QualType::getNonReferenceType() const {
|
||||
if (const ReferenceType *RefType = (*this)->getAs<ReferenceType>())
|
||||
if (const auto *RefType = (*this)->getAs<ReferenceType>())
|
||||
return RefType->getPointeeType();
|
||||
else
|
||||
return *this;
|
||||
|
@ -6045,7 +6044,7 @@ inline bool Type::isRValueReferenceType() const {
|
|||
}
|
||||
|
||||
inline bool Type::isFunctionPointerType() const {
|
||||
if (const PointerType *T = getAs<PointerType>())
|
||||
if (const auto *T = getAs<PointerType>())
|
||||
return T->getPointeeType()->isFunctionType();
|
||||
else
|
||||
return false;
|
||||
|
@ -6056,14 +6055,14 @@ inline bool Type::isMemberPointerType() const {
|
|||
}
|
||||
|
||||
inline bool Type::isMemberFunctionPointerType() const {
|
||||
if (const MemberPointerType* T = getAs<MemberPointerType>())
|
||||
if (const auto *T = getAs<MemberPointerType>())
|
||||
return T->isMemberFunctionPointer();
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool Type::isMemberDataPointerType() const {
|
||||
if (const MemberPointerType* T = getAs<MemberPointerType>())
|
||||
if (const auto *T = getAs<MemberPointerType>())
|
||||
return T->isMemberDataPointer();
|
||||
else
|
||||
return false;
|
||||
|
@ -6135,31 +6134,31 @@ inline bool Type::isAtomicType() const {
|
|||
}
|
||||
|
||||
inline bool Type::isObjCQualifiedIdType() const {
|
||||
if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>())
|
||||
if (const auto *OPT = getAs<ObjCObjectPointerType>())
|
||||
return OPT->isObjCQualifiedIdType();
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool Type::isObjCQualifiedClassType() const {
|
||||
if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>())
|
||||
if (const auto *OPT = getAs<ObjCObjectPointerType>())
|
||||
return OPT->isObjCQualifiedClassType();
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool Type::isObjCIdType() const {
|
||||
if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>())
|
||||
if (const auto *OPT = getAs<ObjCObjectPointerType>())
|
||||
return OPT->isObjCIdType();
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool Type::isObjCClassType() const {
|
||||
if (const ObjCObjectPointerType *OPT = getAs<ObjCObjectPointerType>())
|
||||
if (const auto *OPT = getAs<ObjCObjectPointerType>())
|
||||
return OPT->isObjCClassType();
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool Type::isObjCSelType() const {
|
||||
if (const PointerType *OPT = getAs<PointerType>())
|
||||
if (const auto *OPT = getAs<PointerType>())
|
||||
return OPT->getPointeeType()->isSpecificBuiltinType(BuiltinType::ObjCSel);
|
||||
return false;
|
||||
}
|
||||
|
@ -6222,13 +6221,13 @@ inline bool Type::isSpecificBuiltinType(unsigned K) const {
|
|||
}
|
||||
|
||||
inline bool Type::isPlaceholderType() const {
|
||||
if (const BuiltinType *BT = dyn_cast<BuiltinType>(this))
|
||||
if (const auto *BT = dyn_cast<BuiltinType>(this))
|
||||
return BT->isPlaceholderType();
|
||||
return false;
|
||||
}
|
||||
|
||||
inline const BuiltinType *Type::getAsPlaceholderType() const {
|
||||
if (const BuiltinType *BT = dyn_cast<BuiltinType>(this))
|
||||
if (const auto *BT = dyn_cast<BuiltinType>(this))
|
||||
if (BT->isPlaceholderType())
|
||||
return BT;
|
||||
return nullptr;
|
||||
|
@ -6236,38 +6235,38 @@ inline const BuiltinType *Type::getAsPlaceholderType() const {
|
|||
|
||||
inline bool Type::isSpecificPlaceholderType(unsigned K) const {
|
||||
assert(BuiltinType::isPlaceholderTypeKind((BuiltinType::Kind) K));
|
||||
if (const BuiltinType *BT = dyn_cast<BuiltinType>(this))
|
||||
if (const auto *BT = dyn_cast<BuiltinType>(this))
|
||||
return (BT->getKind() == (BuiltinType::Kind) K);
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool Type::isNonOverloadPlaceholderType() const {
|
||||
if (const BuiltinType *BT = dyn_cast<BuiltinType>(this))
|
||||
if (const auto *BT = dyn_cast<BuiltinType>(this))
|
||||
return BT->isNonOverloadPlaceholderType();
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool Type::isVoidType() const {
|
||||
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
|
||||
if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
|
||||
return BT->getKind() == BuiltinType::Void;
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool Type::isHalfType() const {
|
||||
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
|
||||
if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
|
||||
return BT->getKind() == BuiltinType::Half;
|
||||
// FIXME: Should we allow complex __fp16? Probably not.
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool Type::isFloat16Type() const {
|
||||
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
|
||||
if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
|
||||
return BT->getKind() == BuiltinType::Float16;
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool Type::isNullPtrType() const {
|
||||
if (const BuiltinType *BT = getAs<BuiltinType>())
|
||||
if (const auto *BT = getAs<BuiltinType>())
|
||||
return BT->getKind() == BuiltinType::NullPtr;
|
||||
return false;
|
||||
}
|
||||
|
@ -6276,7 +6275,7 @@ bool IsEnumDeclComplete(EnumDecl *);
|
|||
bool IsEnumDeclScoped(EnumDecl *);
|
||||
|
||||
inline bool Type::isIntegerType() const {
|
||||
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
|
||||
if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
|
||||
return BT->getKind() >= BuiltinType::Bool &&
|
||||
BT->getKind() <= BuiltinType::Int128;
|
||||
if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType)) {
|
||||
|
@ -6289,7 +6288,7 @@ inline bool Type::isIntegerType() const {
|
|||
}
|
||||
|
||||
inline bool Type::isScalarType() const {
|
||||
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
|
||||
if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
|
||||
return BT->getKind() > BuiltinType::Void &&
|
||||
BT->getKind() <= BuiltinType::NullPtr;
|
||||
if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType))
|
||||
|
@ -6304,20 +6303,20 @@ inline bool Type::isScalarType() const {
|
|||
}
|
||||
|
||||
inline bool Type::isIntegralOrEnumerationType() const {
|
||||
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
|
||||
if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
|
||||
return BT->getKind() >= BuiltinType::Bool &&
|
||||
BT->getKind() <= BuiltinType::Int128;
|
||||
|
||||
// Check for a complete enum type; incomplete enum types are not properly an
|
||||
// enumeration type in the sense required here.
|
||||
if (const EnumType *ET = dyn_cast<EnumType>(CanonicalType))
|
||||
if (const auto *ET = dyn_cast<EnumType>(CanonicalType))
|
||||
return IsEnumDeclComplete(ET->getDecl());
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
inline bool Type::isBooleanType() const {
|
||||
if (const BuiltinType *BT = dyn_cast<BuiltinType>(CanonicalType))
|
||||
if (const auto *BT = dyn_cast<BuiltinType>(CanonicalType))
|
||||
return BT->getKind() == BuiltinType::Bool;
|
||||
return false;
|
||||
}
|
||||
|
@ -6394,7 +6393,7 @@ template <typename T> const T *Type::getAs() const {
|
|||
"ArrayType cannot be used with getAs!");
|
||||
|
||||
// If this is directly a T type, return it.
|
||||
if (const T *Ty = dyn_cast<T>(this))
|
||||
if (const auto *Ty = dyn_cast<T>(this))
|
||||
return Ty;
|
||||
|
||||
// If the canonical form of this type isn't the right kind, reject it.
|
||||
|
@ -6410,7 +6409,7 @@ template <typename T> const T *Type::getAsAdjusted() const {
|
|||
static_assert(!TypeIsArrayType<T>::value, "ArrayType cannot be used with getAsAdjusted!");
|
||||
|
||||
// If this is directly a T type, return it.
|
||||
if (const T *Ty = dyn_cast<T>(this))
|
||||
if (const auto *Ty = dyn_cast<T>(this))
|
||||
return Ty;
|
||||
|
||||
// If the canonical form of this type isn't the right kind, reject it.
|
||||
|
@ -6440,7 +6439,7 @@ template <typename T> const T *Type::getAsAdjusted() const {
|
|||
|
||||
inline const ArrayType *Type::getAsArrayTypeUnsafe() const {
|
||||
// If this is directly an array type, return it.
|
||||
if (const ArrayType *arr = dyn_cast<ArrayType>(this))
|
||||
if (const auto *arr = dyn_cast<ArrayType>(this))
|
||||
return arr;
|
||||
|
||||
// If the canonical form of this type isn't the right kind, reject it.
|
||||
|
@ -6456,14 +6455,14 @@ template <typename T> const T *Type::castAs() const {
|
|||
static_assert(!TypeIsArrayType<T>::value,
|
||||
"ArrayType cannot be used with castAs!");
|
||||
|
||||
if (const T *ty = dyn_cast<T>(this)) return ty;
|
||||
if (const auto *ty = dyn_cast<T>(this)) return ty;
|
||||
assert(isa<T>(CanonicalType));
|
||||
return cast<T>(getUnqualifiedDesugaredType());
|
||||
}
|
||||
|
||||
inline const ArrayType *Type::castAsArrayTypeUnsafe() const {
|
||||
assert(isa<ArrayType>(CanonicalType));
|
||||
if (const ArrayType *arr = dyn_cast<ArrayType>(this)) return arr;
|
||||
if (const auto *arr = dyn_cast<ArrayType>(this)) return arr;
|
||||
return cast<ArrayType>(getUnqualifiedDesugaredType());
|
||||
}
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "clang/AST/DeclCXX.h"
|
||||
#include "clang/AST/DeclarationName.h"
|
||||
#include "clang/AST/Expr.h"
|
||||
#include "clang/AST/ExternalASTSource.h"
|
||||
#include "clang/AST/TemplateBase.h"
|
||||
#include "clang/AST/TemplateName.h"
|
||||
#include "clang/AST/Type.h"
|
||||
|
@ -56,11 +57,11 @@ TemplateParameterList::TemplateParameterList(SourceLocation TemplateLoc,
|
|||
begin()[Idx] = P;
|
||||
|
||||
if (!P->isTemplateParameterPack()) {
|
||||
if (NonTypeTemplateParmDecl *NTTP = dyn_cast<NonTypeTemplateParmDecl>(P))
|
||||
if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(P))
|
||||
if (NTTP->getType()->containsUnexpandedParameterPack())
|
||||
ContainsUnexpandedParameterPack = true;
|
||||
|
||||
if (TemplateTemplateParmDecl *TTP = dyn_cast<TemplateTemplateParmDecl>(P))
|
||||
if (const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(P))
|
||||
if (TTP->getTemplateParameters()->containsUnexpandedParameterPack())
|
||||
ContainsUnexpandedParameterPack = true;
|
||||
|
||||
|
@ -118,11 +119,9 @@ unsigned TemplateParameterList::getDepth() const {
|
|||
return 0;
|
||||
|
||||
const NamedDecl *FirstParm = getParam(0);
|
||||
if (const TemplateTypeParmDecl *TTP
|
||||
= dyn_cast<TemplateTypeParmDecl>(FirstParm))
|
||||
if (const auto *TTP = dyn_cast<TemplateTypeParmDecl>(FirstParm))
|
||||
return TTP->getDepth();
|
||||
else if (const NonTypeTemplateParmDecl *NTTP
|
||||
= dyn_cast<NonTypeTemplateParmDecl>(FirstParm))
|
||||
else if (const auto *NTTP = dyn_cast<NonTypeTemplateParmDecl>(FirstParm))
|
||||
return NTTP->getDepth();
|
||||
else
|
||||
return cast<TemplateTemplateParmDecl>(FirstParm)->getDepth();
|
||||
|
@ -133,7 +132,7 @@ static void AdoptTemplateParameterList(TemplateParameterList *Params,
|
|||
for (NamedDecl *P : *Params) {
|
||||
P->setDeclContext(Owner);
|
||||
|
||||
if (auto *TTP = dyn_cast<TemplateTemplateParmDecl>(P))
|
||||
if (const auto *TTP = dyn_cast<TemplateTemplateParmDecl>(P))
|
||||
AdoptTemplateParameterList(TTP->getTemplateParameters(), Owner);
|
||||
}
|
||||
}
|
||||
|
@ -258,7 +257,7 @@ FunctionTemplateDecl *FunctionTemplateDecl::CreateDeserialized(ASTContext &C,
|
|||
|
||||
RedeclarableTemplateDecl::CommonBase *
|
||||
FunctionTemplateDecl::newCommon(ASTContext &C) const {
|
||||
Common *CommonPtr = new (C) Common;
|
||||
auto *CommonPtr = new (C) Common;
|
||||
C.addDestruction(CommonPtr);
|
||||
return CommonPtr;
|
||||
}
|
||||
|
@ -318,8 +317,8 @@ ClassTemplateDecl *ClassTemplateDecl::Create(ASTContext &C,
|
|||
return new (C, DC) ClassTemplateDecl(C, DC, L, Name, Params, Decl);
|
||||
}
|
||||
|
||||
ConstrainedTemplateDeclInfo *const CTDI = new (C) ConstrainedTemplateDeclInfo;
|
||||
ClassTemplateDecl *const New =
|
||||
auto *const CTDI = new (C) ConstrainedTemplateDeclInfo;
|
||||
auto *const New =
|
||||
new (C, DC) ClassTemplateDecl(CTDI, C, DC, L, Name, Params, Decl);
|
||||
New->setAssociatedConstraints(AssociatedConstraints);
|
||||
return New;
|
||||
|
@ -349,7 +348,7 @@ ClassTemplateDecl::getPartialSpecializations() {
|
|||
|
||||
RedeclarableTemplateDecl::CommonBase *
|
||||
ClassTemplateDecl::newCommon(ASTContext &C) const {
|
||||
Common *CommonPtr = new (C) Common;
|
||||
auto *CommonPtr = new (C) Common;
|
||||
C.addDestruction(CommonPtr);
|
||||
return CommonPtr;
|
||||
}
|
||||
|
@ -453,8 +452,8 @@ TemplateTypeParmDecl::Create(const ASTContext &C, DeclContext *DC,
|
|||
SourceLocation KeyLoc, SourceLocation NameLoc,
|
||||
unsigned D, unsigned P, IdentifierInfo *Id,
|
||||
bool Typename, bool ParameterPack) {
|
||||
TemplateTypeParmDecl *TTPDecl =
|
||||
new (C, DC) TemplateTypeParmDecl(DC, KeyLoc, NameLoc, Id, Typename);
|
||||
auto *TTPDecl =
|
||||
new (C, DC) TemplateTypeParmDecl(DC, KeyLoc, NameLoc, Id, Typename);
|
||||
QualType TTPType = C.getTemplateTypeParmType(D, P, ParameterPack, TTPDecl);
|
||||
TTPDecl->setTypeForDecl(TTPType.getTypePtr());
|
||||
return TTPDecl;
|
||||
|
@ -709,7 +708,7 @@ ClassTemplateSpecializationDecl::Create(ASTContext &Context, TagKind TK,
|
|||
ClassTemplateDecl *SpecializedTemplate,
|
||||
ArrayRef<TemplateArgument> Args,
|
||||
ClassTemplateSpecializationDecl *PrevDecl) {
|
||||
ClassTemplateSpecializationDecl *Result =
|
||||
auto *Result =
|
||||
new (Context, DC) ClassTemplateSpecializationDecl(
|
||||
Context, ClassTemplateSpecialization, TK, DC, StartLoc, IdLoc,
|
||||
SpecializedTemplate, Args, PrevDecl);
|
||||
|
@ -722,7 +721,7 @@ ClassTemplateSpecializationDecl::Create(ASTContext &Context, TagKind TK,
|
|||
ClassTemplateSpecializationDecl *
|
||||
ClassTemplateSpecializationDecl::CreateDeserialized(ASTContext &C,
|
||||
unsigned ID) {
|
||||
ClassTemplateSpecializationDecl *Result =
|
||||
auto *Result =
|
||||
new (C, ID) ClassTemplateSpecializationDecl(C, ClassTemplateSpecialization);
|
||||
Result->MayHaveOutOfDateDef = false;
|
||||
return Result;
|
||||
|
@ -732,7 +731,7 @@ void ClassTemplateSpecializationDecl::getNameForDiagnostic(
|
|||
raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const {
|
||||
NamedDecl::getNameForDiagnostic(OS, Policy, Qualified);
|
||||
|
||||
auto *PS = dyn_cast<ClassTemplatePartialSpecializationDecl>(this);
|
||||
const auto *PS = dyn_cast<ClassTemplatePartialSpecializationDecl>(this);
|
||||
if (const ASTTemplateArgumentListInfo *ArgsAsWritten =
|
||||
PS ? PS->getTemplateArgsAsWritten() : nullptr) {
|
||||
printTemplateArgumentList(OS, ArgsAsWritten->arguments(), Policy);
|
||||
|
@ -744,8 +743,8 @@ void ClassTemplateSpecializationDecl::getNameForDiagnostic(
|
|||
|
||||
ClassTemplateDecl *
|
||||
ClassTemplateSpecializationDecl::getSpecializedTemplate() const {
|
||||
if (SpecializedPartialSpecialization *PartialSpec
|
||||
= SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
|
||||
if (const auto *PartialSpec =
|
||||
SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
|
||||
return PartialSpec->PartialSpecialization->getSpecializedTemplate();
|
||||
return SpecializedTemplate.get<ClassTemplateDecl*>();
|
||||
}
|
||||
|
@ -770,7 +769,7 @@ ClassTemplateSpecializationDecl::getSourceRange() const {
|
|||
// uses ExplicitInfo to record the TypeAsWritten, but the source
|
||||
// locations should be retrieved from the instantiation pattern.
|
||||
using CTPSDecl = ClassTemplatePartialSpecializationDecl;
|
||||
CTPSDecl *ctpsd = const_cast<CTPSDecl*>(cast<CTPSDecl>(this));
|
||||
auto *ctpsd = const_cast<CTPSDecl *>(cast<CTPSDecl>(this));
|
||||
CTPSDecl *inst_from = ctpsd->getInstantiatedFromMember();
|
||||
assert(inst_from != nullptr);
|
||||
return inst_from->getSourceRange();
|
||||
|
@ -782,9 +781,9 @@ ClassTemplateSpecializationDecl::getSourceRange() const {
|
|||
inst_from = getInstantiatedFrom();
|
||||
if (inst_from.isNull())
|
||||
return getSpecializedTemplate()->getSourceRange();
|
||||
if (ClassTemplateDecl *ctd = inst_from.dyn_cast<ClassTemplateDecl*>())
|
||||
if (const auto *ctd = inst_from.dyn_cast<ClassTemplateDecl *>())
|
||||
return ctd->getSourceRange();
|
||||
return inst_from.get<ClassTemplatePartialSpecializationDecl*>()
|
||||
return inst_from.get<ClassTemplatePartialSpecializationDecl *>()
|
||||
->getSourceRange();
|
||||
}
|
||||
}
|
||||
|
@ -826,7 +825,7 @@ Create(ASTContext &Context, TagKind TK,DeclContext *DC,
|
|||
const ASTTemplateArgumentListInfo *ASTArgInfos =
|
||||
ASTTemplateArgumentListInfo::Create(Context, ArgInfos);
|
||||
|
||||
ClassTemplatePartialSpecializationDecl *Result = new (Context, DC)
|
||||
auto *Result = new (Context, DC)
|
||||
ClassTemplatePartialSpecializationDecl(Context, TK, DC, StartLoc, IdLoc,
|
||||
Params, SpecializedTemplate, Args,
|
||||
ASTArgInfos, PrevDecl);
|
||||
|
@ -840,8 +839,7 @@ Create(ASTContext &Context, TagKind TK,DeclContext *DC,
|
|||
ClassTemplatePartialSpecializationDecl *
|
||||
ClassTemplatePartialSpecializationDecl::CreateDeserialized(ASTContext &C,
|
||||
unsigned ID) {
|
||||
ClassTemplatePartialSpecializationDecl *Result =
|
||||
new (C, ID) ClassTemplatePartialSpecializationDecl(C);
|
||||
auto *Result = new (C, ID) ClassTemplatePartialSpecializationDecl(C);
|
||||
Result->MayHaveOutOfDateDef = false;
|
||||
return Result;
|
||||
}
|
||||
|
@ -887,7 +885,7 @@ TypeAliasTemplateDecl *TypeAliasTemplateDecl::CreateDeserialized(ASTContext &C,
|
|||
|
||||
RedeclarableTemplateDecl::CommonBase *
|
||||
TypeAliasTemplateDecl::newCommon(ASTContext &C) const {
|
||||
Common *CommonPtr = new (C) Common;
|
||||
auto *CommonPtr = new (C) Common;
|
||||
C.addDestruction(CommonPtr);
|
||||
return CommonPtr;
|
||||
}
|
||||
|
@ -950,7 +948,7 @@ VarTemplateDecl::getPartialSpecializations() {
|
|||
|
||||
RedeclarableTemplateDecl::CommonBase *
|
||||
VarTemplateDecl::newCommon(ASTContext &C) const {
|
||||
Common *CommonPtr = new (C) Common;
|
||||
auto *CommonPtr = new (C) Common;
|
||||
C.addDestruction(CommonPtr);
|
||||
return CommonPtr;
|
||||
}
|
||||
|
@ -1048,7 +1046,7 @@ void VarTemplateSpecializationDecl::getNameForDiagnostic(
|
|||
raw_ostream &OS, const PrintingPolicy &Policy, bool Qualified) const {
|
||||
NamedDecl::getNameForDiagnostic(OS, Policy, Qualified);
|
||||
|
||||
auto *PS = dyn_cast<VarTemplatePartialSpecializationDecl>(this);
|
||||
const auto *PS = dyn_cast<VarTemplatePartialSpecializationDecl>(this);
|
||||
if (const ASTTemplateArgumentListInfo *ArgsAsWritten =
|
||||
PS ? PS->getTemplateArgsAsWritten() : nullptr) {
|
||||
printTemplateArgumentList(OS, ArgsAsWritten->arguments(), Policy);
|
||||
|
@ -1059,7 +1057,7 @@ void VarTemplateSpecializationDecl::getNameForDiagnostic(
|
|||
}
|
||||
|
||||
VarTemplateDecl *VarTemplateSpecializationDecl::getSpecializedTemplate() const {
|
||||
if (SpecializedPartialSpecialization *PartialSpec =
|
||||
if (const auto *PartialSpec =
|
||||
SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
|
||||
return PartialSpec->PartialSpecialization->getSpecializedTemplate();
|
||||
return SpecializedTemplate.get<VarTemplateDecl *>();
|
||||
|
@ -1104,7 +1102,7 @@ VarTemplatePartialSpecializationDecl::Create(
|
|||
const ASTTemplateArgumentListInfo *ASTArgInfos
|
||||
= ASTTemplateArgumentListInfo::Create(Context, ArgInfos);
|
||||
|
||||
VarTemplatePartialSpecializationDecl *Result =
|
||||
auto *Result =
|
||||
new (Context, DC) VarTemplatePartialSpecializationDecl(
|
||||
Context, DC, StartLoc, IdLoc, Params, SpecializedTemplate, T, TInfo,
|
||||
S, Args, ASTArgInfos);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue