[clang] [sanitizer] Fix empty string in unsupported argument error for -fsanitize-trap (PR #136549)

Thurston Dang via cfe-commits cfe-commits at lists.llvm.org
Wed May 14 12:41:22 PDT 2025


thurstond wrote:

Sorry, I didn't notice being tagged earlier. It didn't show up in my review queue since the "Request Review" wasn't used.

Thanks for the patch! I agree this is an improvement over the empty output, but it's arguably confusing to tell the user `unsupported argument 'memtag-stack,memtag-heap,memtag-globals'` when they had actually specified `-fsanitize-trap=memtag`. Perhaps the better fix be to correct the toString function:

```
static std::string toString(const clang::SanitizerSet &Sanitizers) {
  std::string Res;
#define SANITIZER(NAME, ID)                                                    \
  if (Sanitizers.has(SanitizerKind::ID)) {                                     \
    if (!Res.empty())                                                          \
      Res += ",";                                                              \
    Res += NAME;                                                               \
  }
#include "clang/Basic/Sanitizers.def"
  return Res;
}
```
(clang/lib/Driver/SanitizerArgs.cpp)

 so that it works for SANITIZER_GROUP instead of only SANITIZER.

https://github.com/llvm/llvm-project/pull/136549


More information about the cfe-commits mailing list