Paweł Bylica via llvm-dev
2015-Nov-05 16:58 UTC
[llvm-dev] Why StringRef is not a ArrayRef<char>
Hi, Why is StringRef not an ArrayRef<char> extension? That might simplify some interfaces. Cheers, Paweł -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151105/ef56dcdc/attachment.html>
Ramkumar Ramachandra via llvm-dev
2015-Nov-06 14:07 UTC
[llvm-dev] Why StringRef is not a ArrayRef<char>
I think it's the same difference we have between int * and ArrayRef<int>, for instance. If you have a raw pointer, you are expected to keep track of the size out-of-band. In aggregate types, size is part of the type, making it very difficult to confuse a [1 x i8] with a [3 x i8]. Many people probably use the raw pointer as a way to hold a reference to dynamically allocated memory, and as a type-escape hatch. On Thu, Nov 5, 2015 at 11:58 AM, Paweł Bylica <llvm-dev at lists.llvm.org> wrote:> Hi, > > Why is StringRef not an ArrayRef<char> extension? That might simplify some > interfaces. > > Cheers, > Paweł > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev >
Joerg Sonnenberger via llvm-dev
2015-Nov-06 14:24 UTC
[llvm-dev] Why StringRef is not a ArrayRef<char>
On Fri, Nov 06, 2015 at 09:07:43AM -0500, Ramkumar Ramachandra via llvm-dev wrote:> I think it's the same difference we have between int * and > ArrayRef<int>, for instance. If you have a raw pointer, you are > expected to keep track of the size out-of-band. In aggregate types, > size is part of the type, making it very difficult to confuse a [1 x > i8] with a [3 x i8]. Many people probably use the raw pointer as a way > to hold a reference to dynamically allocated memory, and as a > type-escape hatch.StringRef is explicitly sized. I'd be more interested in which interfaces are actually simplified by implicit or explicit conversions between StringRef and ArrayRef<char>. Joerg
Possibly Parallel Threads
- [LLVMdev] How to test isDereferenceablePointer?
- [LLVMdev] Sporadic "RealOffset <= INT32_MAX && RealOffset >= INT32_MIN" failures with MCJIT on Windows
- PIC preferred too strongly, even at CodeModel::Large?
- [LLVMdev] Sporadic "RealOffset <= INT32_MAX && RealOffset >= INT32_MIN" failures with MCJIT on Windows
- [LLVMdev] Sporadic "RealOffset <= INT32_MAX && RealOffset >= INT32_MIN" failures with MCJIT on Windows