aboutsummaryrefslogtreecommitdiff
path: root/llvm/tools/llvm-ml/llvm-ml.cpp
diff options
context:
space:
mode:
authorAlan Zhao <ayzhao@google.com>2022-06-02 19:42:37 -0400
committerAlan Zhao <ayzhao@google.com>2022-06-07 13:03:19 -0400
commitae38e4880ec06bf4cfb7088fa66f70676701144c (patch)
tree900bfa01f99e54a220581b1aeac4d6dffd317ce2 /llvm/tools/llvm-ml/llvm-ml.cpp
parentb968c3452b6a6ccef2545d860c4694dc95dcebc1 (diff)
downloadllvm-ae38e4880ec06bf4cfb7088fa66f70676701144c.zip
llvm-ae38e4880ec06bf4cfb7088fa66f70676701144c.tar.gz
llvm-ae38e4880ec06bf4cfb7088fa66f70676701144c.tar.bz2
[llvm-ml] Remove all file extension restrictions
After D126425 was submitted, hans@ observed that MSVC's ml.exe doesn't care about the file's extension at all. Now, we check if the file exists to determine whether an input filename is a valid assembly file. To keep things consistent with clang-cl and lld-link, llvm-ml will treat everything that's not a flag as a filename. Reviewed By: hans Differential Revision: https://reviews.llvm.org/D126931
Diffstat (limited to 'llvm/tools/llvm-ml/llvm-ml.cpp')
-rw-r--r--llvm/tools/llvm-ml/llvm-ml.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/tools/llvm-ml/llvm-ml.cpp b/llvm/tools/llvm-ml/llvm-ml.cpp
index 2651132f2..12cd727 100644
--- a/llvm/tools/llvm-ml/llvm-ml.cpp
+++ b/llvm/tools/llvm-ml/llvm-ml.cpp
@@ -208,9 +208,10 @@ int main(int Argc, char **Argv) {
std::string InputFilename;
for (auto *Arg : InputArgs.filtered(OPT_INPUT)) {
std::string ArgString = Arg->getAsString(InputArgs);
- StringRef ArgStringRef(ArgString);
- if (ArgString == "-" || ArgStringRef.endswith(".asm") ||
- ArgStringRef.endswith(".S")) {
+ bool IsFile = false;
+ std::error_code IsFileEC =
+ llvm::sys::fs::is_regular_file(ArgString, IsFile);
+ if (ArgString == "-" || IsFile) {
if (!InputFilename.empty()) {
WithColor::warning(errs(), ProgName)
<< "does not support multiple assembly files in one command; "
@@ -220,7 +221,7 @@ int main(int Argc, char **Argv) {
} else {
std::string Diag;
raw_string_ostream OS(Diag);
- OS << "invalid option '" << ArgString << "'";
+ OS << ArgString << ": " << IsFileEC.message();
std::string Nearest;
if (T.findNearest(ArgString, Nearest) < 2)