diff options
Diffstat (limited to 'clang/lib/Analysis/UninitializedValues.cpp')
-rw-r--r-- | clang/lib/Analysis/UninitializedValues.cpp | 23 |
1 files changed, 10 insertions, 13 deletions
diff --git a/clang/lib/Analysis/UninitializedValues.cpp b/clang/lib/Analysis/UninitializedValues.cpp index 7f44685355e0..2437095a22cf 100644 --- a/clang/lib/Analysis/UninitializedValues.cpp +++ b/clang/lib/Analysis/UninitializedValues.cpp @@ -28,14 +28,13 @@ #include "clang/Basic/LLVM.h" #include "llvm/ADT/BitVector.h" #include "llvm/ADT/DenseMap.h" -#include "llvm/ADT/None.h" -#include "llvm/ADT/Optional.h" #include "llvm/ADT/PackedVector.h" #include "llvm/ADT/SmallBitVector.h" #include "llvm/ADT/SmallVector.h" #include "llvm/Support/Casting.h" #include <algorithm> #include <cassert> +#include <optional> using namespace clang; @@ -46,7 +45,8 @@ static bool isTrackedVar(const VarDecl *vd, const DeclContext *dc) { !vd->isExceptionVariable() && !vd->isInitCapture() && !vd->isImplicit() && vd->getDeclContext() == dc) { QualType ty = vd->getType(); - return ty->isScalarType() || ty->isVectorType() || ty->isRecordType(); + return ty->isScalarType() || ty->isVectorType() || ty->isRecordType() || + ty->isRVVType(); } return false; } @@ -70,7 +70,7 @@ public: unsigned size() const { return map.size(); } /// Returns the bit vector index for a given declaration. - Optional<unsigned> getValueIndex(const VarDecl *d) const; + std::optional<unsigned> getValueIndex(const VarDecl *d) const; }; } // namespace @@ -86,10 +86,10 @@ void DeclToIndex::computeMap(const DeclContext &dc) { } } -Optional<unsigned> DeclToIndex::getValueIndex(const VarDecl *d) const { +std::optional<unsigned> DeclToIndex::getValueIndex(const VarDecl *d) const { llvm::DenseMap<const VarDecl *, unsigned>::const_iterator I = map.find(d); if (I == map.end()) - return None; + return std::nullopt; return I->second; } @@ -147,9 +147,8 @@ public: Value getValue(const CFGBlock *block, const CFGBlock *dstBlock, const VarDecl *vd) { - const Optional<unsigned> &idx = declToIndex.getValueIndex(vd); - assert(idx); - return getValueVector(block)[idx.value()]; + std::optional<unsigned> idx = declToIndex.getValueIndex(vd); + return getValueVector(block)[*idx]; } }; @@ -208,9 +207,7 @@ void CFGBlockValues::resetScratch() { } ValueVector::reference CFGBlockValues::operator[](const VarDecl *vd) { - const Optional<unsigned> &idx = declToIndex.getValueIndex(vd); - assert(idx); - return scratch[idx.value()]; + return scratch[*declToIndex.getValueIndex(vd)]; } //------------------------------------------------------------------------====// @@ -861,7 +858,7 @@ static bool runOnBlock(const CFGBlock *block, const CFG &cfg, // Apply the transfer function. TransferFunctions tf(vals, cfg, block, ac, classification, handler); for (const auto &I : *block) { - if (Optional<CFGStmt> cs = I.getAs<CFGStmt>()) + if (std::optional<CFGStmt> cs = I.getAs<CFGStmt>()) tf.Visit(const_cast<Stmt *>(cs->getStmt())); } CFGTerminator terminator = block->getTerminator(); |