From 937b1cee1a7c337dd683274e9bba63cbc4148511 Mon Sep 17 00:00:00 2001 From: Colin LeMahieu Date: Mon, 27 Jul 2015 22:39:14 +0000 Subject: [PATCH] [llvm-mc] Add --no-warn flag with -W alias to disable outputting warnings while assembling. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243338 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/MC/MCTargetOptions.h | 2 ++ include/llvm/MC/MCTargetOptionsCommandFlags.h | 4 ++++ lib/MC/MCParser/AsmParser.cpp | 2 ++ lib/MC/MCTargetOptions.cpp | 2 +- test/tools/llvm-mc/no_warnings.test | 5 +++++ 5 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test/tools/llvm-mc/no_warnings.test diff --git a/include/llvm/MC/MCTargetOptions.h b/include/llvm/MC/MCTargetOptions.h index 7f4f23eda27..00a74de9d06 100644 --- a/include/llvm/MC/MCTargetOptions.h +++ b/include/llvm/MC/MCTargetOptions.h @@ -29,6 +29,7 @@ public: bool MCRelaxAll : 1; bool MCNoExecStack : 1; bool MCFatalWarnings : 1; + bool MCNoWarn : 1; bool MCSaveTempLabels : 1; bool MCUseDwarfDirectory : 1; bool ShowMCEncoding : 1; @@ -49,6 +50,7 @@ inline bool operator==(const MCTargetOptions &LHS, const MCTargetOptions &RHS) { ARE_EQUAL(MCRelaxAll) && ARE_EQUAL(MCNoExecStack) && ARE_EQUAL(MCFatalWarnings) && + ARE_EQUAL(MCNoWarn) && ARE_EQUAL(MCSaveTempLabels) && ARE_EQUAL(MCUseDwarfDirectory) && ARE_EQUAL(ShowMCEncoding) && diff --git a/include/llvm/MC/MCTargetOptionsCommandFlags.h b/include/llvm/MC/MCTargetOptionsCommandFlags.h index 1c08d1722f0..1240e135ea0 100644 --- a/include/llvm/MC/MCTargetOptionsCommandFlags.h +++ b/include/llvm/MC/MCTargetOptionsCommandFlags.h @@ -43,6 +43,9 @@ cl::opt ShowMCInst("asm-show-inst", cl::opt FatalWarnings("fatal-warnings", cl::desc("Treat warnings as errors")); +cl::opt NoWarn("no-warn", cl::desc("Suppress all warnings")); +cl::alias NoWarnW("W", cl::desc("Alias for --no-warn"), cl::aliasopt(NoWarn)); + cl::opt ABIName("target-abi", cl::Hidden, cl::desc("The name of the ABI to be targeted from the backend."), @@ -57,6 +60,7 @@ static inline MCTargetOptions InitMCTargetOptionsFromFlags() { Options.ShowMCInst = ShowMCInst; Options.ABIName = ABIName; Options.MCFatalWarnings = FatalWarnings; + Options.MCNoWarn = NoWarn; return Options; } diff --git a/lib/MC/MCParser/AsmParser.cpp b/lib/MC/MCParser/AsmParser.cpp index 04d141389c9..3f45b3d85a3 100644 --- a/lib/MC/MCParser/AsmParser.cpp +++ b/lib/MC/MCParser/AsmParser.cpp @@ -553,6 +553,8 @@ void AsmParser::Note(SMLoc L, const Twine &Msg, ArrayRef Ranges) { } bool AsmParser::Warning(SMLoc L, const Twine &Msg, ArrayRef Ranges) { + if(getTargetParser().getTargetOptions().MCNoWarn) + return false; if (getTargetParser().getTargetOptions().MCFatalWarnings) return Error(L, Msg, Ranges); printMessage(L, SourceMgr::DK_Warning, Msg, Ranges); diff --git a/lib/MC/MCTargetOptions.cpp b/lib/MC/MCTargetOptions.cpp index 1258d9e29f2..64796af10c8 100644 --- a/lib/MC/MCTargetOptions.cpp +++ b/lib/MC/MCTargetOptions.cpp @@ -14,7 +14,7 @@ namespace llvm { MCTargetOptions::MCTargetOptions() : SanitizeAddress(false), MCRelaxAll(false), MCNoExecStack(false), - MCFatalWarnings(false), MCSaveTempLabels(false), + MCFatalWarnings(false), MCNoWarn(false), MCSaveTempLabels(false), MCUseDwarfDirectory(false), ShowMCEncoding(false), ShowMCInst(false), AsmVerbose(false), DwarfVersion(0), ABIName() {} diff --git a/test/tools/llvm-mc/no_warnings.test b/test/tools/llvm-mc/no_warnings.test new file mode 100644 index 00000000000..f542f1773c0 --- /dev/null +++ b/test/tools/llvm-mc/no_warnings.test @@ -0,0 +1,5 @@ +# RUN: llvm-mc --no-warn %s 2>&1 | FileCheck %s +# XFAIL: hexagon + +# CHECK-NOT: warning: +.warning -- 2.34.1