clang-tools
8.0.0
llvm.src
tools
clang
tools
extra
clang-tidy
bugprone
MisplacedWideningCastCheck.h
Go to the documentation of this file.
1
//===--- MisplacedWideningCastCheck.h - clang-tidy---------------*- C++ -*-===//
2
//
3
// The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
10
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_MISPLACEDWIDENINGCASTCHECK_H
11
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_BUGPRONE_MISPLACEDWIDENINGCASTCHECK_H
12
13
#include "../ClangTidy.h"
14
15
namespace
clang
{
16
namespace
tidy {
17
namespace
bugprone {
18
19
/// Find casts of calculation results to bigger type. Typically from int to
20
/// long. If the intention of the cast is to avoid loss of precision then
21
/// the cast is misplaced, and there can be loss of precision. Otherwise
22
/// such cast is ineffective.
23
///
24
/// There is one option:
25
///
26
/// - `CheckImplicitCasts`: Whether to check implicit casts as well which may
27
// be the most common case. Enabled by default.
28
///
29
/// For the user-facing documentation see:
30
/// http://clang.llvm.org/extra/clang-tidy/checks/bugprone-misplaced-widening-cast.html
31
class
MisplacedWideningCastCheck
:
public
ClangTidyCheck
{
32
public
:
33
MisplacedWideningCastCheck
(StringRef
Name
,
ClangTidyContext
*Context);
34
void
storeOptions
(
ClangTidyOptions::OptionMap
&Opts)
override
;
35
void
registerMatchers
(ast_matchers::MatchFinder *Finder)
override
;
36
void
check
(
const
ast_matchers::MatchFinder::MatchResult &
Result
)
override
;
37
38
private
:
39
const
bool
CheckImplicitCasts;
40
};
41
42
}
// namespace bugprone
43
}
// namespace tidy
44
}
// namespace clang
45
46
#endif
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition:
ClangTidy.h:127
clang::tidy::bugprone::MisplacedWideningCastCheck
Find casts of calculation results to bigger type.
Definition:
MisplacedWideningCastCheck.h:31
clang::tidy::bugprone::MisplacedWideningCastCheck::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:
MisplacedWideningCastCheck.cpp:26
clang::tidy::bugprone::MisplacedWideningCastCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition:
MisplacedWideningCastCheck.cpp:31
clang::tidy::bugprone::MisplacedWideningCastCheck::MisplacedWideningCastCheck
MisplacedWideningCastCheck(StringRef Name, ClangTidyContext *Context)
Definition:
MisplacedWideningCastCheck.cpp:21
Name
static constexpr llvm::StringLiteral Name
Definition:
UppercaseLiteralSuffixCheck.cpp:28
clang::tidy::ClangTidyOptions::OptionMap
std::map< std::string, std::string > OptionMap
Definition:
ClangTidyOptions.h:98
clang::tidy::bugprone::MisplacedWideningCastCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition:
MisplacedWideningCastCheck.cpp:184
Result
llvm::Optional< llvm::Expected< tooling::AtomicChanges > > Result
Definition:
ClangdServer.cpp:60
clang
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition:
ChangeNamespace.cpp:18
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition:
ClangTidyDiagnosticConsumer.h:100
Generated on Thu Feb 28 2019 09:32:56 for clang-tools by
1.8.13