[clang] [StaticAnalyzer] Remove redundant calls to std::unique_ptr<T>::get (NFC) (PR #139353)
via cfe-commits
cfe-commits at lists.llvm.org
Fri May 9 21:46:57 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
Author: Kazu Hirata (kazutakahirata)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/139353.diff
5 Files Affected:
- (modified) clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp (+1-1)
- (modified) clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp (+3-3)
- (modified) clang/lib/StaticAnalyzer/Core/ExprEngine.cpp (+1-1)
- (modified) clang/lib/StaticAnalyzer/Core/SVals.cpp (+2-2)
- (modified) clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp (+1-1)
``````````diff
diff --git a/clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp b/clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
index 3a66b0f11eb2e..839c8bcd90210 100644
--- a/clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/CheckPlacementNew.cpp
@@ -124,7 +124,7 @@ bool PlacementNewChecker::checkPlaceCapacityIsSufficient(
"requires {1} bytes. Current overhead requires the size of {2} "
"bytes",
SizeOfPlaceCI->getValue(), SizeOfTargetCI->getValue(),
- *SizeOfPlaceCI->getValue().get() - SizeOfTargetCI->getValue()));
+ *SizeOfPlaceCI->getValue() - SizeOfTargetCI->getValue()));
else if (IsArrayTypeAllocated &&
SizeOfPlaceCI->getValue() == SizeOfTargetCI->getValue())
Msg = std::string(llvm::formatv(
diff --git a/clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp b/clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
index 4e3919ef01667..637cf87ef8b6d 100644
--- a/clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
+++ b/clang/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
@@ -157,9 +157,9 @@ class DeadStoreObs : public LiveVariables::Observer {
return true;
// Lazily construct the set that records which VarDecls are in
// EH code.
- if (!InEH.get()) {
+ if (!InEH) {
InEH.reset(new llvm::DenseSet<const VarDecl *>());
- EHCodeVisitor V(*InEH.get());
+ EHCodeVisitor V(*InEH);
V.TraverseStmt(AC->getBody());
}
// Treat all VarDecls that occur in EH code as being "always live"
@@ -196,7 +196,7 @@ class DeadStoreObs : public LiveVariables::Observer {
// Compute reachable blocks within the CFG for trivial cases
// where a bogus dead store can be reported because itself is unreachable.
- if (!reachableCode.get()) {
+ if (!reachableCode) {
reachableCode.reset(new ReachableCode(cfg));
reachableCode->computeReachableBlocks();
}
diff --git a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
index 86e2e8f634bfd..40514cb1ba449 100644
--- a/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ b/clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -4050,7 +4050,7 @@ std::string ExprEngine::DumpGraph(ArrayRef<const ExplodedNode *> Nodes,
StringRef Filename) {
std::unique_ptr<ExplodedGraph> TrimmedG(G.trim(Nodes));
- if (!TrimmedG.get()) {
+ if (!TrimmedG) {
llvm::errs() << "warning: Trimmed ExplodedGraph is empty.\n";
return "";
}
diff --git a/clang/lib/StaticAnalyzer/Core/SVals.cpp b/clang/lib/StaticAnalyzer/Core/SVals.cpp
index 3ab01a04dcec4..824e4a3630735 100644
--- a/clang/lib/StaticAnalyzer/Core/SVals.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SVals.cpp
@@ -249,9 +249,9 @@ bool SVal::isConstant() const {
bool SVal::isConstant(int I) const {
if (std::optional<loc::ConcreteInt> LV = getAs<loc::ConcreteInt>())
- return *LV->getValue().get() == I;
+ return *LV->getValue() == I;
if (std::optional<nonloc::ConcreteInt> NV = getAs<nonloc::ConcreteInt>())
- return *NV->getValue().get() == I;
+ return *NV->getValue() == I;
return false;
}
diff --git a/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp b/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
index 3c5c992fa8dbc..ee9f90796fead 100644
--- a/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
+++ b/clang/lib/StaticAnalyzer/Core/SimpleConstraintManager.cpp
@@ -75,7 +75,7 @@ ProgramStateRef SimpleConstraintManager::assumeAux(ProgramStateRef State,
}
case nonloc::ConcreteIntKind: {
- bool b = *Cond.castAs<nonloc::ConcreteInt>().getValue().get() != 0;
+ bool b = *Cond.castAs<nonloc::ConcreteInt>().getValue() != 0;
bool isFeasible = b ? Assumption : !Assumption;
return isFeasible ? State : nullptr;
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/139353
More information about the cfe-commits
mailing list