This is an archive of the discontinued LLVM Phabricator instance.

Introduce StringRefZ class to represent null-terminated string.
ClosedPublic

Authored by ruiu on Nov 23 2016, 12:17 AM.

Details

Summary

StringRefZ is a class to represent a null-terminated string. String
length is computed lazily, so it more efficient than StringRef to
represent strings in string table.

The main purpose of defining that new class is to merge functions
that only differ in string types; we have many constructors that takes
const char * or StringRef. With StringRefZ, we can merge them.

Diff Detail

Repository
rL LLVM

Event Timeline

ruiu updated this revision to Diff 79035.Nov 23 2016, 12:17 AM
ruiu retitled this revision from to Introduce StringRefZ class to represent null-terminated string..
ruiu updated this object.
ruiu added a reviewer: rafael.
ruiu added a subscriber: llvm-commits.
ruiu updated this revision to Diff 79036.Nov 23 2016, 12:26 AM
  • Inline a few functions.
ruiu added a comment.Nov 29 2016, 7:42 AM

One thing we could do to prevent buffer overrun is to check if a string table ends with '\0'. String table is runs of null-terminated, so it should ends with null, and that should work as the last stopper.

This revision was automatically updated to reflect the committed changes.