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
trim is probably not the responsibility of cc1. cc1 can assume that the options are already in some checked forms.