[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang-tools-extra / clang-tidy / readability / RedundantSmartptrGetCheck.h
blob37c09b871d44cc7ad30a4f4de6b1e6ba6796a890
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 //===----------------------------------------------------------------------===//
9 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANTSMARTPTRGETCHECK_H
10 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANTSMARTPTRGETCHECK_H
12 #include "../ClangTidyCheck.h"
14 namespace clang {
15 namespace tidy {
16 namespace readability {
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;
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 llvm::Optional<TraversalKind> getCheckTraversalKind() const override {
39 return TK_IgnoreUnlessSpelledInSource;
42 private:
43 const bool IgnoreMacros;
46 } // namespace readability
47 } // namespace tidy
48 } // namespace clang
50 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_REDUNDANTSMARTPTRGETCHECK_H