Details
- Reviewers
ributzka keith Roger - Group Reviewers
Restricted Project - Commits
- rG3925ea4172fa: [lld-macho][nfci] Don't include null terminator in StringRefs
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
lld/MachO/MapFile.cpp | ||
---|---|---|
91 | dereferencing end iterators from the STL is undefined, but fortunately a StringRef isn't part of the STL... |
thanks! I started on this by had some off by one breaking some other test, but I assume your case ironed that out!
Generally looks good :)
lld/MachO/SyntheticSections.cpp | ||
---|---|---|
1546 | It looks to me that we used to copy over a null terminator here but we no longer will do that. Am I correct? |
lld/MachO/InputSection.cpp | ||
---|---|---|
244–245 | actually I think it's only that one assert that assumes this, and that assert is no longer actually necessary all the other places that "skip the null terminator" are basically just skipping a byte in the output buffer. they don't assume that the StringRef itself has a null terminator | |
lld/MachO/MapFile.cpp | ||
91 | I realize that assert was only done because we were trimming off the null terminator in the (now deleted) substr call. So we can remove the assert | |
lld/MachO/SyntheticSections.cpp | ||
1546 | indeed. Though not guaranteed by a spec, it appears that our mmaped output buffer is zero-initialized -- at least, a good deal of the code already assumes that this is the case (and tests would fail otherwise) |
I should probably put an explicit "LGTM" here: LGTM :)
(You landed this at the right time, should've approved with my original comment.)
There's a bunch of places that assume that the trailing \0 byte is still there, but that's generally not the case for StringRefs. Maybe we should use ArrayRefs in the places you touched?