[PATCH] D143971: [clang-tidy] Flag more buggy string constructor cases
Piotr Zegar via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Sun Jun 11 22:37:57 PDT 2023
PiotrZSL added inline comments.
================
Comment at: clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp:69
void StringConstructorCheck::registerMatchers(MatchFinder *Finder) {
+ const auto SignedCharType = qualType(isAnyCharacter(), isSignedInteger());
const auto ZeroExpr = expr(ignoringParenImpCasts(integerLiteral(equals(0))));
----------------
this may incorrectly work also for signed char, we want it work only for char and wchat_t, not signed char, unsigned char, signed wchar_t, unsigned wchar_t.
So this still need some work. I would say new "isAnyCharacter" need to be created.
================
Comment at: clang-tools-extra/clang-tidy/bugprone/StringConstructorCheck.cpp:96
+ const auto NonCharacterInteger =
+ qualType(isInteger(), unless(isAnyCharacter()));
+ const auto CharToIntCastExpr = implicitCastExpr(
----------------
Similar could be here, we consider std::uint8_t and std::sint8_t as integers, not as an characters, same with signed char, unsigned char
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