[clang] 1cb7fba - [StaticAnalyzer] Don't use Optional<T>::create (NFC)
Kazu Hirata via cfe-commits
cfe-commits at lists.llvm.org
Sat Dec 10 12:35:09 PST 2022
Author: Kazu Hirata
Date: 2022-12-10T12:35:03-08:00
New Revision: 1cb7fba3e57d6c31f05c7a2bda1634da49dd1d18
URL: https://github.com/llvm/llvm-project/commit/1cb7fba3e57d6c31f05c7a2bda1634da49dd1d18
DIFF: https://github.com/llvm/llvm-project/commit/1cb7fba3e57d6c31f05c7a2bda1634da49dd1d18.diff
LOG: [StaticAnalyzer] Don't use Optional<T>::create (NFC)
std::optional<T> does not have an equivalent method.
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
Added:
Modified:
clang/lib/StaticAnalyzer/Core/RegionStore.cpp
Removed:
################################################################################
diff --git a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
index f5959b26dd92..db8a5c5c38c8 100644
--- a/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ b/clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -263,11 +263,13 @@ class RegionBindingsRef : public llvm::ImmutableMapRef<const MemRegion *,
typedef const RegionBindingsRef& RegionBindingsConstRef;
Optional<SVal> RegionBindingsRef::getDirectBinding(const MemRegion *R) const {
- return Optional<SVal>::create(lookup(R, BindingKey::Direct));
+ const SVal *V = lookup(R, BindingKey::Direct);
+ return V ? Optional<SVal>(*V) : std::nullopt;
}
Optional<SVal> RegionBindingsRef::getDefaultBinding(const MemRegion *R) const {
- return Optional<SVal>::create(lookup(R, BindingKey::Default));
+ const SVal *V = lookup(R, BindingKey::Default);
+ return V ? Optional<SVal>(*V) : std::nullopt;
}
RegionBindingsRef RegionBindingsRef::addBinding(BindingKey K, SVal V) const {
More information about the cfe-commits
mailing list