This is an archive of the discontinued LLVM Phabricator instance.

[Support] Fix behavior of StringRef::count with overlapping occurrences, add tests
ClosedPublic

Authored by Bensge on Nov 22 2019, 12:14 AM.

Details

Summary

Fix the behavior of StringRef::count(StringRef) to not count overlapping occurrences, as is stated in the documentation.
Fixes bug https://bugs.llvm.org/show_bug.cgi?id=44072

I added Krzysztof Parzyszek to review this change because a use of this function in HexagonInstrInfo::getInlineAsmLength might depend on the overlapping-behavior. I don't have enough domain knowledge to tell if this change could break anything there.

All other uses of this method in LLVM (besides the unit tests) only use single-character search strings. In those cases, search occurrences can not overlap anyway.

Diff Detail

Event Timeline

Bensge created this revision.Nov 22 2019, 12:14 AM
jdoerfert accepted this revision.Dec 19 2019, 12:03 AM
jdoerfert added a subscriber: jdoerfert.

LGTM.

This revision is now accepted and ready to land.Dec 19 2019, 12:03 AM

Thank you for reviewing this change. You may commit it as I don't have commit access.

This revision was automatically updated to reflect the committed changes.
aganea added a subscriber: aganea.Jan 1 2020, 2:33 PM

Hi! This patch broke the polly tests (the bot seems down). I wrote a fix here: 92b68c1937cd065a2fc44d18c1099de7da19b356 - it was trivial enough, but please let me know if you don't agree with the fix.