Use std::foo_t rather than std::foo in clang.

Summary: No functional change.

Reviewers: bkramer, MaskRay, martong, shafik

Subscribers: martong, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D74414
This commit is contained in:
Justin Lebar 2020-02-10 23:23:44 -08:00
parent f0fd852fcd
commit 027eb71696
22 changed files with 91 additions and 107 deletions

View File

@ -465,22 +465,22 @@ private:
template <typename T>
struct DynTypedNode::BaseConverter<
T, typename std::enable_if<std::is_base_of<Decl, T>::value>::type>
T, std::enable_if_t<std::is_base_of<Decl, T>::value>>
: public DynCastPtrConverter<T, Decl> {};
template <typename T>
struct DynTypedNode::BaseConverter<
T, typename std::enable_if<std::is_base_of<Stmt, T>::value>::type>
T, std::enable_if_t<std::is_base_of<Stmt, T>::value>>
: public DynCastPtrConverter<T, Stmt> {};
template <typename T>
struct DynTypedNode::BaseConverter<
T, typename std::enable_if<std::is_base_of<Type, T>::value>::type>
T, std::enable_if_t<std::is_base_of<Type, T>::value>>
: public DynCastPtrConverter<T, Type> {};
template <typename T>
struct DynTypedNode::BaseConverter<
T, typename std::enable_if<std::is_base_of<OMPClause, T>::value>::type>
T, std::enable_if_t<std::is_base_of<OMPClause, T>::value>>
: public DynCastPtrConverter<T, OMPClause> {};
template <>

View File

@ -74,7 +74,7 @@ public:
/// canonical type pointers.
template <typename U>
CanQual(const CanQual<U> &Other,
typename std::enable_if<std::is_base_of<T, U>::value, int>::type = 0);
std::enable_if_t<std::is_base_of<T, U>::value, int> = 0);
/// Retrieve the underlying type pointer, which refers to a
/// canonical type.

View File

@ -50,10 +50,9 @@ template <class T> void addDataToConsumer(T &DataConsumer, const QualType &QT) {
}
template <class T, class Type>
typename std::enable_if<
std::is_integral<Type>::value || std::is_enum<Type>::value ||
std::is_convertible<Type, size_t>::value // for llvm::hash_code
>::type
std::enable_if_t<std::is_integral<Type>::value || std::is_enum<Type>::value ||
std::is_convertible<Type, size_t>::value // for llvm::hash_code
>
addDataToConsumer(T &DataConsumer, Type Data) {
DataConsumer.update(StringRef(reinterpret_cast<char *>(&Data), sizeof(Data)));
}

View File

@ -5282,10 +5282,9 @@ class GenericSelectionExpr final
template <bool Const> class AssociationTy {
friend class GenericSelectionExpr;
template <bool OtherConst> friend class AssociationIteratorTy;
using ExprPtrTy =
typename std::conditional<Const, const Expr *, Expr *>::type;
using TSIPtrTy = typename std::conditional<Const, const TypeSourceInfo *,
TypeSourceInfo *>::type;
using ExprPtrTy = std::conditional_t<Const, const Expr *, Expr *>;
using TSIPtrTy =
std::conditional_t<Const, const TypeSourceInfo *, TypeSourceInfo *>;
ExprPtrTy E;
TSIPtrTy TSI;
bool Selected;
@ -5327,10 +5326,9 @@ class GenericSelectionExpr final
// const Association &Assoc = *It++; // Oops, Assoc is dangling.
using BaseTy = typename AssociationIteratorTy::iterator_facade_base;
using StmtPtrPtrTy =
typename std::conditional<Const, const Stmt *const *, Stmt **>::type;
using TSIPtrPtrTy =
typename std::conditional<Const, const TypeSourceInfo *const *,
TypeSourceInfo **>::type;
std::conditional_t<Const, const Stmt *const *, Stmt **>;
using TSIPtrPtrTy = std::conditional_t<Const, const TypeSourceInfo *const *,
TypeSourceInfo **>;
StmtPtrPtrTy E; // = nullptr; FIXME: Once support for gcc 4.8 is dropped.
TSIPtrPtrTy TSI; // Kept in sync with E.
unsigned Offset = 0, SelectedOffset = 0;

View File

@ -6611,7 +6611,7 @@ public:
template<class ImplClass, template <typename> class Ptr, typename RetTy>
class OMPClauseVisitorBase {
public:
#define PTR(CLASS) typename Ptr<CLASS>::type
#define PTR(CLASS) Ptr<CLASS>
#define DISPATCH(CLASS) \
return static_cast<ImplClass*>(this)->Visit##CLASS(static_cast<PTR(CLASS)>(S))
@ -6634,12 +6634,11 @@ public:
#undef DISPATCH
};
template <typename T>
using const_ptr = typename std::add_pointer<typename std::add_const<T>::type>;
template <typename T> using const_ptr = std::add_pointer_t<std::add_const_t<T>>;
template<class ImplClass, typename RetTy = void>
class OMPClauseVisitor :
public OMPClauseVisitorBase <ImplClass, std::add_pointer, RetTy> {};
template <class ImplClass, typename RetTy = void>
class OMPClauseVisitor
: public OMPClauseVisitorBase<ImplClass, std::add_pointer_t, RetTy> {};
template<class ImplClass, typename RetTy = void>
class ConstOMPClauseVisitor :
public OMPClauseVisitorBase <ImplClass, const_ptr, RetTy> {};

View File

@ -340,11 +340,11 @@ private:
(has_same_member_pointer_type<decltype( \
&RecursiveASTVisitor::Traverse##NAME), \
decltype(&Derived::Traverse##NAME)>::value \
? static_cast<typename std::conditional< \
? static_cast<std::conditional_t< \
has_same_member_pointer_type< \
decltype(&RecursiveASTVisitor::Traverse##NAME), \
decltype(&Derived::Traverse##NAME)>::value, \
Derived &, RecursiveASTVisitor &>::type>(*this) \
Derived &, RecursiveASTVisitor &>>(*this) \
.Traverse##NAME(static_cast<CLASS *>(VAR), QUEUE) \
: getDerived().Traverse##NAME(static_cast<CLASS *>(VAR)))

View File

@ -516,8 +516,8 @@ public:
/// Requires \c T to be derived from \c From.
template <typename From>
Matcher(const Matcher<From> &Other,
typename std::enable_if<std::is_base_of<From, T>::value &&
!std::is_same<From, T>::value>::type * = nullptr)
std::enable_if_t<std::is_base_of<From, T>::value &&
!std::is_same<From, T>::value> * = nullptr)
: Implementation(restrictMatcher(Other.Implementation)) {
assert(Implementation.getSupportedKind().isSame(
ast_type_traits::ASTNodeKind::getFromNodeKind<T>()));
@ -528,9 +528,8 @@ public:
/// The resulting matcher is not strict, i.e. ignores qualifiers.
template <typename TypeT>
Matcher(const Matcher<TypeT> &Other,
typename std::enable_if<
std::is_same<T, QualType>::value &&
std::is_same<TypeT, Type>::value>::type* = nullptr)
std::enable_if_t<std::is_same<T, QualType>::value &&
std::is_same<TypeT, Type>::value> * = nullptr)
: Implementation(new TypeToQualType<TypeT>(Other)) {}
/// Convert \c this into a \c Matcher<T> by applying dyn_cast<> to the

View File

@ -624,10 +624,10 @@ class CFGBlock {
template <bool IsOtherConst> friend class ElementRefImpl;
using CFGBlockPtr =
typename std::conditional<IsConst, const CFGBlock *, CFGBlock *>::type;
std::conditional_t<IsConst, const CFGBlock *, CFGBlock *>;
using CFGElementPtr = typename std::conditional<IsConst, const CFGElement *,
CFGElement *>::type;
using CFGElementPtr =
std::conditional_t<IsConst, const CFGElement *, CFGElement *>;
protected:
CFGBlockPtr Parent;
@ -675,15 +675,14 @@ class CFGBlock {
friend class ElementRefIterator;
using CFGBlockRef =
typename std::conditional<IsConst, const CFGBlock *, CFGBlock *>::type;
std::conditional_t<IsConst, const CFGBlock *, CFGBlock *>;
using UnderlayingIteratorTy = typename std::conditional<
using UnderlayingIteratorTy = std::conditional_t<
IsConst,
typename std::conditional<IsReverse,
ElementList::const_reverse_iterator,
ElementList::const_iterator>::type,
typename std::conditional<IsReverse, ElementList::reverse_iterator,
ElementList::iterator>::type>::type;
std::conditional_t<IsReverse, ElementList::const_reverse_iterator,
ElementList::const_iterator>,
std::conditional_t<IsReverse, ElementList::reverse_iterator,
ElementList::iterator>>;
using IteratorTraits = typename std::iterator_traits<UnderlayingIteratorTy>;
using ElementRef = typename CFGBlock::ElementRefImpl<IsConst>;

View File

@ -1217,9 +1217,7 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB, int I) {
// We use enable_if here to prevent that this overload is selected for
// pointers or other arguments that are implicitly convertible to bool.
template <typename T>
inline
typename std::enable_if<std::is_same<T, bool>::value,
const DiagnosticBuilder &>::type
inline std::enable_if_t<std::is_same<T, bool>::value, const DiagnosticBuilder &>
operator<<(const DiagnosticBuilder &DB, T I) {
DB.AddTaggedVal(I, DiagnosticsEngine::ak_sint);
return DB;
@ -1249,9 +1247,9 @@ inline const DiagnosticBuilder &operator<<(const DiagnosticBuilder &DB,
// other arguments that derive from DeclContext (e.g., RecordDecls) will not
// match.
template <typename T>
inline typename std::enable_if<
std::is_same<typename std::remove_const<T>::type, DeclContext>::value,
const DiagnosticBuilder &>::type
inline std::enable_if_t<
std::is_same<std::remove_const_t<T>, DeclContext>::value,
const DiagnosticBuilder &>
operator<<(const DiagnosticBuilder &DB, T *DC) {
DB.AddTaggedVal(reinterpret_cast<intptr_t>(DC),
DiagnosticsEngine::ak_declcontext);

View File

@ -378,10 +378,9 @@ public:
// so that we only match those arguments that are (statically) DeclContexts;
// other arguments that derive from DeclContext (e.g., RecordDecls) will not
// match.
template<typename T>
friend inline
typename std::enable_if<std::is_same<T, DeclContext>::value,
const PartialDiagnostic &>::type
template <typename T>
friend inline std::enable_if_t<std::is_same<T, DeclContext>::value,
const PartialDiagnostic &>
operator<<(const PartialDiagnostic &PD, T *DC) {
PD.AddTaggedVal(reinterpret_cast<intptr_t>(DC),
DiagnosticsEngine::ak_declcontext);

View File

@ -20,8 +20,8 @@ namespace clang {
namespace tooling {
/// A refactoring option that stores a value of type \c T.
template <typename T, typename = typename std::enable_if<
traits::IsValidOptionType<T>::value>::type>
template <typename T,
typename = std::enable_if_t<traits::IsValidOptionType<T>::value>>
class OptionalRefactoringOption : public RefactoringOption {
public:
void passToVisitor(RefactoringOptionVisitor &Visitor) final override {
@ -39,8 +39,8 @@ protected:
};
/// A required refactoring option that stores a value of type \c T.
template <typename T, typename = typename std::enable_if<
traits::IsValidOptionType<T>::value>::type>
template <typename T,
typename = std::enable_if_t<traits::IsValidOptionType<T>::value>>
class RequiredRefactoringOption : public OptionalRefactoringOption<T> {
public:
using ValueType = T;

View File

@ -650,7 +650,7 @@ namespace clang {
template<typename IIter, typename OIter>
Error ImportArrayChecked(IIter Ibegin, IIter Iend, OIter Obegin) {
using ItemT = typename std::remove_reference<decltype(*Obegin)>::type;
using ItemT = std::remove_reference_t<decltype(*Obegin)>;
for (; Ibegin != Iend; ++Ibegin, ++Obegin) {
Expected<ItemT> ToOrErr = import(*Ibegin);
if (!ToOrErr)

View File

@ -85,14 +85,13 @@ class Boolean {
static Boolean max(unsigned NumBits) { return Boolean(true); }
template <typename T>
static typename std::enable_if<std::is_integral<T>::value, Boolean>::type
from(T Value) {
static std::enable_if_t<std::is_integral<T>::value, Boolean> from(T Value) {
return Boolean(Value != 0);
}
template <unsigned SrcBits, bool SrcSign>
static typename std::enable_if<SrcBits != 0, Boolean>::type from(
Integral<SrcBits, SrcSign> Value) {
static std::enable_if_t<SrcBits != 0, Boolean>
from(Integral<SrcBits, SrcSign> Value) {
return Boolean(!Value.isZero());
}

View File

@ -156,13 +156,12 @@ public:
}
template <typename T>
static typename std::enable_if<std::is_integral<T>::value, Integral>::type
from(T Value) {
static std::enable_if_t<std::is_integral<T>::value, Integral> from(T Value) {
return Integral(Value);
}
template <unsigned SrcBits, bool SrcSign>
static typename std::enable_if<SrcBits != 0, Integral>::type
static std::enable_if_t<SrcBits != 0, Integral>
from(Integral<SrcBits, SrcSign> Value) {
return Integral(Value.V);
}
@ -206,52 +205,52 @@ public:
private:
template <typename T>
static typename std::enable_if<std::is_signed<T>::value, bool>::type
CheckAddUB(T A, T B, T &R) {
static std::enable_if_t<std::is_signed<T>::value, bool> CheckAddUB(T A, T B,
T &R) {
return llvm::AddOverflow<T>(A, B, R);
}
template <typename T>
static typename std::enable_if<std::is_unsigned<T>::value, bool>::type
CheckAddUB(T A, T B, T &R) {
static std::enable_if_t<std::is_unsigned<T>::value, bool> CheckAddUB(T A, T B,
T &R) {
R = A + B;
return false;
}
template <typename T>
static typename std::enable_if<std::is_signed<T>::value, bool>::type
CheckSubUB(T A, T B, T &R) {
static std::enable_if_t<std::is_signed<T>::value, bool> CheckSubUB(T A, T B,
T &R) {
return llvm::SubOverflow<T>(A, B, R);
}
template <typename T>
static typename std::enable_if<std::is_unsigned<T>::value, bool>::type
CheckSubUB(T A, T B, T &R) {
static std::enable_if_t<std::is_unsigned<T>::value, bool> CheckSubUB(T A, T B,
T &R) {
R = A - B;
return false;
}
template <typename T>
static typename std::enable_if<std::is_signed<T>::value, bool>::type
CheckMulUB(T A, T B, T &R) {
static std::enable_if_t<std::is_signed<T>::value, bool> CheckMulUB(T A, T B,
T &R) {
return llvm::MulOverflow<T>(A, B, R);
}
template <typename T>
static typename std::enable_if<std::is_unsigned<T>::value, bool>::type
CheckMulUB(T A, T B, T &R) {
static std::enable_if_t<std::is_unsigned<T>::value, bool> CheckMulUB(T A, T B,
T &R) {
R = A * B;
return false;
}
template <typename T, T Min, T Max>
static typename std::enable_if<std::is_signed<T>::value, bool>::type
static std::enable_if_t<std::is_signed<T>::value, bool>
CheckRange(int64_t V) {
return Min <= V && V <= Max;
}
template <typename T, T Min, T Max>
static typename std::enable_if<std::is_unsigned<T>::value, bool>::type
static std::enable_if_t<std::is_unsigned<T>::value, bool>
CheckRange(int64_t V) {
return V >= 0 && static_cast<uint64_t>(V) <= Max;
}

View File

@ -56,14 +56,14 @@ private:
/// Helper to decode a value or a pointer.
template <typename T>
static typename std::enable_if<!std::is_pointer<T>::value, T>::type
static std::enable_if_t<!std::is_pointer<T>::value, T>
ReadHelper(const char *Ptr) {
using namespace llvm::support;
return endian::read<T, endianness::native, 1>(Ptr);
}
template <typename T>
static typename std::enable_if<std::is_pointer<T>::value, T>::type
static std::enable_if_t<std::is_pointer<T>::value, T>
ReadHelper(const char *Ptr) {
using namespace llvm::support;
auto Punned = endian::read<uintptr_t, endianness::native, 1>(Ptr);

View File

@ -1249,8 +1249,7 @@ static StringRef ClassifyDiagnostic(const ValueDecl *VD) {
}
template <typename AttrTy>
static typename std::enable_if<!has_arg_iterator_range<AttrTy>::value,
StringRef>::type
static std::enable_if_t<!has_arg_iterator_range<AttrTy>::value, StringRef>
ClassifyDiagnostic(const AttrTy *A) {
if (const ValueDecl *VD = getValueDecl(A->getArg()))
return ClassifyDiagnostic(VD);
@ -1258,8 +1257,7 @@ ClassifyDiagnostic(const AttrTy *A) {
}
template <typename AttrTy>
static typename std::enable_if<has_arg_iterator_range<AttrTy>::value,
StringRef>::type
static std::enable_if_t<has_arg_iterator_range<AttrTy>::value, StringRef>
ClassifyDiagnostic(const AttrTy *A) {
for (const auto *Arg : A->args()) {
if (const ValueDecl *VD = getValueDecl(Arg))

View File

@ -80,11 +80,10 @@ public:
template <typename Callable>
RegionCodeGenTy(
Callable &&CodeGen,
typename std::enable_if<
!std::is_same<typename std::remove_reference<Callable>::type,
RegionCodeGenTy>::value>::type * = nullptr)
std::enable_if_t<!std::is_same<std::remove_reference_t<Callable>,
RegionCodeGenTy>::value> * = nullptr)
: CodeGen(reinterpret_cast<intptr_t>(&CodeGen)),
Callback(CallbackFn<typename std::remove_reference<Callable>::type>),
Callback(CallbackFn<std::remove_reference_t<Callable>>),
PrePostAction(nullptr) {}
void setAction(PrePostActionTy &Action) const { PrePostAction = &Action; }
void operator()(CodeGenFunction &CGF) const;

View File

@ -225,8 +225,7 @@ static bool checkAttributeAtMostNumArgs(Sema &S, const ParsedAttr &AL,
/// A helper function to provide Attribute Location for the Attr types
/// AND the ParsedAttr.
template <typename AttrInfo>
static typename std::enable_if<std::is_base_of<Attr, AttrInfo>::value,
SourceLocation>::type
static std::enable_if_t<std::is_base_of<Attr, AttrInfo>::value, SourceLocation>
getAttrLoc(const AttrInfo &AL) {
return AL.getLocation();
}

View File

@ -2747,8 +2747,8 @@ CheckDeducedArgumentConstraints(Sema& S, TemplateDeclT *Template,
/// Complete template argument deduction for a partial specialization.
template <typename T>
static typename std::enable_if<IsPartialSpecialization<T>::value,
Sema::TemplateDeductionResult>::type
static std::enable_if_t<IsPartialSpecialization<T>::value,
Sema::TemplateDeductionResult>
FinishTemplateArgumentDeduction(
Sema &S, T *Partial, bool IsPartialOrdering,
const TemplateArgumentList &TemplateArgs,

View File

@ -51,11 +51,10 @@ using CheckerNameLT = FullNameLT<CheckerRegistry::CheckerInfo>;
} // end of anonymous namespace
template <class CheckerOrPackageInfoList>
static
typename std::conditional<std::is_const<CheckerOrPackageInfoList>::value,
typename CheckerOrPackageInfoList::const_iterator,
typename CheckerOrPackageInfoList::iterator>::type
binaryFind(CheckerOrPackageInfoList &Collection, StringRef FullName) {
static std::conditional_t<std::is_const<CheckerOrPackageInfoList>::value,
typename CheckerOrPackageInfoList::const_iterator,
typename CheckerOrPackageInfoList::iterator>
binaryFind(CheckerOrPackageInfoList &Collection, StringRef FullName) {
using CheckerOrPackage = typename CheckerOrPackageInfoList::value_type;
using CheckerOrPackageFullNameLT = FullNameLT<CheckerOrPackage>;

View File

@ -117,12 +117,12 @@ public:
Impl(SyntaxTree *Parent, Stmt *N, ASTContext &AST);
template <class T>
Impl(SyntaxTree *Parent,
typename std::enable_if<std::is_base_of<Stmt, T>::value, T>::type *Node,
std::enable_if_t<std::is_base_of<Stmt, T>::value, T> *Node,
ASTContext &AST)
: Impl(Parent, dyn_cast<Stmt>(Node), AST) {}
template <class T>
Impl(SyntaxTree *Parent,
typename std::enable_if<std::is_base_of<Decl, T>::value, T>::type *Node,
std::enable_if_t<std::is_base_of<Decl, T>::value, T> *Node,
ASTContext &AST)
: Impl(Parent, dyn_cast<Decl>(Node), AST) {}

View File

@ -101,22 +101,22 @@ void checkDeclName(const SelectedASTNode &Node, StringRef Name) {
}
template <typename T>
const SelectedASTNode &
checkNode(const SelectedASTNode &StmtNode, SourceSelectionKind SelectionKind,
unsigned NumChildren = 0,
typename std::enable_if<std::is_base_of<Stmt, T>::value, T>::type
*StmtOverloadChecker = nullptr) {
const SelectedASTNode &checkNode(
const SelectedASTNode &StmtNode, SourceSelectionKind SelectionKind,
unsigned NumChildren = 0,
std::enable_if_t<std::is_base_of<Stmt, T>::value, T> *StmtOverloadChecker =
nullptr) {
checkNodeImpl(isa<T>(StmtNode.Node.get<Stmt>()), StmtNode, SelectionKind,
NumChildren);
return StmtNode;
}
template <typename T>
const SelectedASTNode &
checkNode(const SelectedASTNode &DeclNode, SourceSelectionKind SelectionKind,
unsigned NumChildren = 0, StringRef Name = "",
typename std::enable_if<std::is_base_of<Decl, T>::value, T>::type
*DeclOverloadChecker = nullptr) {
const SelectedASTNode &checkNode(
const SelectedASTNode &DeclNode, SourceSelectionKind SelectionKind,
unsigned NumChildren = 0, StringRef Name = "",
std::enable_if_t<std::is_base_of<Decl, T>::value, T> *DeclOverloadChecker =
nullptr) {
checkNodeImpl(isa<T>(DeclNode.Node.get<Decl>()), DeclNode, SelectionKind,
NumChildren);
if (!Name.empty())