Skip to content

Commit

Permalink
[llvm-mc] Add --no-warn flag with -W alias to disable outputting warn…
Browse files Browse the repository at this point in the history
…ings while assembling.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243338 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
Colin LeMahieu committed Jul 27, 2015
1 parent ff88606 commit 937b1ce
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 1 deletion.
2 changes: 2 additions & 0 deletions include/llvm/MC/MCTargetOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class MCTargetOptions {
bool MCRelaxAll : 1;
bool MCNoExecStack : 1;
bool MCFatalWarnings : 1;
bool MCNoWarn : 1;
bool MCSaveTempLabels : 1;
bool MCUseDwarfDirectory : 1;
bool ShowMCEncoding : 1;
Expand All @@ -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) &&
Expand Down
4 changes: 4 additions & 0 deletions include/llvm/MC/MCTargetOptionsCommandFlags.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ cl::opt<bool> ShowMCInst("asm-show-inst",
cl::opt<bool> FatalWarnings("fatal-warnings",
cl::desc("Treat warnings as errors"));

cl::opt<bool> NoWarn("no-warn", cl::desc("Suppress all warnings"));
cl::alias NoWarnW("W", cl::desc("Alias for --no-warn"), cl::aliasopt(NoWarn));

cl::opt<std::string>
ABIName("target-abi", cl::Hidden,
cl::desc("The name of the ABI to be targeted from the backend."),
Expand All @@ -57,6 +60,7 @@ static inline MCTargetOptions InitMCTargetOptionsFromFlags() {
Options.ShowMCInst = ShowMCInst;
Options.ABIName = ABIName;
Options.MCFatalWarnings = FatalWarnings;
Options.MCNoWarn = NoWarn;
return Options;
}

Expand Down
2 changes: 2 additions & 0 deletions lib/MC/MCParser/AsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,8 @@ void AsmParser::Note(SMLoc L, const Twine &Msg, ArrayRef<SMRange> Ranges) {
}

bool AsmParser::Warning(SMLoc L, const Twine &Msg, ArrayRef<SMRange> Ranges) {
if(getTargetParser().getTargetOptions().MCNoWarn)
return false;
if (getTargetParser().getTargetOptions().MCFatalWarnings)
return Error(L, Msg, Ranges);
printMessage(L, SourceMgr::DK_Warning, Msg, Ranges);
Expand Down
2 changes: 1 addition & 1 deletion lib/MC/MCTargetOptions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() {}

Expand Down
5 changes: 5 additions & 0 deletions test/tools/llvm-mc/no_warnings.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# RUN: llvm-mc --no-warn %s 2>&1 | FileCheck %s
# XFAIL: hexagon

# CHECK-NOT: warning:
.warning

0 comments on commit 937b1ce

Please sign in to comment.