mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-10-02 17:55:18 +00:00
Canonicalize line endings to Linux style also when the --strict-whitespace flag is in use. This flag is supposed to affect horizontal whitespaces only.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@174541 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
c3662eeaa4
commit
4cc74fcba0
@ -43,7 +43,8 @@ OPTIONS
|
|||||||
|
|
||||||
By default, FileCheck canonicalizes input horizontal whitespace (spaces and
|
By default, FileCheck canonicalizes input horizontal whitespace (spaces and
|
||||||
tabs) which causes it to ignore these differences (a space will match a tab).
|
tabs) which causes it to ignore these differences (a space will match a tab).
|
||||||
The :option:`--strict-whitespace` argument disables this behavior.
|
The :option:`--strict-whitespace` argument disables this behavior. End-of-line
|
||||||
|
sequences are canonicalized to UNIX-style '\n' in all modes.
|
||||||
|
|
||||||
.. option:: -version
|
.. option:: -version
|
||||||
|
|
||||||
|
11
test/FileCheck/dos-style-eol.txt
Normal file
11
test/FileCheck/dos-style-eol.txt
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
// Test for using FileCheck on DOS style end-of-line
|
||||||
|
// This test was deliberately committed with DOS style end of line.
|
||||||
|
// Don't change line endings!
|
||||||
|
// RUN: FileCheck -input-file %s %s
|
||||||
|
// RUN: FileCheck --strict-whitespace -input-file %s %s
|
||||||
|
|
||||||
|
LINE 1
|
||||||
|
; CHECK: {{^}}LINE 1{{$}}
|
||||||
|
|
||||||
|
LINE 2
|
||||||
|
; CHECK: {{^}}LINE 2{{$}}
|
@ -587,9 +587,13 @@ struct CheckString {
|
|||||||
: Pat(P), Loc(L), IsCheckNext(isCheckNext) {}
|
: Pat(P), Loc(L), IsCheckNext(isCheckNext) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
/// CanonicalizeInputFile - Remove duplicate horizontal space from the specified
|
/// Canonicalize whitespaces in the input file. Line endings are replaced
|
||||||
/// memory buffer, free it, and return a new one.
|
/// with UNIX-style '\n'.
|
||||||
static MemoryBuffer *CanonicalizeInputFile(MemoryBuffer *MB) {
|
///
|
||||||
|
/// \param PreserveHorizontal Don't squash consecutive horizontal whitespace
|
||||||
|
/// characters to a single space.
|
||||||
|
static MemoryBuffer *CanonicalizeInputFile(MemoryBuffer *MB,
|
||||||
|
bool PreserveHorizontal) {
|
||||||
SmallString<128> NewFile;
|
SmallString<128> NewFile;
|
||||||
NewFile.reserve(MB->getBufferSize());
|
NewFile.reserve(MB->getBufferSize());
|
||||||
|
|
||||||
@ -600,8 +604,9 @@ static MemoryBuffer *CanonicalizeInputFile(MemoryBuffer *MB) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If current char is not a horizontal whitespace, dump it to output as is.
|
// If current char is not a horizontal whitespace or if horizontal
|
||||||
if (*Ptr != ' ' && *Ptr != '\t') {
|
// whitespace canonicalization is disabled, dump it to output as is.
|
||||||
|
if (PreserveHorizontal || (*Ptr != ' ' && *Ptr != '\t')) {
|
||||||
NewFile.push_back(*Ptr);
|
NewFile.push_back(*Ptr);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -637,9 +642,8 @@ static bool ReadCheckFile(SourceMgr &SM,
|
|||||||
MemoryBuffer *F = File.take();
|
MemoryBuffer *F = File.take();
|
||||||
|
|
||||||
// If we want to canonicalize whitespace, strip excess whitespace from the
|
// If we want to canonicalize whitespace, strip excess whitespace from the
|
||||||
// buffer containing the CHECK lines.
|
// buffer containing the CHECK lines. Remove DOS style line endings.
|
||||||
if (!NoCanonicalizeWhiteSpace)
|
F = CanonicalizeInputFile(F, NoCanonicalizeWhiteSpace);
|
||||||
F = CanonicalizeInputFile(F);
|
|
||||||
|
|
||||||
SM.AddNewSourceBuffer(F, SMLoc());
|
SM.AddNewSourceBuffer(F, SMLoc());
|
||||||
|
|
||||||
@ -807,8 +811,8 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove duplicate spaces in the input file if requested.
|
// Remove duplicate spaces in the input file if requested.
|
||||||
if (!NoCanonicalizeWhiteSpace)
|
// Remove DOS style line endings.
|
||||||
F = CanonicalizeInputFile(F);
|
F = CanonicalizeInputFile(F, NoCanonicalizeWhiteSpace);
|
||||||
|
|
||||||
SM.AddNewSourceBuffer(F, SMLoc());
|
SM.AddNewSourceBuffer(F, SMLoc());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user