github-actions[bot] commented on code in PR #63242:
URL: https://github.com/apache/doris/pull/63242#discussion_r3239848724
##########
be/src/core/column/column.h:
##########
@@ -787,46 +800,87 @@ struct IsMutableColumns<> {
static const bool value = true;
};
+template <typename PointerType>
+class DORIS_CLANG_CONSUMABLE_UNKNOWN ColumnPtrGuard {
+public:
+ explicit ColumnPtrGuard(PointerType column) : _column(column) {}
+
+ explicit operator bool() const DORIS_CLANG_TEST_UNCONSUMED { return
_column != nullptr; }
+
+ bool operator==(std::nullptr_t) const DORIS_CLANG_TEST_UNCONSUMED { return
_column == nullptr; }
Review Comment:
`test_typestate(unconsumed)` on `operator==(nullptr)` inverts the typestate
contract. This operator returns true when `_column == nullptr`, but
`unconsumed` is exactly the state required by `get()`/`operator->()`. With
`-Wconsumed` now enabled as `-Werror`, the natural safe pattern `if (guard ==
nullptr) return; guard.get();` is diagnosed as using `guard` in the consumed
state, while the null branch is treated as the dereferenceable branch.
`operator!=`/`operator bool` match the runtime meaning, but equality should
either use `test_typestate(consumed)` or be left unannotated/removed so `==
nullptr` does not break callers that use the standard null-check spelling.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]