[PATCH] D78050: Introduce `__sanitizer::ArrayRef<T>` type.

David Blaikie via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 13 17:57:34 PDT 2020


dblaikie added a comment.

While I'm in favor of this type looking more like llvm's MutableArrayRef (ie: allowing mutability or immutability to be encoded in the type parameter (const T versus non-const T)) rather than needing the two types LLVM has (ArrayRef + MutableArrayRef). I wonder if having this type called "ArrayRef" when it is subtly different from llvm's ArrayRef might be confusing? Wonder if it needs another/better name - though the standard doesn't offer us a great alternative, it seems the standardized equivalent is std::span, which might be sufficiently different not to be a good name to use either? Not sure.



================
Comment at: compiler-rt/lib/sanitizer_common/sanitizer_array_ref.h:87
+    CHECK_LE(n, size());
+    T *slice_begin = const_cast<T *>(begin()) + n;
+    uptr slice_size = size() - n;
----------------
Might just be better/easier to use "data_" directly, rather than const_casting+begin?

Or use "data()" instead, like llvm::ArrayRef does?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D78050/new/

https://reviews.llvm.org/D78050





More information about the llvm-commits mailing list