Skip to content

Commit

Permalink
[StaticAnalyzer] Use std::optional in BugReporterVisitors.cpp (NFC)
Browse files Browse the repository at this point in the history
This is part of an effort to migrate from llvm::Optional to
std::optional:

https://discourse.llvm.org/t/deprecating-llvm-optional-x-hasvalue-getvalue-getvalueor/63716
  • Loading branch information
kazutakahirata committed Dec 11, 2022
1 parent 602af71 commit a67a115
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
Expand Up @@ -205,8 +205,8 @@ static bool hasVisibleUpdate(const ExplodedNode *LeftNode, SVal LeftVal,
RLCV->getStore() == RightNode->getState()->getStore();
}

static Optional<SVal> getSValForVar(const Expr *CondVarExpr,
const ExplodedNode *N) {
static std::optional<SVal> getSValForVar(const Expr *CondVarExpr,
const ExplodedNode *N) {
ProgramStateRef State = N->getState();
const LocationContext *LCtx = N->getLocationContext();

Expand All @@ -229,10 +229,10 @@ static Optional<SVal> getSValForVar(const Expr *CondVarExpr,
return std::nullopt;
}

static Optional<const llvm::APSInt *>
static std::optional<const llvm::APSInt *>
getConcreteIntegerValue(const Expr *CondVarExpr, const ExplodedNode *N) {

if (Optional<SVal> V = getSValForVar(CondVarExpr, N))
if (std::optional<SVal> V = getSValForVar(CondVarExpr, N))
if (auto CI = V->getAs<nonloc::ConcreteInt>())
return &CI->getValue();
return std::nullopt;
Expand All @@ -247,7 +247,7 @@ static bool isVarAnInterestingCondition(const Expr *CondVarExpr,
if (!B->getErrorNode()->getStackFrame()->isParentOf(N->getStackFrame()))
return false;

if (Optional<SVal> V = getSValForVar(CondVarExpr, N))
if (std::optional<SVal> V = getSValForVar(CondVarExpr, N))
if (Optional<bugreporter::TrackingKind> K = B->getInterestingnessKind(*V))
return *K == bugreporter::TrackingKind::Condition;

Expand All @@ -256,7 +256,7 @@ static bool isVarAnInterestingCondition(const Expr *CondVarExpr,

static bool isInterestingExpr(const Expr *E, const ExplodedNode *N,
const PathSensitiveBugReport *B) {
if (Optional<SVal> V = getSValForVar(E, N))
if (std::optional<SVal> V = getSValForVar(E, N))
return B->getInterestingnessKind(*V).has_value();
return false;
}
Expand Down Expand Up @@ -3244,7 +3244,7 @@ bool ConditionBRVisitor::printValue(const Expr *CondVarExpr, raw_ostream &Out,
if (!Ty->isIntegralOrEnumerationType())
return false;

Optional<const llvm::APSInt *> IntValue;
std::optional<const llvm::APSInt *> IntValue;
if (!IsAssuming)
IntValue = getConcreteIntegerValue(CondVarExpr, N);

Expand Down

0 comments on commit a67a115

Please sign in to comment.