[clang-tools-extra] [clang-tidy][NFC] Fix a couple of suspicious StringRef::data() usages (PR #158480)
via cfe-commits
cfe-commits at lists.llvm.org
Sun Sep 14 11:06:37 PDT 2025
capitan-davide wrote:
> LGTM But there are still some violations left?
Yes, two more. Unfortunately, they require some refactoring as `llvm::yaml::IO` API uses C-strings only.
```sh
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp:102:36: warning: result of a `data()` call may not be null terminated, provide size information to the callee to prevent potential issues [bugprone-suspicious-stringview-data-usage]
102 | IO.preflightKey(Option.first.data(), true, false, UseDefault, SaveInfo);
| ~~~~~~~~~~~~~^~~~
clang-tools-extra/clang-tidy/ClangTidyOptions.cpp:119:28: warning: result of a `data()` call may not be null terminated, provide size information to the callee to prevent potential issues [bugprone-suspicious-stringview-data-usage]
119 | IO.mapRequired(Key.data(), Val[Key].Value);
| ~~~~^~~~
```
https://github.com/llvm/llvm-project/pull/158480
More information about the cfe-commits
mailing list