aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Support/StringRef.cpp
diff options
context:
space:
mode:
authorAlexandre Ganea <alexandre.ganea@ubisoft.com>2020-01-01 17:23:06 -0500
committerAlexandre Ganea <alexandre.ganea@ubisoft.com>2020-01-01 17:29:04 -0500
commit92b68c1937cd065a2fc44d18c1099de7da19b356 (patch)
tree8a47e1ae3f830532208f76092c20c05ebb6427ad /llvm/lib/Support/StringRef.cpp
parent6656e961c08393c3949412ef945ade0272b66fca (diff)
downloadllvm-92b68c1937cd065a2fc44d18c1099de7da19b356.zip
llvm-92b68c1937cd065a2fc44d18c1099de7da19b356.tar.gz
llvm-92b68c1937cd065a2fc44d18c1099de7da19b356.tar.bz2
[polly][Support] Un-break polly tests
Previously, the polly unit tests were stuck in a infinite loop. There was an edge case in StringRef::count() introduced by 9f6b13e5cce96066d7262d224c971d93c2724795, where an empty 'Str' would cause the function to never exit. Also fixed usage in polly.
Diffstat (limited to 'llvm/lib/Support/StringRef.cpp')
-rw-r--r--llvm/lib/Support/StringRef.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Support/StringRef.cpp b/llvm/lib/Support/StringRef.cpp
index d7fa99d..393504c 100644
--- a/llvm/lib/Support/StringRef.cpp
+++ b/llvm/lib/Support/StringRef.cpp
@@ -372,7 +372,7 @@ void StringRef::split(SmallVectorImpl<StringRef> &A, char Separator,
size_t StringRef::count(StringRef Str) const {
size_t Count = 0;
size_t N = Str.size();
- if (N > Length)
+ if (!N || N > Length)
return 0;
for (size_t i = 0, e = Length - N + 1; i < e;) {
if (substr(i, N).equals(Str)) {