[PATCH] D143971: [clang-tidy] Flag more buggy string constructor cases
Piotr Zegar via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Mar 7 00:51:10 PST 2023
PiotrZSL added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp:97
+ const auto CharToIntCastExpr = implicitCastExpr(
+ hasSourceExpression(expr(hasType(qualType(isAnyCharacter())))),
+ hasImplicitDestinationType(NonCharacterInteger));
----------------
PiotrZSL wrote:
> reuse here CharExpr
try with test like this:
```
struct Class
{
operator char() const;
};
Class c;
std::string value(c, 5);
```
I fear that hasSourceExpression could match Class type, and therefore this case wouldn't be detected.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D143971/new/
https://reviews.llvm.org/D143971
More information about the cfe-commits
mailing list