diff options
Diffstat (limited to 'compilerplugins')
-rw-r--r-- | compilerplugins/clang/compat.hxx | 7 | ||||
-rw-r--r-- | compilerplugins/clang/redundantcast.cxx | 8 |
2 files changed, 11 insertions, 4 deletions
diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx index 897d9fe855c0..f62061ed48e4 100644 --- a/compilerplugins/clang/compat.hxx +++ b/compilerplugins/clang/compat.hxx @@ -17,6 +17,7 @@ #include "clang/AST/Expr.h" #include "clang/AST/ExprCXX.h" #include "clang/Basic/SourceManager.h" +#include "clang/Basic/Specifiers.h" #include "clang/Frontend/CompilerInstance.h" #include "clang/Lex/Lexer.h" #include "llvm/ADT/StringRef.h" @@ -169,6 +170,12 @@ inline bool CPlusPlus17(clang::LangOptions const & opts) { #endif } +#if CLANG_VERSION >= 130000 +constexpr clang::ExprValueKind VK_PRValue = clang::VK_PRValue; +#else +constexpr clang::ExprValueKind VK_PRValue = clang::VK_RValue; +#endif + inline bool EvaluateAsInt(clang::Expr const * expr, llvm::APSInt& intRes, const clang::ASTContext& ctx) { #if CLANG_VERSION >= 80000 clang::Expr::EvalResult res; diff --git a/compilerplugins/clang/redundantcast.cxx b/compilerplugins/clang/redundantcast.cxx index afc1cb414681..088349fa1d9c 100644 --- a/compilerplugins/clang/redundantcast.cxx +++ b/compilerplugins/clang/redundantcast.cxx @@ -51,12 +51,12 @@ bool canConstCastFromTo(Expr const * from, Expr const * to) { auto const k2 = to->getValueKind(); return (k2 == VK_LValue && k1 == VK_LValue) || (k2 == VK_XValue - && (k1 != VK_RValue || from->getType()->isRecordType())); + && (k1 != compat::VK_PRValue || from->getType()->isRecordType())); } char const * printExprValueKind(ExprValueKind k) { switch (k) { - case VK_RValue: + case compat::VK_PRValue: return "prvalue"; case VK_LValue: return "lvalue"; @@ -539,7 +539,7 @@ bool RedundantCast::VisitCXXStaticCastExpr(CXXStaticCastExpr const * expr) { " written as an explicit construction of a temporary}4"), expr->getExprLoc()) << t1 << printExprValueKind(k1) << t2 << printExprValueKind(k3) - << (k3 == VK_RValue && (k1 != VK_RValue || t1->isRecordType())) + << (k3 == compat::VK_PRValue && (k1 != compat::VK_PRValue || t1->isRecordType())) << expr->getSourceRange(); return true; } @@ -726,7 +726,7 @@ bool RedundantCast::VisitCXXFunctionalCastExpr(CXXFunctionalCastExpr const * exp auto const t1 = expr->getTypeAsWritten(); bool const fnptr = t1->isFunctionPointerType() || t1->isMemberFunctionPointerType(); auto const sub = fnptr ? stopAtFunctionPointerDecay(expr) : compat::getSubExprAsWritten(expr); - if ((sub->getValueKind() != VK_RValue && !fnptr) || expr->getType()->isRecordType() + if ((sub->getValueKind() != compat::VK_PRValue && !fnptr) || expr->getType()->isRecordType() || isa<InitListExpr>(sub) || isa<CXXStdInitializerListExpr>(sub)) { return true; |