clang-tools
11.0.0
clang-tools-extra
clang-tidy
readability
RedundantSmartptrGetCheck.h
Go to the documentation of this file.
1
//===--- RedundantSmartptrGetCheck.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_READABILITY_REDUNDANTSMARTPTRGETCHECK_H
10
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANTSMARTPTRGETCHECK_H
11
12
#include "../ClangTidyCheck.h"
13
14
namespace
clang
{
15
namespace
tidy {
16
namespace
readability {
17
18
/// Find and remove redundant calls to smart pointer's `.get()` method.
19
///
20
/// Examples:
21
///
22
/// \code
23
/// ptr.get()->Foo() ==> ptr->Foo()
24
/// *ptr.get() ==> *ptr
25
/// *ptr->get() ==> **ptr
26
/// \endcode
27
class
RedundantSmartptrGetCheck
:
public
ClangTidyCheck
{
28
public
:
29
RedundantSmartptrGetCheck
(StringRef
Name
,
ClangTidyContext
*Context)
30
:
ClangTidyCheck
(
Name
, Context),
31
IgnoreMacros(
Options
.getLocalOrGlobal(
"IgnoreMacros"
, true)) {}
32
bool
isLanguageVersionSupported
(
const
LangOptions &LangOpts)
const override
{
33
return
LangOpts.CPlusPlus;
34
}
35
void
storeOptions
(
ClangTidyOptions::OptionMap
&Opts)
override
;
36
void
registerMatchers
(ast_matchers::MatchFinder *Finder)
override
;
37
void
check
(
const
ast_matchers::MatchFinder::MatchResult &Result)
override
;
38
39
private
:
40
const
bool
IgnoreMacros;
41
};
42
43
}
// namespace readability
44
}
// namespace tidy
45
}
// namespace clang
46
47
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANTSMARTPTRGETCHECK_H
clang::tidy::readability::RedundantSmartptrGetCheck
Find and remove redundant calls to smart pointer's .get() method.
Definition:
RedundantSmartptrGetCheck.h:27
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition:
ClangTidyCheck.h:114
clang::tidy::readability::RedundantSmartptrGetCheck::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:
RedundantSmartptrGetCheck.cpp:96
clang::tidy::readability::RedundantSmartptrGetCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition:
RedundantSmartptrGetCheck.cpp:124
clang::tidy::ClangTidyCheck::Options
OptionsView Options
Definition:
ClangTidyCheck.h:471
clang::tidy::readability::RedundantSmartptrGetCheck::isLanguageVersionSupported
bool isLanguageVersionSupported(const LangOptions &LangOpts) const override
Override this to disable registering matchers and PP callbacks if an invalid language version is bein...
Definition:
RedundantSmartptrGetCheck.h:32
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
===– Representation.cpp - ClangDoc Representation --------—*- C++ -*-===//
Definition:
ApplyReplacements.h:27
clang::tidy::readability::RedundantSmartptrGetCheck::RedundantSmartptrGetCheck
RedundantSmartptrGetCheck(StringRef Name, ClangTidyContext *Context)
Definition:
RedundantSmartptrGetCheck.h:29
clang::tidy::ClangTidyOptions::OptionMap
std::map< std::string, ClangTidyValue > OptionMap
Definition:
ClangTidyOptions.h:111
clang::tidy::readability::RedundantSmartptrGetCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition:
RedundantSmartptrGetCheck.cpp:101
Generated on Tue Jul 28 2020 16:14:03 for clang-tools by
1.8.16