diff options
author | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-08-27 01:06:23 +0000 |
---|---|---|
committer | Richard Smith <richard-llvm@metafoo.co.uk> | 2019-08-27 01:06:23 +0000 |
commit | f3f00b2e5ec110386bc6729a97559a8521857577 (patch) | |
tree | 6d229ad0d80b7fb448f1e3afa7e4fe121170d85c /clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp | |
parent | 57aee099a302f01c692f16a80526228001657f29 (diff) | |
download | bcm5719-llvm-f3f00b2e5ec110386bc6729a97559a8521857577.tar.gz bcm5719-llvm-f3f00b2e5ec110386bc6729a97559a8521857577.zip |
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.
llvm-svn: 370000
Diffstat (limited to 'clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp')
-rw-r--r-- | clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp | 49 |
1 files changed, 14 insertions, 35 deletions
diff --git a/clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp b/clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp index a350481df9a..11dca073616 100644 --- a/clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp +++ b/clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp @@ -196,29 +196,15 @@ static void skipString(const char *&First, const char *const End) { ++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 *&First, const char *const End) { 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(const char *const Start, } 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, const char *const End) { 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 char *&First, const char *const End) { // Print out the string. if (Last == End || Last == First || Last[-1] != '\\') { append(First, reverseOverSpaces(First, Last)); - First = Last; - skipNewline(First, End); return; } |