Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ static constexpr int UnsignedASCIIUpperBound = 127;
SignedCharMisuseCheck::SignedCharMisuseCheck(StringRef Name,
ClangTidyContext *Context)
: ClangTidyCheck(Name, Context),
CharTypdefsToIgnoreList(Options.get("CharTypdefsToIgnore", "")),
CharTypedefsToIgnoreList(Options.get("CharTypedefsToIgnore", "")),
DiagnoseSignedUnsignedCharComparisons(
Options.get("DiagnoseSignedUnsignedCharComparisons", true)) {}

void SignedCharMisuseCheck::storeOptions(ClangTidyOptions::OptionMap &Opts) {
Options.store(Opts, "CharTypdefsToIgnore", CharTypdefsToIgnoreList);
Options.store(Opts, "CharTypedefsToIgnore", CharTypedefsToIgnoreList);
Options.store(Opts, "DiagnoseSignedUnsignedCharComparisons",
DiagnoseSignedUnsignedCharComparisons);
}
Expand All @@ -39,7 +39,7 @@ BindableMatcher<clang::Stmt> SignedCharMisuseCheck::charCastExpression(
// (e.g. typedef char sal_Int8). In this case, we don't need to
// worry about the misinterpretation of char values.
const auto IntTypedef = qualType(hasDeclaration(typedefDecl(
hasAnyName(utils::options::parseStringList(CharTypdefsToIgnoreList)))));
hasAnyName(utils::options::parseStringList(CharTypedefsToIgnoreList)))));

auto CharTypeExpr = expr();
if (IsSigned) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class SignedCharMisuseCheck : public ClangTidyCheck {
const ast_matchers::internal::Matcher<clang::QualType> &IntegerType,
const std::string &CastBindName) const;

const StringRef CharTypdefsToIgnoreList;
const StringRef CharTypedefsToIgnoreList;
const bool DiagnoseSignedUnsignedCharComparisons;
};

Expand Down
7 changes: 5 additions & 2 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,11 @@ Potentially Breaking Changes
:doc:`bugprone-easily-swappable-parameters
<clang-tidy/checks/bugprone/easily-swappable-parameters>` from
``NamePrefixSuffixSilenceDissimilarityTreshold`` to
``NamePrefixSuffixSilenceDissimilarityThreshold``,
correcting a spelling mistake.
``NamePrefixSuffixSilenceDissimilarityThreshold`` and of check
:doc:`bugprone-signed-char-misuse
<clang-tidy/checks/bugprone/signed-char-misuse>` from
``CharTypdefsToIgnore`` to ``CharTypedefsToIgnore``,
correcting spelling mistakes.

Improvements to clangd
----------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ so both arguments will have the same type.
Options
-------

.. option:: CharTypdefsToIgnore
.. option:: CharTypedefsToIgnore

A semicolon-separated list of typedef names. In this list, we can list
typedefs for ``char`` or ``signed char``, which will be ignored by the
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// RUN: %check_clang_tidy %s bugprone-signed-char-misuse %t \
// RUN: -config='{CheckOptions: \
// RUN: {bugprone-signed-char-misuse.CharTypdefsToIgnore: "sal_Int8;int8_t"}}' \
// RUN: {bugprone-signed-char-misuse.CharTypedefsToIgnore: "sal_Int8;int8_t"}}' \
// RUN: --

///////////////////////////////////////////////////////////////////
Expand Down
Loading