clang-tools 22.0.0git
|
Transforms the deprecated std::auto_ptr into the C++11 std::unique_ptr. More...
#include <ReplaceAutoPtrCheck.h>
Public Member Functions | |
ReplaceAutoPtrCheck (StringRef Name, ClangTidyContext *Context) | |
bool | isLanguageVersionSupported (const LangOptions &LangOpts) const override |
void | storeOptions (ClangTidyOptions::OptionMap &Opts) override |
void | registerMatchers (ast_matchers::MatchFinder *Finder) override |
void | registerPPCallbacks (const SourceManager &SM, Preprocessor *PP, Preprocessor *ModuleExpanderPP) override |
void | check (const ast_matchers::MatchFinder::MatchResult &Result) override |
Transforms the deprecated std::auto_ptr into the C++11 std::unique_ptr.
Note that both the std::auto_ptr type and the transfer of ownership are transformed. std::auto_ptr provides two ways to transfer the ownership, the copy-constructor and the assignment operator. Unlike most classes these operations do not 'copy' the resource but they 'steal' it. std::unique_ptr uses move semantics instead, which makes the intent of transferring the resource explicit. This difference between the two smart pointers requires wrapping the copy-ctor and assign-operator with std::move().
For example, given:
This code is transformed to:
Definition at line 41 of file ReplaceAutoPtrCheck.h.
clang::tidy::modernize::ReplaceAutoPtrCheck::ReplaceAutoPtrCheck | ( | StringRef | Name, |
ClangTidyContext * | Context ) |
Definition at line 38 of file ReplaceAutoPtrCheck.cpp.
|
override |
Definition at line 98 of file ReplaceAutoPtrCheck.cpp.
|
inlineoverride |
Definition at line 44 of file ReplaceAutoPtrCheck.h.
|
override |
Definition at line 49 of file ReplaceAutoPtrCheck.cpp.
|
override |
Definition at line 92 of file ReplaceAutoPtrCheck.cpp.
|
override |
Definition at line 45 of file ReplaceAutoPtrCheck.cpp.