summaryrefslogtreecommitdiffstats
path: root/llvm/utils/FileCheck
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/utils/FileCheck')
-rw-r--r--llvm/utils/FileCheck/FileCheck.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/llvm/utils/FileCheck/FileCheck.cpp b/llvm/utils/FileCheck/FileCheck.cpp
index 9619f945aac..3c4742cc36f 100644
--- a/llvm/utils/FileCheck/FileCheck.cpp
+++ b/llvm/utils/FileCheck/FileCheck.cpp
@@ -340,7 +340,10 @@ unsigned Pattern::ComputeMatchDistance(StringRef Buffer,
if (ExampleString.empty())
ExampleString = RegExStr;
- return Buffer.substr(0, ExampleString.size()).edit_distance(ExampleString);
+ // Only compare up to the first line in the buffer, or the string size.
+ StringRef BufferPrefix = Buffer.substr(0, ExampleString.size());
+ BufferPrefix = BufferPrefix.split('\n').first;
+ return BufferPrefix.edit_distance(ExampleString);
}
void Pattern::PrintFailureInfo(const SourceMgr &SM, StringRef Buffer,
OpenPOWER on IntegriCloud