[clang-tools-extra] [clang-tidy] Add modernize-substr-to-starts-with check (PR #116033)
via cfe-commits
cfe-commits at lists.llvm.org
Thu Nov 14 07:34:56 PST 2024
EugeneZelenko wrote:
> refactored and integrated into existing checker. seems to work, with my local test.cpp files. however i am struggling, adding tests.
>
> https://github.com/llvm/llvm-project/pull/116033/files#diff-da808871a68f05cbe09bd3761e5092a51a46608bd2206db26c2a98f93e75f68cR274
>
> .substr() is undefined.
>
> ```
> error: no member named 'substr' in 'std::basic_string<char>' [clang-diagnostic-error]
> 268 | s.substr(0, 5) == "hello";
> ```
>
> any advice? or sample where i can take a look how to get a real std::string or how to mock it?
Tests use mock-up header (`clang-tools-extra/test/clang-tidy/checkers/Inputs/Headers/string`), so you need to add `substr` there.
https://github.com/llvm/llvm-project/pull/116033
More information about the cfe-commits
mailing list