clang-tools
11.0.0
clang-tools-extra
clang-tidy
bugprone
SignedCharMisuseCheck.h
Go to the documentation of this file.
1
//===--- SignedCharMisuseCheck.h - clang-tidy -------------------*- C++ -*-===//
2
//
3
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
9
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SIGNEDCHARMISUSECHECK_H
10
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SIGNEDCHARMISUSECHECK_H
11
12
#include "../ClangTidyCheck.h"
13
14
namespace
clang
{
15
namespace
tidy {
16
namespace
bugprone {
17
18
/// Finds those ``signed char`` -> integer conversions which might indicate a
19
/// programming error. The basic problem with the ``signed char``, that it might
20
/// store the non-ASCII characters as negative values. This behavior can cause a
21
/// misunderstanding of the written code both when an explicit and when an
22
/// implicit conversion happens.
23
///
24
/// For the user-facing documentation see:
25
/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-signed-char-misuse.html
26
class
SignedCharMisuseCheck
:
public
ClangTidyCheck
{
27
public
:
28
SignedCharMisuseCheck
(StringRef
Name
,
ClangTidyContext
*Context);
29
30
void
storeOptions
(
ClangTidyOptions::OptionMap
&Opts)
override
;
31
void
registerMatchers
(ast_matchers::MatchFinder *Finder)
override
;
32
void
check
(
const
ast_matchers::MatchFinder::MatchResult &Result)
override
;
33
34
private
:
35
ast_matchers::internal::BindableMatcher<clang::Stmt> charCastExpression(
36
bool
IsSigned,
37
const
ast_matchers::internal::Matcher<clang::QualType> &IntegerType,
38
const
std::string &CastBindName)
const
;
39
40
const
std::string CharTypdefsToIgnoreList;
41
const
bool
DiagnoseSignedUnsignedCharComparisons;
42
};
43
44
}
// namespace bugprone
45
}
// namespace tidy
46
}
// namespace clang
47
48
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SIGNEDCHARMISUSECHECK_H
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition:
ClangTidyCheck.h:114
clang::tidy::bugprone::SignedCharMisuseCheck::storeOptions
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
Definition:
SignedCharMisuseCheck.cpp:36
clang::tidy::bugprone::SignedCharMisuseCheck::SignedCharMisuseCheck
SignedCharMisuseCheck(StringRef Name, ClangTidyContext *Context)
Definition:
SignedCharMisuseCheck.cpp:29
clang::tidy::bugprone::SignedCharMisuseCheck
Finds those signed char -> integer conversions which might indicate a programming error.
Definition:
SignedCharMisuseCheck.h:26
clang::tidy::bugprone::SignedCharMisuseCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition:
SignedCharMisuseCheck.cpp:78
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition:
ClangTidyDiagnosticConsumer.h:76
Name
static constexpr llvm::StringLiteral Name
Definition:
UppercaseLiteralSuffixCheck.cpp:27
clang::tidy::bugprone::SignedCharMisuseCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition:
SignedCharMisuseCheck.cpp:131
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition:
ApplyReplacements.h:27
clang::tidy::ClangTidyOptions::OptionMap
std::map< std::string, ClangTidyValue > OptionMap
Definition:
ClangTidyOptions.h:111
Generated on Tue Jul 28 2020 16:14:03 for clang-tools by
1.8.16