From 75dd5d2e734ad9e8265b1954c7496d1ba241079e Mon Sep 17 00:00:00 2001 From: Noel Grandin Date: Tue, 27 Nov 2018 12:56:12 +0200 Subject: add EvaluateAsInt compat function for latest clang the old EvaluateAsInt method has been dropped as from current clang Change-Id: Ie30d1547ad8de777badff4b380d2fc9fb261e8fe Reviewed-on: https://gerrit.libreoffice.org/64107 Tested-by: Jenkins Reviewed-by: Noel Grandin --- compilerplugins/clang/compat.hxx | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'compilerplugins/clang/compat.hxx') diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx index 4733cd332e5e..97410fcbdc7a 100644 --- a/compilerplugins/clang/compat.hxx +++ b/compilerplugins/clang/compat.hxx @@ -156,6 +156,18 @@ inline bool CPlusPlus17(clang::LangOptions const & opts) { #endif } +inline bool EvaluateAsInt(clang::Expr const * expr, llvm::APSInt& intRes, const clang::ASTContext& ctx) { +#if CLANG_VERSION >= 80000 + clang::Expr::EvalResult res; + bool b = expr->EvaluateAsInt(res, ctx); + if (b && res.Val.isInt()) + intRes = res.Val.getInt(); + return b; +#else + return expr->EvaluateAsInt(intRes, ctx); +#endif +} + // Work around : // // SfxErrorHandler::GetClassString (svtools/source/misc/ehdl.cxx): -- cgit