Pre-allocate space for results from a regex match that uses 3 match strings.
authorMLIR Team <no-reply@google.com>
Thu, 10 Oct 2019 02:57:02 +0000 (19:57 -0700)
committerA. Unique TensorFlower <gardener@tensorflow.org>
Thu, 10 Oct 2019 03:07:46 +0000 (20:07 -0700)
That space is 4 StringRefs, not 3, because element 0 of the match always
contains the entire source string.

PiperOrigin-RevId: 273875606

mlir/lib/IR/Diagnostics.cpp

index b13db11..edd67d7 100644 (file)
@@ -594,7 +594,7 @@ SourceMgrDiagnosticVerifierHandlerImpl::computeExpectedDiags(
   SmallVector<StringRef, 100> lines;
   buf->getBuffer().split(lines, '\n');
   for (unsigned lineNo = 0, e = lines.size(); lineNo < e; ++lineNo) {
-    SmallVector<StringRef, 3> matches;
+    SmallVector<StringRef, 4> matches;
     if (!expected.match(lines[lineNo], &matches))
       continue;
     // Point to the start of expected-*.