FileCheck: Eliminate DOSish \r from input file.
authorNAKAMURA Takumi <geek4civic@gmail.com>
Sun, 14 Nov 2010 03:28:22 +0000 (03:28 +0000)
committerNAKAMURA Takumi <geek4civic@gmail.com>
Sun, 14 Nov 2010 03:28:22 +0000 (03:28 +0000)
It can pass two tests below on Win32.
  - Clang :: CodeGenCXX/dyncast.cpp
  - LLVM :: CodeGen/ARM/globals.ll

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@119023 91177308-0d34-0410-b5e6-96231b3b80d8

utils/FileCheck/FileCheck.cpp

index c6b2ff7c60e73f513a8de899f0d83f7909bd5b7e..5e30c22db35e83946af8c5ed6e627564de97501f 100644 (file)
@@ -456,6 +456,11 @@ static MemoryBuffer *CanonicalizeInputFile(MemoryBuffer *MB) {
 
   for (const char *Ptr = MB->getBufferStart(), *End = MB->getBufferEnd();
        Ptr != End; ++Ptr) {
+    // Eliminate trailing dosish \r.
+    if (Ptr <= End - 2 && Ptr[0] == '\r' && Ptr[1] == '\n') {
+      continue;
+    }
+
     // If C is not a horizontal whitespace, skip it.
     if (*Ptr != ' ' && *Ptr != '\t') {
       NewFile.push_back(*Ptr);