summaryrefslogtreecommitdiff
path: root/compilerplugins/clang/compat.hxx
diff options
context:
space:
mode:
Diffstat (limited to 'compilerplugins/clang/compat.hxx')
-rw-r--r--compilerplugins/clang/compat.hxx11
1 files changed, 11 insertions, 0 deletions
diff --git a/compilerplugins/clang/compat.hxx b/compilerplugins/clang/compat.hxx
index 76f076621394..8a1a728bd95b 100644
--- a/compilerplugins/clang/compat.hxx
+++ b/compilerplugins/clang/compat.hxx
@@ -174,6 +174,17 @@ inline bool EvaluateAsInt(clang::Expr const * expr, llvm::APSInt& intRes, const
#endif
}
+inline llvm::Optional<llvm::APSInt> getIntegerConstantExpr(
+ clang::Expr const * expr, clang::ASTContext const & context)
+{
+#if CLANG_VERSION >= 120000
+ return expr->getIntegerConstantExpr(context);
+#else
+ llvm::APSInt res;
+ return expr->isIntegerConstantExpr(res, context) ? res : llvm::Optional<llvm::APSInt>();
+#endif
+}
+
inline clang::Expr * getSubExpr(clang::MaterializeTemporaryExpr const * expr) {
#if CLANG_VERSION >= 100000
return expr->getSubExpr();