diff --git a/llvm/test/tools/llvm-ml/invalid_file_extension.blah b/llvm/test/tools/llvm-ml/invalid_file_extension.blah new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-ml/invalid_file_extension.blah @@ -0,0 +1,8 @@ +; RUN: not llvm-ml %s /Fo /dev/null 2>&1 | FileCheck %s --check-prefixes=CHECK-INVALID +; RUN: llvm-ml /Ta %s -m64 -filetype=s /Fo - | FileCheck %s --check-prefixes=CHECK-TA + +; CHECK-INVALID: error: invalid option '{{.*}}invalid_file_extension.blah' + +.code +foo: +; CHECK-TA: foo: diff --git a/llvm/test/tools/llvm-ml/lit.local.cfg b/llvm/test/tools/llvm-ml/lit.local.cfg --- a/llvm/test/tools/llvm-ml/lit.local.cfg +++ b/llvm/test/tools/llvm-ml/lit.local.cfg @@ -3,3 +3,5 @@ config.unsupported = True config.suffixes.add('.asm') +config.suffixes.add('.S') +config.suffixes.add('.blah') diff --git a/llvm/test/tools/llvm-ml/valid_file_extension.S b/llvm/test/tools/llvm-ml/valid_file_extension.S new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-ml/valid_file_extension.S @@ -0,0 +1,5 @@ +; RUN: llvm-ml -m64 -filetype=s %s /Fo - | FileCheck %s + +.code +foo: +; CHECK: foo: diff --git a/llvm/tools/llvm-ml/Opts.td b/llvm/tools/llvm-ml/Opts.td --- a/llvm/tools/llvm-ml/Opts.td +++ b/llvm/tools/llvm-ml/Opts.td @@ -31,7 +31,7 @@ def bitness : LLVMJoined<"m">, Values<"32,64">, HelpText<"Target platform (x86 or x86-64)">; def as_lex : LLVMFlag<"as-lex">, - HelpText<"Lex tokens from a .asm file without assembling">; + HelpText<"Lex tokens from an .asm or .S file without assembling">; def debug : LLVMFlag<"debug">, Flags<[HelpHidden]>, HelpText<"Enable debug output">; def debug_only : LLVMCommaJoined<"debug-only=">, Flags<[HelpHidden]>, @@ -82,7 +82,7 @@ "32-bit.">; def assembly_file : MLJoinedOrSeparate<"Ta">, HelpText<"Assemble source file with name not ending with " - "the .asm extension">; + "the .asm or the .S extension">; def error_on_warning : MLFlag<"WX">, Alias; def parse_only : MLFlag<"Zs">, HelpText<"Run a syntax-check only">, Alias, AliasArgs<["null"]>; diff --git a/llvm/tools/llvm-ml/llvm-ml.cpp b/llvm/tools/llvm-ml/llvm-ml.cpp --- a/llvm/tools/llvm-ml/llvm-ml.cpp +++ b/llvm/tools/llvm-ml/llvm-ml.cpp @@ -208,7 +208,9 @@ std::string InputFilename; for (auto *Arg : InputArgs.filtered(OPT_INPUT)) { std::string ArgString = Arg->getAsString(InputArgs); - if (ArgString == "-" || StringRef(ArgString).endswith(".asm")) { + StringRef ArgStringRef(ArgString); + if (ArgString == "-" || ArgStringRef.endswith(".asm") || + ArgStringRef.endswith(".S")) { if (!InputFilename.empty()) { WithColor::warning(errs(), ProgName) << "does not support multiple assembly files in one command; " @@ -234,7 +236,7 @@ << "does not support multiple assembly files in one command; " << "ignoring '" << InputFilename << "'\n"; } - InputFilename = Arg->getAsString(InputArgs); + InputFilename = Arg->getValue(); } for (auto *Arg : InputArgs.filtered(OPT_unsupported_Group)) {