summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/compat.hxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-11-27 12:56:12 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-11-27 17:16:05 +0100
commit75dd5d2e734ad9e8265b1954c7496d1ba241079e (patch)
treeb3a694e1bbe01dcdfc917a01d44c36bde39e850b /compilerplugins/clang/compat.hxx
parentecdf05d1b93529a0b1edda04d0f89c08cf580308 (diff)
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 <noel.grandin@collabora.co.uk>
Diffstat (limited to 'compilerplugins/clang/compat.hxx')
-rw-r--r--compilerplugins/clang/compat.hxx12
1 files changed, 12 insertions, 0 deletions
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 <http://reviews.llvm.org/D22128>:
//
// SfxErrorHandler::GetClassString (svtools/source/misc/ehdl.cxx):