clang-tools
6.0.0
llvm.src
tools
clang
tools
extra
clang-tidy
modernize
ReplaceAutoPtrCheck.h
Go to the documentation of this file.
1
//===--- ReplaceAutoPtrCheck.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_MODERNIZE_REPLACE_AUTO_PTR_H
11
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACE_AUTO_PTR_H
12
13
#include "../ClangTidy.h"
14
#include "../utils/IncludeInserter.h"
15
16
namespace
clang
{
17
namespace
tidy {
18
namespace
modernize {
19
20
/// Transforms the deprecated `std::auto_ptr` into the C++11 `std::unique_ptr`.
21
///
22
/// Note that both the `std::auto_ptr` type and the transfer of ownership are
23
/// transformed. `std::auto_ptr` provides two ways to transfer the ownership,
24
/// the copy-constructor and the assignment operator. Unlike most classes these
25
/// operations do not 'copy' the resource but they 'steal' it.
26
/// `std::unique_ptr` uses move semantics instead, which makes the intent of
27
/// transferring the resource explicit. This difference between the two smart
28
/// pointers requeres to wrap the copy-ctor and assign-operator with
29
/// `std::move()`.
30
///
31
/// For example, given:
32
///
33
/// \code
34
/// std::auto_ptr<int> i, j;
35
/// i = j;
36
/// \endcode
37
///
38
/// This code is transformed to:
39
///
40
/// \code
41
/// std::unique_ptr<in> i, j;
42
/// i = std::move(j);
43
/// \endcode
44
class
ReplaceAutoPtrCheck
:
public
ClangTidyCheck
{
45
public
:
46
ReplaceAutoPtrCheck
(StringRef
Name
,
ClangTidyContext
*Context);
47
void
storeOptions
(
ClangTidyOptions::OptionMap
&Opts)
override
;
48
void
registerMatchers
(ast_matchers::MatchFinder *Finder)
override
;
49
void
registerPPCallbacks
(CompilerInstance &Compiler)
override
;
50
void
check
(
const
ast_matchers::MatchFinder::MatchResult &Result)
override
;
51
52
private
:
53
std::unique_ptr<utils::IncludeInserter> Inserter;
54
const
utils::IncludeSorter::IncludeStyle
IncludeStyle;
55
};
56
57
}
// namespace modernize
58
}
// namespace tidy
59
}
// namespace clang
60
61
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MODERNIZE_REPLACE_AUTO_PTR_H
clang::tidy::modernize::ReplaceAutoPtrCheck
Transforms the deprecated std::auto_ptr into the C++11 std::unique_ptr.
Definition:
ReplaceAutoPtrCheck.h:44
Name
StringHandle Name
Definition:
PreprocessorTracker.cpp:525
clang::tidy::utils::IncludeSorter::IncludeStyle
IncludeStyle
Supported include styles.
Definition:
IncludeSorter.h:27
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition:
ClangTidy.h:127
clang::tidy::modernize::ReplaceAutoPtrCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
clang::tidy::ClangTidyOptions::OptionMap
std::map< std::string, std::string > OptionMap
Definition:
ClangTidyOptions.h:99
clang::tidy::modernize::ReplaceAutoPtrCheck::registerPPCallbacks
void registerPPCallbacks(CompilerInstance &Compiler) override
Override this to register PPCallbacks with Compiler.
clang
Definition:
AndroidTidyModule.cpp:28
clang::tidy::modernize::ReplaceAutoPtrCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
clang::tidy::modernize::ReplaceAutoPtrCheck::storeOptions
void storeOptions(ClangTidyOptions::OptionMap &Opts) override
Should store all options supported by this check with their current values or default values for opti...
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition:
ClangTidyDiagnosticConsumer.h:104
clang::tidy::modernize::ReplaceAutoPtrCheck::ReplaceAutoPtrCheck
ReplaceAutoPtrCheck(StringRef Name, ClangTidyContext *Context)
Generated on Thu Feb 8 2018 09:13:45 for clang-tools by
1.8.13