clang-tools 3.8.0

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

UniqueptrResetReleaseCheck.h
Go to the documentation of this file.
1 //===--- UniqueptrResetReleaseCheck.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_UNIQUEPTRRESETRELEASECHECK_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_UNIQUEPTRRESETRELEASECHECK_H
12
13 #include "../ClangTidy.h"
14
15 namespace clang {
16 namespace tidy {
17 namespace misc {
18
19 /// Find and replace `unique_ptr::reset(release())` with `std::move()`.
20 ///
21 /// Example:
22 ///
23 /// \code
24 /// std::unique_ptr<Foo> x, y;
25 /// x.reset(y.release()); -> x = std::move(y);
26 /// \endcode
27 ///
28 /// If `y` is already rvalue, `std::move()` is not added. `x` and `y` can also
29 /// be `std::unique_ptr<Foo>*`.
30 class UniqueptrResetReleaseCheck : public ClangTidyCheck {
31 public:
32 UniqueptrResetReleaseCheck(StringRef Name, ClangTidyContext *Context)
33 : ClangTidyCheck(Name, Context) {}
34
35 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
36 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
37 };
38
39 } // namespace misc
40 } // namespace tidy
41 } // namespace clang
42
43 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_UNIQUEPTRRESETRELEASECHECK_H
clang::tidy::misc::UniqueptrResetReleaseCheck
Find and replace unique_ptr::reset(release()) with std::move().
Definition: UniqueptrResetReleaseCheck.h:30
Name
StringHandle Name
Definition: PreprocessorTracker.cpp:525
Finder
std::unique_ptr< ast_matchers::MatchFinder > Finder
Definition: ClangTidy.cpp:188
clang::tidy::misc::UniqueptrResetReleaseCheck::UniqueptrResetReleaseCheck
UniqueptrResetReleaseCheck(StringRef Name, ClangTidyContext *Context)
Definition: UniqueptrResetReleaseCheck.h:32
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition: ClangTidy.h:102
clang::tidy::misc::UniqueptrResetReleaseCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition: UniqueptrResetReleaseCheck.cpp:96
clang::tidy::misc::UniqueptrResetReleaseCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register ASTMatchers with Finder.
Definition: UniqueptrResetReleaseCheck.cpp:20
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