summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2017-08-18 15:08:33 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2017-08-18 15:08:33 +0200
commit84c0687f092d2e6f21560dd8a6d6401a38f2afa3 (patch)
tree2efd5b901bd45cabeefbdd5f5fe67c76b1c0da0c
parent39cc076cb66071c1522fb554a1469c039b6b5770 (diff)
don't use boost in compilerplugins
Change-Id: Ic1610e99cd2d11d1a536a6f3e66b44417ee59793
-rw-r--r--compilerplugins/clang/expressionalwayszero.cxx13
1 files changed, 6 insertions, 7 deletions
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