jurahul updated this revision to Diff 269870. jurahul added a comment. Split isa<> changes into its own change
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D81045/new/ https://reviews.llvm.org/D81045 Files: clang/include/clang/AST/DeclBase.h llvm/include/llvm/Support/Casting.h llvm/lib/Analysis/ScalarEvolution.cpp llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp Index: llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp =================================================================== --- llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp +++ llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp @@ -220,7 +220,7 @@ 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 Index: llvm/lib/Analysis/ScalarEvolution.cpp =================================================================== --- llvm/lib/Analysis/ScalarEvolution.cpp +++ llvm/lib/Analysis/ScalarEvolution.cpp @@ -3860,7 +3860,8 @@ 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 @@ // 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; } Index: llvm/include/llvm/Support/Casting.h =================================================================== --- llvm/include/llvm/Support/Casting.h +++ llvm/include/llvm/Support/Casting.h @@ -132,24 +132,31 @@ } }; -// 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 argument. 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... Rest, typename Y> +LLVM_NODISCARD inline typename std::enable_if<sizeof...(Rest) != 0, bool>::type +isa(const Y &Val) { + return isa<First>(Val) || isa<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); } //===----------------------------------------------------------------------===// Index: clang/include/clang/AST/DeclBase.h =================================================================== --- clang/include/clang/AST/DeclBase.h +++ clang/include/clang/AST/DeclBase.h @@ -518,7 +518,9 @@ if (!HasAttrs) return; AttrVec &Vec = getAttrs(); - Vec.erase(std::remove_if(Vec.begin(), Vec.end(), isa<T, Attr*>), Vec.end()); + Vec.erase(std::remove_if(Vec.begin(), Vec.end(), + [](Attr *A) { return isa<T>(A); }), + Vec.end()); if (Vec.empty()) HasAttrs = false;
Index: llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp =================================================================== --- llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp +++ llvm/lib/Target/PowerPC/PPCBoolRetToInt.cpp @@ -220,7 +220,7 @@ 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 Index: llvm/lib/Analysis/ScalarEvolution.cpp =================================================================== --- llvm/lib/Analysis/ScalarEvolution.cpp +++ llvm/lib/Analysis/ScalarEvolution.cpp @@ -3860,7 +3860,8 @@ 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 @@ // 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; } Index: llvm/include/llvm/Support/Casting.h =================================================================== --- llvm/include/llvm/Support/Casting.h +++ llvm/include/llvm/Support/Casting.h @@ -132,24 +132,31 @@ } }; -// 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 argument. 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... Rest, typename Y> +LLVM_NODISCARD inline typename std::enable_if<sizeof...(Rest) != 0, bool>::type +isa(const Y &Val) { + return isa<First>(Val) || isa<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); } //===----------------------------------------------------------------------===// Index: clang/include/clang/AST/DeclBase.h =================================================================== --- clang/include/clang/AST/DeclBase.h +++ clang/include/clang/AST/DeclBase.h @@ -518,7 +518,9 @@ if (!HasAttrs) return; AttrVec &Vec = getAttrs(); - Vec.erase(std::remove_if(Vec.begin(), Vec.end(), isa<T, Attr*>), Vec.end()); + Vec.erase(std::remove_if(Vec.begin(), Vec.end(), + [](Attr *A) { return isa<T>(A); }), + Vec.end()); if (Vec.empty()) HasAttrs = false;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits