diff options
Diffstat (limited to 'compilerplugins/clang/pointerbool.cxx')
-rw-r--r-- | compilerplugins/clang/pointerbool.cxx | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/compilerplugins/clang/pointerbool.cxx b/compilerplugins/clang/pointerbool.cxx index 6886e1fac63f..6530c76e7179 100644 --- a/compilerplugins/clang/pointerbool.cxx +++ b/compilerplugins/clang/pointerbool.cxx @@ -16,6 +16,7 @@ #include <clang/AST/CXXInheritance.h> #include "plugin.hxx" #include "check.hxx" +#include "compat.hxx" /** Look for calls where the param is bool but the call-site-arg is pointer. @@ -46,7 +47,7 @@ public: bool VisitCallExpr(CallExpr const*); private: - llvm::Optional<APSInt> getCallValue(const Expr* arg); + compat::optional<APSInt> getCallValue(const Expr* arg); std::vector<FunctionDecl*> functions_; }; @@ -114,7 +115,7 @@ bool PointerBool::VisitCallExpr(CallExpr const* callExpr) if (arg->getType()->isIntegerType()) { auto ret = getCallValue(arg); - if (ret.hasValue() && (ret.getValue() == 1 || ret.getValue() == 0)) + if (compat::has_value(ret) && (compat::value(ret) == 1 || compat::value(ret) == 0)) continue; // something like: priv->m_nLOKFeatures & LOK_FEATURE_DOCUMENT_PASSWORD if (isa<BinaryOperator>(arg->IgnoreParenImpCasts())) @@ -139,7 +140,7 @@ bool PointerBool::VisitCallExpr(CallExpr const* callExpr) return true; } -llvm::Optional<APSInt> PointerBool::getCallValue(const Expr* arg) +compat::optional<APSInt> PointerBool::getCallValue(const Expr* arg) { arg = arg->IgnoreParenCasts(); if (auto defArg = dyn_cast<CXXDefaultArgExpr>(arg)) @@ -149,14 +150,14 @@ llvm::Optional<APSInt> PointerBool::getCallValue(const Expr* arg) // ignore this, it seems to trigger an infinite recursion if (isa<UnaryExprOrTypeTraitExpr>(arg)) { - return llvm::Optional<APSInt>(); + return compat::optional<APSInt>(); } APSInt x1; if (compat::EvaluateAsInt(arg, x1, compiler.getASTContext())) { return x1; } - return llvm::Optional<APSInt>(); + return compat::optional<APSInt>(); } loplugin::Plugin::Registration<PointerBool> pointerbool("pointerbool"); |