[PATCH] D91015: [clang-tidy] Extend bugprone-string-constructor-check to std::string_view.
Chris Kennelly via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 16 21:07:34 PST 2020
ckennelly added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp:65
+ const auto hasStringCtorName =
+ hasAnyNameStdString(removeNamespaces(StringNames));
+
----------------
aaron.ballman wrote:
> It took me a while to realize that this functionality is really about trying to get to the name of the constructor for a given type -- perhaps this should be a single function called `getCtorNameFromType()` or something?
>
> Actually, given that this is a narrowing matcher from a `CXXConstructExpr`, can't you look at `CXXConstructExpr::getConstructor()` to get the `CXXConstructorDecl` and check the name from there? That seems cleaner than trying to identify the constructor name through string matching.
I applied ymandel's suggestion, which I think simplified things a bit.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D91015/new/
https://reviews.llvm.org/D91015
More information about the cfe-commits
mailing list