summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/llvm/ADT/StringRef.h2
-rw-r--r--unittests/ADT/StringRefTest.cpp1
2 files changed, 2 insertions, 1 deletions
diff --git a/include/llvm/ADT/StringRef.h b/include/llvm/ADT/StringRef.h
index 5433056..acfc335 100644
--- a/include/llvm/ADT/StringRef.h
+++ b/include/llvm/ADT/StringRef.h
@@ -177,7 +177,7 @@ namespace llvm {
size_t Count = 0;
for (size_t i = 0, e = Length; i != e; ++i)
if (Data[i] == C)
- return i;
+ ++Count;
return Count;
}
diff --git a/unittests/ADT/StringRefTest.cpp b/unittests/ADT/StringRefTest.cpp
index ef89e9f..320633a 100644
--- a/unittests/ADT/StringRefTest.cpp
+++ b/unittests/ADT/StringRefTest.cpp
@@ -96,6 +96,7 @@ TEST(StringRefTest, Utilities) {
EXPECT_TRUE(Str.find("zz") == StringRef::npos);
EXPECT_TRUE(Str.count('l') == 2);
+ EXPECT_TRUE(Str.count('o') == 1);
EXPECT_TRUE(Str.count('z') == 0);
EXPECT_TRUE(Str.count("helloworld") == 0);
EXPECT_TRUE(Str.count("hello") == 1);