[Libreoffice-commits] core.git: compilerplugins/clang
Noel Grandin
noel.grandin at collabora.co.uk
Fri Aug 18 13:11:57 UTC 2017
compilerplugins/clang/expressionalwayszero.cxx | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
New commits:
commit 84c0687f092d2e6f21560dd8a6d6401a38f2afa3
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date: Fri Aug 18 15:08:33 2017 +0200
don't use boost in compilerplugins
Change-Id: Ic1610e99cd2d11d1a536a6f3e66b44417ee59793
diff --git a/compilerplugins/clang/expressionalwayszero.cxx b/compilerplugins/clang/expressionalwayszero.cxx
index 1090d9d9765b..f10528e8954a 100644
--- a/compilerplugins/clang/expressionalwayszero.cxx
+++ b/compilerplugins/clang/expressionalwayszero.cxx
@@ -12,8 +12,6 @@
#include <iostream>
#include <fstream>
-#include <boost/optional.hpp>
-
#include "plugin.hxx"
#include "compat.hxx"
#include "check.hxx"
@@ -50,7 +48,8 @@ public:
bool VisitCXXOperatorCallExpr(CXXOperatorCallExpr const *);
bool TraverseStaticAssertDecl(StaticAssertDecl *);
private:
- boost::optional<APSInt> getExprValue(const Expr* arg);
+ // note, abusing std::unique_ptr as a std::optional lookalike
+ std::unique_ptr<APSInt> getExprValue(const Expr* arg);
};
bool ExpressionAlwaysZero::VisitBinaryOperator( BinaryOperator const * binaryOperator )
@@ -97,17 +96,17 @@ bool ExpressionAlwaysZero::VisitCXXOperatorCallExpr( CXXOperatorCallExpr const *
return true;
}
-boost::optional<APSInt> ExpressionAlwaysZero::getExprValue(Expr const * expr)
+std::unique_ptr<APSInt> ExpressionAlwaysZero::getExprValue(Expr const * expr)
{
expr = expr->IgnoreParenCasts();
// ignore this, it seems to trigger an infinite recursion
if (isa<UnaryExprOrTypeTraitExpr>(expr)) {
- return boost::optional<APSInt>();
+ return std::unique_ptr<APSInt>();
}
APSInt x1;
if (expr->EvaluateAsInt(x1, compiler.getASTContext()))
- return x1;
- return boost::optional<APSInt>();
+ return std::unique_ptr<APSInt>(new APSInt(x1));
+ return std::unique_ptr<APSInt>();
}
// these will often evaluate to zero harmlessly
More information about the Libreoffice-commits
mailing list