[PATCH] D135389: [Clang] Emit a warning for ambiguous joined '-o' arguments
Artem Belevich via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 6 13:18:47 PDT 2022
tra added a comment.
LGTM in principle.
================
Comment at: clang/lib/Driver/Driver.cpp:337
+ std::string Nearest;
+ if (getOpts().findNearest("-" + ArgString, Nearest, IncludedFlagsBitmask,
+ ExcludedFlagsBitmask) == 1)
----------------
This looks for all 1-symbol mismatches. and may trigger on differences other than `--option` vs `-option`. E.g. if user passes `-oip-link` (which looks like something we may see in real life), we'll try to find the nearest for `--oip-link` and will get a distance-1 match for the existing option `--hip-link`.
We may need to verify that the nearest match that we've found is indeed due to a missing leading `dash`.
================
Comment at: clang/test/Driver/unknown-arg.c:68
+
+// RUN: %clang -### -offload-arch=sm_70 --offload-arch=sm_70 -offload-device-only -output -o foo \
+// RUN: %s 2>&1 | FileCheck --check-prefix=O-WARN %s
----------------
I'd also add a test verifying that `-o ffload-device-only` does not trigger the warning.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D135389/new/
https://reviews.llvm.org/D135389
More information about the cfe-commits
mailing list