Index: include/llvm/Support/FileCheck.h =================================================================== --- include/llvm/Support/FileCheck.h +++ include/llvm/Support/FileCheck.h @@ -35,6 +35,7 @@ bool AllowDeprecatedDagOverlap = false; bool Verbose = false; bool VerboseVerbose = false; + bool Warn = false; }; @@ -218,6 +219,8 @@ /// Returns false if the input fails to satisfy the checks. bool CheckInput(SourceMgr &SM, StringRef Buffer, ArrayRef CheckStrings); + + void PrintWarning(SourceMgr &SM, SMLoc Loc, const Twine &Msg); }; } // namespace llvm #endif Index: lib/Support/FileCheck.cpp =================================================================== --- lib/Support/FileCheck.cpp +++ lib/Support/FileCheck.cpp @@ -25,6 +25,13 @@ using namespace llvm; +void FileCheck::PrintWarning(SourceMgr &SM, SMLoc Loc, const Twine &Msg) { + if (!Req.Warn) + return; + + SM.PrintMessage(Loc, SourceMgr::DK_Warning, Msg); +} + /// Parses the given string into the Pattern. /// /// \p Prefix provides which prefix is being matched, \p SM provides the Index: test/FileCheck/check-warning.txt =================================================================== --- /dev/null +++ test/FileCheck/check-warning.txt @@ -0,0 +1,10 @@ +; RUN: FileCheck -v -warn -input-file %s %s 2>&1 | FileCheck -check-prefix=CHECK-WARNING %s +; RUN: FileCheck -v -warn=true -input-file %s %s 2>&1 | FileCheck -check-prefix=CHECK-WARNING %s +; RUN: FileCheck -v -warn=false -input-file %s %s 2>&1 | FileCheck -check-prefix=CHECK-QUIET %s + +hello world + +; CHECK: hello world + +; CHECK-WARNING: warning: Running FileCheck with warnings enabled +; CHECK-QUIET-NOT: warning: Running FileCheck with warnings enabled Index: utils/FileCheck/FileCheck.cpp =================================================================== --- utils/FileCheck/FileCheck.cpp +++ utils/FileCheck/FileCheck.cpp @@ -85,6 +85,10 @@ "vv", cl::init(false), cl::desc("Print information helpful in diagnosing internal FileCheck\n" "issues. Implies -v.\n")); + +static cl::opt Warn("warn", cl::init(false), + cl::desc("Print warning messages.\n")); + static const char * DumpInputEnv = "FILECHECK_DUMP_INPUT_ON_FAILURE"; static cl::opt DumpInputOnFailure( @@ -130,6 +134,7 @@ Req.AllowEmptyInput = AllowEmptyInput; Req.EnableVarScope = EnableVarScope; Req.AllowDeprecatedDagOverlap = AllowDeprecatedDagOverlap; + Req.Warn = Warn; Req.Verbose = Verbose; Req.VerboseVerbose = VerboseVerbose; Req.NoCanonicalizeWhiteSpace = NoCanonicalizeWhiteSpace; @@ -157,7 +162,6 @@ return 2; } - SourceMgr SM; // Read the expected strings from the check file. @@ -204,6 +208,9 @@ InputFileText, InputFile.getBufferIdentifier()), SMLoc()); + if (Req.Verbose) + FC.PrintWarning(SM, SMLoc(), "Running FileCheck with warnings enabled"); + int ExitCode = FC.CheckInput(SM, InputFileText, CheckStrings) ? EXIT_SUCCESS : 1; if (ExitCode == 1 && DumpInputOnFailure)