Index: llvm/utils/FileCheck/FileCheck.cpp =================================================================== --- llvm/utils/FileCheck/FileCheck.cpp +++ llvm/utils/FileCheck/FileCheck.cpp @@ -90,8 +90,17 @@ "provided for convenience as old tests are migrated to the new\n" "non-overlapping CHECK-DAG implementation.\n")); +static const char * DumpInputEnv = "FILECHECK_DUMP_INPUT_ON_FAILURE"; + +static cl::opt DumpInputOnFailure( + "dump-input-on-failure", cl::init(std::getenv(DumpInputEnv)), + cl::desc("Dump original input to stderr before failing.\n" + "The value can be also controlled using\n" + "FILECHECK_DUMP_INPUT_ON_FAILURE environment variable.\n")); + typedef cl::list::const_iterator prefix_iterator; + //===----------------------------------------------------------------------===// // Pattern Handling Code. //===----------------------------------------------------------------------===// @@ -1501,5 +1510,9 @@ InputFileText, InputFile.getBufferIdentifier()), SMLoc()); - return CheckInput(SM, InputFileText, CheckStrings) ? EXIT_SUCCESS : 1; + int ExitCode = CheckInput(SM, InputFileText, CheckStrings) ? EXIT_SUCCESS : 1; + if (ExitCode == 1 && std::getenv(DumpInputEnv)) + errs() << "Full input was:\n<<<<<<\n" << InputFileText << "\n>>>>>>\n"; + + return ExitCode; } Index: llvm/utils/lit/lit/TestingConfig.py =================================================================== --- llvm/utils/lit/lit/TestingConfig.py +++ llvm/utils/lit/lit/TestingConfig.py @@ -25,7 +25,8 @@ 'CLANG', 'LD_PRELOAD', 'ASAN_OPTIONS', 'UBSAN_OPTIONS', 'LSAN_OPTIONS', 'ADB', 'ANDROID_SERIAL', 'SANITIZER_IGNORE_CVE_2016_2143', 'TMPDIR', 'TMP', 'TEMP', - 'TEMPDIR', 'AVRLIT_BOARD', 'AVRLIT_PORT'] + 'TEMPDIR', 'AVRLIT_BOARD', 'AVRLIT_PORT', + 'FILECHECK_DUMP_INPUT_ON_FAILURE'] for var in pass_vars: val = os.environ.get(var, '') # Check for empty string as some variables such as LD_PRELOAD cannot be empty