Commit 92b68c19 authored by Alexandre Ganea's avatar Alexandre Ganea
Browse files

[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 9f6b13e5, where an empty 'Str' would cause the function to never exit.
Also fixed usage in polly.
parent 6656e961
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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)) {
+1 −0
Original line number Diff line number Diff line
@@ -509,6 +509,7 @@ TEST(StringRefTest, Count) {
  EXPECT_EQ(1U, Str.count("hello"));
  EXPECT_EQ(1U, Str.count("ello"));
  EXPECT_EQ(0U, Str.count("zz"));
  EXPECT_EQ(0U, Str.count(""));

  StringRef OverlappingAbba("abbabba");
  EXPECT_EQ(1U, OverlappingAbba.count("abba"));
+2 −1
Original line number Diff line number Diff line
@@ -1653,7 +1653,8 @@ bool ScopDetection::isValidRegion(DetectionContext &Context) const {
                                            CurRegion.getExit(), DbgLoc);
  }

  if (!CurRegion.getEntry()->getName().count(OnlyRegion)) {
  if (!OnlyRegion.empty() &&
      !CurRegion.getEntry()->getName().count(OnlyRegion)) {
    LLVM_DEBUG({
      dbgs() << "Region entry does not match -polly-region-only";
      dbgs() << "\n";