clang-tools  10.0.0git
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 ``signed char`` -> integer conversions which might indicate a programming
19 /// error. The basic problem with the ``signed char``, that it might store the
20 /// non-ASCII characters as negative values. The human programmer probably
21 /// expects that after an integer conversion the converted value matches with the
22 /// character code (a value from [0..255]), however, the actual value is in
23 /// [-128..127] interval. This also applies to the plain ``char`` type on
24 /// those implementations which represent ``char`` similar to ``signed char``.
25 ///
26 /// For the user-facing documentation see:
27 /// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-signed-char-misuse.html
29 public:
30  SignedCharMisuseCheck(StringRef Name, ClangTidyContext *Context);
31 
32  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
33  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
34  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
35 
36 private:
37  const std::string CharTypdefsToIgnoreList;
38 };
39 
40 } // namespace bugprone
41 } // namespace tidy
42 } // namespace clang
43 
44 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_SIGNEDCHARMISUSECHECK_H
Finds signed char -> integer conversions which might indicate a programming error.
Base class for all clang-tidy checks.
static constexpr llvm::StringLiteral Name
std::map< std::string, std::string > OptionMap
SignedCharMisuseCheck(StringRef Name, ClangTidyContext *Context)
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.