clang-tools
3.8.0
Main Page
Namespaces
Classes
Files
File List
File Members
work
release-test
final
docsbuild
llvm.src
tools
clang
tools
extra
clang-tidy
misc
AssertSideEffectCheck.h
Go to the documentation of this file.
1
//===--- AssertSideEffectCheck.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_MISC_ASSERTSIDEEFFECTCHECK_H
11
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_ASSERTSIDEEFFECTCHECK_H
12
13
#include "../ClangTidy.h"
14
#include "llvm/ADT/SmallVector.h"
15
#include "llvm/ADT/StringRef.h"
16
#include <string>
17
18
namespace
clang {
19
namespace
tidy {
20
21
/// Finds `assert()` with side effect.
22
///
23
/// The condition of `assert()` is evaluated only in debug builds so a
24
/// condition with side effect can cause different behavior in debug / release
25
/// builds.
26
///
27
/// There are two options:
28
///
29
/// - `AssertMacros`: A comma-separated list of the names of assert macros to
30
/// be checked.
31
/// - `CheckFunctionCalls`: Whether to treat non-const member and non-member
32
/// functions as they produce side effects. Disabled by default because it
33
/// can increase the number of false positive warnings.
34
class
AssertSideEffectCheck
:
public
ClangTidyCheck
{
35
public
:
36
AssertSideEffectCheck
(StringRef
Name
,
ClangTidyContext
*
Context
);
37
void
storeOptions
(
ClangTidyOptions::OptionMap
&Opts)
override
;
38
void
registerMatchers
(ast_matchers::MatchFinder *
Finder
)
override
;
39
void
check
(
const
ast_matchers::MatchFinder::MatchResult &
Result
)
override
;
40
41
private
:
42
const
bool
CheckFunctionCalls;
43
const
std::string RawAssertList;
44
SmallVector<StringRef, 5> AssertMacros;
45
};
46
47
}
// namespace tidy
48
}
// namespace clang
49
50
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_ASSERTSIDEEFFECTCHECK_H
Name
StringHandle Name
Definition:
PreprocessorTracker.cpp:525
Finder
std::unique_ptr< ast_matchers::MatchFinder > Finder
Definition:
ClangTidy.cpp:188
clang::tidy::AssertSideEffectCheck
Finds assert() with side effect.
Definition:
AssertSideEffectCheck.h:34
clang::tidy::AssertSideEffectCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition:
AssertSideEffectCheck.cpp:94
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition:
ClangTidy.h:102
clang::tidy::AssertSideEffectCheck::AssertSideEffectCheck
AssertSideEffectCheck(StringRef Name, ClangTidyContext *Context)
Definition:
AssertSideEffectCheck.cpp:71
clang::tidy::AssertSideEffectCheck::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:
AssertSideEffectCheck.cpp:80
clang::tidy::AssertSideEffectCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register ASTMatchers with Finder.
Definition:
AssertSideEffectCheck.cpp:85
clang::tidy::ClangTidyOptions::OptionMap
std::map< std::string, std::string > OptionMap
Definition:
ClangTidyOptions.h:82
Context
ClangTidyContext & Context
Definition:
ClangTidy.cpp:93
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition:
ClangTidyDiagnosticConsumer.h:124
Result
const NamedDecl * Result
Definition:
USRFinder.cpp:121
Generated on Mon Mar 7 2016 09:54:11 for clang-tools by
1.8.6