mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 04:02:41 +01:00
[LLVM] Change isa<> to a variadic function template
Change isa<> to a variadic function template, so that it can be used to test against one of multiple types as follows: isa<Type0, Type1, Type2>(Val) Differential Revision: https://reviews.llvm.org/D81045
This commit is contained in:
parent
74fefe7dbd
commit
b474372d7b
@ -132,24 +132,30 @@ struct isa_impl_wrap<To, FromTy, FromTy> {
|
||||
}
|
||||
};
|
||||
|
||||
// isa<X> - Return true if the parameter to the template is an instance of the
|
||||
// template type argument. Used like this:
|
||||
// isa<X> - Return true if the parameter to the template is an instance of one
|
||||
// of the template type arguments. Used like this:
|
||||
//
|
||||
// if (isa<Type>(myVal)) { ... }
|
||||
// if (isa<Type0, Type1, Type2>(myVal)) { ... }
|
||||
//
|
||||
template <class X, class Y> LLVM_NODISCARD inline bool isa(const Y &Val) {
|
||||
return isa_impl_wrap<X, const Y,
|
||||
typename simplify_type<const Y>::SimpleType>::doit(Val);
|
||||
}
|
||||
|
||||
template <typename First, typename Second, typename... Rest, typename Y>
|
||||
LLVM_NODISCARD inline bool isa(const Y &Val) {
|
||||
return isa<First>(Val) || isa<Second, Rest...>(Val);
|
||||
}
|
||||
|
||||
// isa_and_nonnull<X> - Functionally identical to isa, except that a null value
|
||||
// is accepted.
|
||||
//
|
||||
template <class X, class Y>
|
||||
template <typename... X, class Y>
|
||||
LLVM_NODISCARD inline bool isa_and_nonnull(const Y &Val) {
|
||||
if (!Val)
|
||||
return false;
|
||||
return isa<X>(Val);
|
||||
return isa<X...>(Val);
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -3860,7 +3860,8 @@ bool ScalarEvolution::containsAddRecurrence(const SCEV *S) {
|
||||
if (I != HasRecMap.end())
|
||||
return I->second;
|
||||
|
||||
bool FoundAddRec = SCEVExprContains(S, isa<SCEVAddRecExpr, const SCEV *>);
|
||||
bool FoundAddRec =
|
||||
SCEVExprContains(S, [](const SCEV *S) { return isa<SCEVAddRecExpr>(S); });
|
||||
HasRecMap.insert({S, FoundAddRec});
|
||||
return FoundAddRec;
|
||||
}
|
||||
@ -11201,8 +11202,9 @@ static bool findArrayDimensionsRec(ScalarEvolution &SE,
|
||||
// Returns true when one of the SCEVs of Terms contains a SCEVUnknown parameter.
|
||||
static inline bool containsParameters(SmallVectorImpl<const SCEV *> &Terms) {
|
||||
for (const SCEV *T : Terms)
|
||||
if (SCEVExprContains(T, isa<SCEVUnknown, const SCEV *>))
|
||||
if (SCEVExprContains(T, [](const SCEV *S) { return isa<SCEVUnknown>(S); }))
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -220,7 +220,7 @@ class PPCBoolRetToInt : public FunctionPass {
|
||||
auto Defs = findAllDefs(U);
|
||||
|
||||
// If the values are all Constants or Arguments, don't bother
|
||||
if (llvm::none_of(Defs, isa<Instruction, Value *>))
|
||||
if (llvm::none_of(Defs, [](Value *V) { return isa<Instruction>(V); }))
|
||||
return false;
|
||||
|
||||
// Presently, we only know how to handle PHINode, Constant, Arguments and
|
||||
|
Loading…
Reference in New Issue
Block a user