Skip to content

Commit 8d72b84

Browse files
Mark RefCountPtr as a nullable type.
This allows uses of the type to be annotated as absl_nonnull, absl_nullable, or absl_nullability_unknown. It's possible that the clang compiler could be altered to automatically consider classes as nullable if they inherit from a nullable class, but that won't happen any time soon. PiperOrigin-RevId: 797525969
1 parent 0407d36 commit 8d72b84

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

tsl/platform/BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1213,6 +1213,7 @@ cc_library(
12131213
deps = [
12141214
":mutex",
12151215
":thread_annotations",
1216+
"@com_google_absl//absl/base:nullability",
12161217
"@xla//xla/tsl/platform:logging",
12171218
],
12181219
)

tsl/platform/refcount.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ limitations under the License.
2020
#include <map>
2121
#include <memory>
2222

23+
#include "absl/base/nullability.h"
2324
#include "xla/tsl/platform/logging.h"
2425
#include "tsl/platform/mutex.h"
2526
#include "tsl/platform/thread_annotations.h"
@@ -98,7 +99,8 @@ ABSL_MUST_USE_RESULT RefCountPtr<T> GetNewRef(T* ptr) {
9899

99100
// A unique_ptr that unrefs the owned object on destruction.
100101
template <typename T>
101-
class RefCountPtr : public std::unique_ptr<T, RefCountDeleter> {
102+
class ABSL_NULLABILITY_COMPATIBLE RefCountPtr
103+
: public std::unique_ptr<T, RefCountDeleter> {
102104
public:
103105
using std::unique_ptr<T, RefCountDeleter>::unique_ptr;
104106
ABSL_MUST_USE_RESULT RefCountPtr GetNewRef() const {

0 commit comments

Comments
 (0)