[PATCH] D92504: [ms] [llvm-ml] When warnings are fatal, make sure to fail on warnings

Eric Astor via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 17 11:11:23 PDT 2021


epastor updated this revision to Diff 331323.
epastor added a comment.

Revised to include fatal warning support, and test both cases


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92504/new/

https://reviews.llvm.org/D92504

Files:
  llvm/lib/MC/MCParser/MasmParser.cpp
  llvm/test/tools/llvm-ml/hexfloat_error.asm
  llvm/test/tools/llvm-ml/hexfloat_warn.asm
  llvm/tools/llvm-ml/Opts.td
  llvm/tools/llvm-ml/llvm-ml.cpp


Index: llvm/tools/llvm-ml/llvm-ml.cpp
===================================================================
--- llvm/tools/llvm-ml/llvm-ml.cpp
+++ llvm/tools/llvm-ml/llvm-ml.cpp
@@ -231,6 +231,7 @@
 
   MCTargetOptions MCOptions;
   MCOptions.AssemblyLanguage = "masm";
+  MCOptions.MCFatalWarnings = InputArgs.hasArg(OPT_fatal_warnings);
 
   Triple TheTriple = GetTriple(ProgName, InputArgs);
   std::string Error;
Index: llvm/tools/llvm-ml/Opts.td
===================================================================
--- llvm/tools/llvm-ml/Opts.td
+++ llvm/tools/llvm-ml/Opts.td
@@ -31,6 +31,8 @@
               HelpText<"Target platform (x86 or x86-64)">;
 def as_lex : LLVMFlag<"as-lex">,
              HelpText<"Lex tokens from a .asm file without assembling">;
+def fatal_warnings : LLVMFlag<"fatal-warnings">,
+                     HelpText<"Treat warnings as errors">;
 def filetype : LLVMJoined<"filetype=">, Values<"obj,s,null">,
                HelpText<"Emit a file with the given type">;
 def output_att_asm : LLVMFlag<"output-att-asm">,
@@ -68,6 +70,7 @@
 def assembly_file : MLJoinedOrSeparate<"Ta">,
                     HelpText<"Assemble source file with name not ending with "
                              "the .asm extension">;
+def error_on_warning : MLFlag<"WX">, Alias<fatal_warnings>;
 def parse_only : MLFlag<"Zs">, HelpText<"Run a syntax-check only">,
                  Alias<filetype>, AliasArgs<["null"]>;
 
@@ -102,7 +105,6 @@
 def listing_false_conditionals : UnsupportedFlag<"Sx">, HelpText<"">;
 def extra_warnings : UnsupportedFlag<"w">, HelpText<"">;
 def warning_level : UnsupportedJoined<"W">, HelpText<"">;
-def error_on_warning : UnsupportedFlag<"WX">, HelpText<"">;
 def ignore_include_envvar : UnsupportedFlag<"X">, HelpText<"">;
 def line_number_info : UnsupportedFlag<"Zd">, HelpText<"">;
 def export_all_symbols : UnsupportedFlag<"Zf">, HelpText<"">;
Index: llvm/test/tools/llvm-ml/hexfloat_warn.asm
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-ml/hexfloat_warn.asm
@@ -0,0 +1,12 @@
+; RUN: llvm-ml -filetype=s %s /Fo - 2>&1 | FileCheck %s
+
+.data
+
+; CHECK: :[[# @LINE + 1]]:25: warning: MASM-style hex floats ignore explicit sign
+negative_hexfloat REAL4 -3fa66666r
+; CHECK-LABEL: negative_hexfloat:
+; CHECK-NEXT: .long 1067869798
+
+.code
+
+END
Index: llvm/test/tools/llvm-ml/hexfloat_error.asm
===================================================================
--- /dev/null
+++ llvm/test/tools/llvm-ml/hexfloat_error.asm
@@ -0,0 +1,10 @@
+; RUN: not llvm-ml -filetype=s %s /WX /Fo /dev/null 2>&1 | FileCheck %s --implicit-check-not=error:
+
+.data
+
+; CHECK: :[[# @LINE + 1]]:25: error: MASM-style hex floats ignore explicit sign
+negative_hexfloat REAL4 -3fa66666r
+
+.code
+
+END
Index: llvm/lib/MC/MCParser/MasmParser.cpp
===================================================================
--- llvm/lib/MC/MCParser/MasmParser.cpp
+++ llvm/lib/MC/MCParser/MasmParser.cpp
@@ -4471,8 +4471,9 @@
     return addErrorSuffix(" in align directive");
   // Ignore empty 'align' directives.
   if (getTok().is(AsmToken::EndOfStatement)) {
-    Warning(AlignmentLoc, "align directive with no operand is ignored");
-    return parseToken(AsmToken::EndOfStatement);
+    return Warning(AlignmentLoc,
+                   "align directive with no operand is ignored") &&
+           parseToken(AsmToken::EndOfStatement);
   }
   if (parseAbsoluteExpression(Alignment) ||
       parseToken(AsmToken::EndOfStatement))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92504.331323.patch
Type: text/x-patch
Size: 3521 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210317/925490dc/attachment.bin>


More information about the llvm-commits mailing list