[clang][Driver] AllAddedKinds leaks disabled sanitizer settings into cc1 invocation
SanitizerArgs uses AllAddedKinds, a collection of all sanitizers ever mentioned in a Clang driver invocation, is used to parse many sanitizer-specific options. This is appropriate for claiming and validating arguments, but the resulting properties are frequently not cross-checked against final Kinds. Consequently, disabled sanitizers can still affect cc1 or linker arguments when another sanitizer remains enabled.
This pattern affects multiple sanitizers; CFI is one example:
clang -fsanitize=undefined,cfi -fno-sanitize=cfi -### -x c++ -o- - < /dev/null
The final cc1 -fsanitize= contains only UBSan checks, but the invocation still contains:
"-fsanitize-cfi-canonical-jump-tables"
See https://godbolt.org/z/fszoj9beW
The same underlying pattern occurs in several other sanitizer related settings.
AllAddedKinds should continue controlling parsing & claiming, but properties affecting compilation or linking should additionally be gated by final resolved Kinds.
@llvm/issue-subscribers-clang-driver
Author: Douglas (dgg5503)
This pattern affects multiple sanitizers; CFI is one example:
clang -fsanitize=undefined,cfi -fno-sanitize=cfi -### -x c++ -o- - < /dev/null
The final cc1 -fsanitize= contains only UBSan checks, but the invocation still contains:
"-fsanitize-cfi-canonical-jump-tables"
See https://godbolt.org/z/fszoj9beW
The same underlying pattern occurs in several other sanitizer related settings.
AllAddedKinds should continue controlling parsing & claiming, but properties affecting compilation or linking should additionally be gated by final resolved Kinds.