clang-tools 3.8.0

- Main Page
- Namespaces
- Classes
- Files

- File List
- File Members

UnnecessaryCopyInitialization.h
Go to the documentation of this file.
1 //===--- UnnecessaryCopyInitialization.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_PERFORMANCE_UNNECESSARY_COPY_INITIALIZATION_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_UNNECESSARY_COPY_INITIALIZATION_H
12
13 #include "../ClangTidy.h"
14
15 namespace clang {
16 namespace tidy {
17 namespace performance {
18
19 // A check that detects const local variable declarations that are copy
20 // initialized with the const reference of a function call or the const
21 // reference of a method call whose object is guaranteed to outlive the
22 // variable's scope and suggests to use a const reference.
23 //
24 // The check currently only understands a subset of variables that are
25 // guaranteed to outlive the const reference returned, namely: const variables,
26 // const references, and const pointers to const.
27 class UnnecessaryCopyInitialization : public ClangTidyCheck {
28 public:
29 UnnecessaryCopyInitialization(StringRef Name, ClangTidyContext *Context)
30 : ClangTidyCheck(Name, Context) {}
31 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
32 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
33 };
34
35 } // namespace performance
36 } // namespace tidy
37 } // namespace clang
38
39 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_PERFORMANCE_UNNECESSARY_COPY_INITIALIZATION_H
clang::tidy::performance::UnnecessaryCopyInitialization
Definition: UnnecessaryCopyInitialization.h:27
Name
StringHandle Name
Definition: PreprocessorTracker.cpp:525
clang::tidy::performance::UnnecessaryCopyInitialization::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register ASTMatchers with Finder.
Definition: UnnecessaryCopyInitialization.cpp:25
Finder
std::unique_ptr< ast_matchers::MatchFinder > Finder
Definition: ClangTidy.cpp:188
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition: ClangTidy.h:102
clang::tidy::performance::UnnecessaryCopyInitialization::UnnecessaryCopyInitialization
UnnecessaryCopyInitialization(StringRef Name, ClangTidyContext *Context)
Definition: UnnecessaryCopyInitialization.h:29
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:124
clang::tidy::performance::UnnecessaryCopyInitialization::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition: UnnecessaryCopyInitialization.cpp:55
Result
const NamedDecl * Result
Definition: USRFinder.cpp:121