Clang with debug builds will crash when run with empty target feature input. And the warning message is a little bit confusing. This patch adds an empty check and adds a new diagnostic to illustrate where goes wrong.
Before:
// clang will crash or emit '-' is not a recognized feature for this target (ignoring feature) clang -cc1 -target riscv64-unknown-elf -target-feature '' ./test.c // clang will emit '-' is not a recognized feature for this target (ignoring feature) clang -cc1 -target riscv64-unknown-elf -target-feature m ./test.c
Now:
// clang will ignoring the empty input clang -cc1 -target riscv64-unknown-elf -target-feature '' ./test.c // clang will emit warning: feature flags 'm' should start with '+' or '-' clang -cc1 -target riscv64-unknown-elf -target-feature m ./test.c
You should also wrap this to roughly 80 columns and put it into a diagnostic group (I think InvalidCommandLineArgument is the correct group for this to use). Also, this diagnostic is specific to the frontend, so it should live in DiagnosticFrontendKinds.td instead of DiagnosticCommonKinds.td (we use the common file for diagnostics that are triggered across multiple components).