r370000 - Revert "[clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF line endings"
Richard Smith via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 26 18:06:23 PDT 2019
Author: rsmith
Date: Mon Aug 26 18:06:23 2019
New Revision: 370000
URL: http://llvm.org/viewvc/llvm-project?rev=370000&view=rev
Log:
Revert "[clang-scan-deps] Minimizer: Correctly handle multi-line content with CR+LF line endings"
This reverts commit r369986.
This change added a dependency on the 'dos2unix' tool, which is not one
of our accepted test dependencies and may not exist on all machines that
build Clang.
Removed:
cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
Modified:
cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
Modified: cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp?rev=370000&r1=369999&r2=370000&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp (original)
+++ cfe/trunk/lib/Lex/DependencyDirectivesSourceMinimizer.cpp Mon Aug 26 18:06:23 2019
@@ -196,29 +196,15 @@ static void skipString(const char *&Firs
++First; // Finish off the string.
}
-// Returns the length of EOL, either 0 (no end-of-line), 1 (\n) or 2 (\r\n)
-static unsigned isEOL(const char *First, const char *const End) {
- if (First == End)
- return 0;
- if (End - First > 1 && isVerticalWhitespace(First[0]) &&
- isVerticalWhitespace(First[1]) && First[0] != First[1])
- return 2;
- return !!isVerticalWhitespace(First[0]);
-}
-
-// Returns the length of the skipped newline
-static unsigned skipNewline(const char *&First, const char *End) {
- if (First == End)
- return 0;
+static void skipNewline(const char *&First, const char *End) {
assert(isVerticalWhitespace(*First));
- unsigned Len = isEOL(First, End);
- assert(Len && "expected newline");
- First += Len;
- return Len;
-}
+ ++First;
+ if (First == End)
+ return;
-static bool wasLineContinuation(const char *First, unsigned EOLLen) {
- return *(First - (int)EOLLen - 1) == '\\';
+ // Check for "\n\r" and "\r\n".
+ if (LLVM_UNLIKELY(isVerticalWhitespace(*First) && First[-1] != First[0]))
+ ++First;
}
static void skipToNewlineRaw(const char *&First, const char *const End) {
@@ -226,21 +212,17 @@ static void skipToNewlineRaw(const char
if (First == End)
return;
- unsigned Len = isEOL(First, End);
- if (Len)
+ if (isVerticalWhitespace(*First))
return;
- do {
+ while (!isVerticalWhitespace(*First))
if (++First == End)
return;
- Len = isEOL(First, End);
- } while (!Len);
if (First[-1] != '\\')
return;
- First += Len;
- // Keep skipping lines...
+ ++First; // Keep going...
}
}
@@ -295,7 +277,7 @@ static bool isQuoteCppDigitSeparator(con
}
static void skipLine(const char *&First, const char *const End) {
- for (;;) {
+ do {
assert(First <= End);
if (First == End)
return;
@@ -340,10 +322,9 @@ static void skipLine(const char *&First,
return;
// Skip over the newline.
- unsigned Len = skipNewline(First, End);
- if (!wasLineContinuation(First, Len)) // Continue past line-continuations.
- break;
- }
+ assert(isVerticalWhitespace(*First));
+ skipNewline(First, End);
+ } while (First[-2] == '\\'); // Continue past line-continuations.
}
static void skipDirective(StringRef Name, const char *&First,
@@ -399,8 +380,6 @@ void Minimizer::printToNewline(const cha
// Print out the string.
if (Last == End || Last == First || Last[-1] != '\\') {
append(First, reverseOverSpaces(First, Last));
- First = Last;
- skipNewline(First, End);
return;
}
Removed: cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c?rev=369999&view=auto
==============================================================================
--- cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c (original)
+++ cfe/trunk/test/Lexer/minimize_source_to_dependency_directives_invalid_error.c (removed)
@@ -1,16 +0,0 @@
-// Test CF+LF are properly handled along with quoted, multi-line #error
-// RUN: cat %s | unix2dos | %clang_cc1 -DOTHER -print-dependency-directives-minimized-source 2>&1 | FileCheck %s
-
-#ifndef TEST
-#error "message \
- more message \
- even more"
-#endif
-
-#ifdef OTHER
-#include <string>
-#endif
-
-// CHECK: #ifdef OTHER
-// CHECK-NEXT: #include <string>
-// CHECK-NEXT: #endif
More information about the cfe-commits
mailing list