summaryrefslogtreecommitdiff
path: root/compilerplugins/clang
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2021-06-10 14:27:49 +0200
committerStephan Bergmann <sbergman@redhat.com>2021-06-10 15:42:45 +0200
commit3732bba5e2b5ca5890be1fc3d09455248b81c763 (patch)
tree952b19bc66fed70f123392863499277d8c38b28b /compilerplugins/clang
parenta774d3295f84c5c4df26274edec2778ea3c3dc59 (diff)
Adapt compilerplugins to Clang VK_RValue -> VK_PRValue rename
<https://github.com/llvm/llvm-project/commit/aef5d8fdc7d0d348125d5ecf4a13be5888eb1654> "[clang] NFC: Rename rvalue to prvalue" Change-Id: I237e8a491465500e35637f8dae400402bcd9411d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/116983 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'compilerplugins/clang')
-rw-r--r--compilerplugins/clang/compat.hxx7
-rw-r--r--compilerplugins/clang/redundantcast.cxx8
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;