[clang] [FlowSensitive] [StatusOr] cache pointers for all const methods (PR #179791)
Florian Mayer via cfe-commits
cfe-commits at lists.llvm.org
Thu Feb 5 10:20:00 PST 2026
https://github.com/fmayer updated https://github.com/llvm/llvm-project/pull/179791
>From 624aa74fc35500b9384cc5baf4b0a38847fe5f44 Mon Sep 17 00:00:00 2001
From: Florian Mayer <fmayer at google.com>
Date: Wed, 4 Feb 2026 13:57:13 -0800
Subject: [PATCH 1/2] =?UTF-8?q?[=F0=9D=98=80=F0=9D=97=BD=F0=9D=97=BF]=20ch?=
=?UTF-8?q?anges=20to=20main=20this=20commit=20is=20based=20on?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Created using spr 1.3.6
[skip ci]
---
.../UncheckedStatusOrAccessModelTestFixture.cpp | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
diff --git a/clang/unittests/Analysis/FlowSensitive/UncheckedStatusOrAccessModelTestFixture.cpp b/clang/unittests/Analysis/FlowSensitive/UncheckedStatusOrAccessModelTestFixture.cpp
index 5be4e38133744..575c8ccc1b723 100644
--- a/clang/unittests/Analysis/FlowSensitive/UncheckedStatusOrAccessModelTestFixture.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/UncheckedStatusOrAccessModelTestFixture.cpp
@@ -3960,6 +3960,23 @@ TEST_P(UncheckedStatusOrAccessModelTest, StatusPtrReference) {
)cc");
}
+TEST_P(UncheckedStatusOrAccessModelTest, PairIterator) {
+ ExpectDiagnosticsFor(R"cc(
+#include "unchecked_statusor_access_test_defs.h"
+
+ class iterator {
+ public:
+ const std::pair<int, absl::StatusOr<int>>* operator->() const;
+ };
+ void target() {
+ if (auto it = Make<iterator>(); it->second.ok()) {
+ // This is a false positive. Fix and remove the unsafe.
+ it->second.value(); // [[unsafe]]
+ }
+ }
+)cc");
+}
+
} // namespace
std::string
>From 3f4c212c6c919e8c6cbb6582f2f1489725b803a5 Mon Sep 17 00:00:00 2001
From: Florian Mayer <fmayer at google.com>
Date: Wed, 4 Feb 2026 14:00:21 -0800
Subject: [PATCH 2/2] fix
Created using spr 1.3.6
---
.../FlowSensitive/UncheckedStatusOrAccessModelTestFixture.cpp | 1 -
1 file changed, 1 deletion(-)
diff --git a/clang/unittests/Analysis/FlowSensitive/UncheckedStatusOrAccessModelTestFixture.cpp b/clang/unittests/Analysis/FlowSensitive/UncheckedStatusOrAccessModelTestFixture.cpp
index 396b2d96093a0..0491f40c225f7 100644
--- a/clang/unittests/Analysis/FlowSensitive/UncheckedStatusOrAccessModelTestFixture.cpp
+++ b/clang/unittests/Analysis/FlowSensitive/UncheckedStatusOrAccessModelTestFixture.cpp
@@ -3970,7 +3970,6 @@ TEST_P(UncheckedStatusOrAccessModelTest, PairIterator) {
};
void target() {
if (auto it = Make<iterator>(); it->second.ok()) {
- // This is a false positive. Fix and remove the unsafe.
it->second.value();
}
}
More information about the cfe-commits
mailing list