https://bugs.llvm.org/show_bug.cgi?id=44072

            Bug ID: 44072
           Summary: StringRef::count(StringRef) doesn't behave as
                    documented
           Product: new-bugs
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: new bugs
          Assignee: unassignedb...@nondot.org
          Reporter: be...@bensge.com
                CC: htmldevelo...@gmail.com, llvm-bugs@lists.llvm.org

The StringRef::count(StringRef) documentation reads as follows:
Return the number of non-overlapped occurrences of \arg Str in the string.
However, the implementation of this method actually counts overlapping
occurrences as well. 

Minimum example:
`StringRef("abbabba").count("abba")` returns 2, when it should return 1.

There are very few usages of this API in LLVM. I could only find one usage of
this API where the bug actually makes a difference. All other usages used a
search string with length one, the bug doesn't affect this special case.

There are no tests to ensure the correct overlapping-occurrence behavior of
this function.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to