[llvm-mc] Add --no-warn flag with -W alias to disable outputting warnings while assem...
authorColin LeMahieu <colinl@codeaurora.org>
Mon, 27 Jul 2015 22:39:14 +0000 (22:39 +0000)
committerColin LeMahieu <colinl@codeaurora.org>
Mon, 27 Jul 2015 22:39:14 +0000 (22:39 +0000)
llvm-svn: 243338

llvm/include/llvm/MC/MCTargetOptions.h
llvm/include/llvm/MC/MCTargetOptionsCommandFlags.h
llvm/lib/MC/MCParser/AsmParser.cpp
llvm/lib/MC/MCTargetOptions.cpp
llvm/test/tools/llvm-mc/no_warnings.test [new file with mode: 0644]

index 7f4f23e..00a74de 100644 (file)
@@ -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) &&
index 1c08d17..1240e13 100644 (file)
@@ -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."),
@@ -57,6 +60,7 @@ static inline MCTargetOptions InitMCTargetOptionsFromFlags() {
   Options.ShowMCInst = ShowMCInst;
   Options.ABIName = ABIName;
   Options.MCFatalWarnings = FatalWarnings;
+  Options.MCNoWarn = NoWarn;
   return Options;
 }
 
index 04d1413..3f45b3d 100644 (file)
@@ -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);
index 1258d9e..64796af 100644 (file)
@@ -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/llvm/test/tools/llvm-mc/no_warnings.test b/llvm/test/tools/llvm-mc/no_warnings.test
new file mode 100644 (file)
index 0000000..f542f17
--- /dev/null
@@ -0,0 +1,5 @@
+# RUN: llvm-mc --no-warn %s 2>&1 | FileCheck %s
+# XFAIL: hexagon
+
+# CHECK-NOT: warning:
+.warning