From a67a11536e1cfaec0e02a740b5a77f0db4e1481a Mon Sep 17 00:00:00 2001 From: Kazu Hirata Date: Sat, 10 Dec 2022 21:11:31 -0800 Subject: [PATCH] [StaticAnalyzer] Use std::optional in BugReporterVisitors.cpp (NFC) 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 --- clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp index 811fd03..e36716f 100644 --- a/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp +++ b/clang/lib/StaticAnalyzer/Core/BugReporterVisitors.cpp @@ -205,8 +205,8 @@ static bool hasVisibleUpdate(const ExplodedNode *LeftNode, SVal LeftVal, RLCV->getStore() == RightNode->getState()->getStore(); } -static Optional getSValForVar(const Expr *CondVarExpr, - const ExplodedNode *N) { +static std::optional getSValForVar(const Expr *CondVarExpr, + const ExplodedNode *N) { ProgramStateRef State = N->getState(); const LocationContext *LCtx = N->getLocationContext(); @@ -229,10 +229,10 @@ static Optional getSValForVar(const Expr *CondVarExpr, return std::nullopt; } -static Optional +static std::optional getConcreteIntegerValue(const Expr *CondVarExpr, const ExplodedNode *N) { - if (Optional V = getSValForVar(CondVarExpr, N)) + if (std::optional V = getSValForVar(CondVarExpr, N)) if (auto CI = V->getAs()) return &CI->getValue(); return std::nullopt; @@ -247,7 +247,7 @@ static bool isVarAnInterestingCondition(const Expr *CondVarExpr, if (!B->getErrorNode()->getStackFrame()->isParentOf(N->getStackFrame())) return false; - if (Optional V = getSValForVar(CondVarExpr, N)) + if (std::optional V = getSValForVar(CondVarExpr, N)) if (Optional K = B->getInterestingnessKind(*V)) return *K == bugreporter::TrackingKind::Condition; @@ -256,7 +256,7 @@ static bool isVarAnInterestingCondition(const Expr *CondVarExpr, static bool isInterestingExpr(const Expr *E, const ExplodedNode *N, const PathSensitiveBugReport *B) { - if (Optional V = getSValForVar(E, N)) + if (std::optional V = getSValForVar(E, N)) return B->getInterestingnessKind(*V).has_value(); return false; } @@ -3244,7 +3244,7 @@ bool ConditionBRVisitor::printValue(const Expr *CondVarExpr, raw_ostream &Out, if (!Ty->isIntegralOrEnumerationType()) return false; - Optional IntValue; + std::optional IntValue; if (!IsAssuming) IntValue = getConcreteIntegerValue(CondVarExpr, N); -- 2.7.4