[PATCH] D69548: Give clang-tidy readability-redundant-string-init a customizable list of string types to fix
Dmitri Gribenko via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 31 10:29:51 PDT 2019
gribozavr2 requested changes to this revision.
gribozavr2 added inline comments.
This revision now requires changes to proceed.
================
Comment at: clang-tools-extra/clang-tidy/readability/RedundantStringInitCheck.cpp:21
+const char DefaultStringNames[] = "basic_string";
+
----------------
poelmanc wrote:
> aaron.ballman wrote:
> > I think the default should probably be `::std::basic_string` to avoid getting other things named `basic_string`?
> The prior code had `basic_string` hard-coded at lines 27, 31, and 50 so I initially set the default to `basic_string` just to keep the default behavior unchanged.
>
> I just now tried setting it to each of `std::basic_string`, `::std::basic_string`, and even `std::string;std::wstring` and the `readability-redundant-string-init.cpp` tests failed with any of those settings, so I've left it set to `basic_string`.
I think we should change the checker behavior so that it checks against the fully-qualified name.
We are defining a user-settable option, and changing its behavior later to allow fully-qualified names could be difficult.
The reason why tests failed for you is because below the name "basic_string" is used as a method name (the name of the constructor). That checker should be rewritten to check the name of the type.
Repository:
rCTE Clang Tools Extra
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D69548/new/
https://reviews.llvm.org/D69548
More information about the cfe-commits
mailing list