clang-tools 6.0.0

ForwardingReferenceOverloadCheck.h
Go to the documentation of this file.
1 //===--- ForwardingReferenceOverloadCheck.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_FORWARDING_REFERENCE_OVERLOAD_H
11 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_FORWARDING_REFERENCE_OVERLOAD_H
12
13 #include "../ClangTidy.h"
14
15 namespace clang {
16 namespace tidy {
17 namespace misc {
18
19 /// The checker looks for constructors that can act as copy or move constructors
20 /// through their forwarding reference parameters. If a non const lvalue
21 /// reference is passed to the constructor, the forwarding reference parameter
22 /// can be a perfect match while the const reference parameter of the copy
23 /// constructor can't. The forwarding reference constructor will be called,
24 /// which can lead to confusion.
25 /// For detailed description of this problem see: Scott Meyers, Effective Modern
26 /// C++ Design, item 26.
27 ///
28 /// For the user-facing documentation see:
29 /// http://clang.llvm.org/extra/clang-tidy/checks/misc-forwarding-reference-overload.html
30 class ForwardingReferenceOverloadCheck : public ClangTidyCheck {
31 public:
32 ForwardingReferenceOverloadCheck(StringRef Name, ClangTidyContext *Context)
33 : ClangTidyCheck(Name, Context) {}
34 void registerMatchers(ast_matchers::MatchFinder *Finder) override;
35 void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
36 };
37
38 } // namespace misc
39 } // namespace tidy
40 } // namespace clang
41
42 #endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_FORWARDING_REFERENCE_OVERLOAD_H
Name
StringHandle Name
Definition: PreprocessorTracker.cpp:525
clang::tidy::ClangTidyCheck
Base class for all clang-tidy checks.
Definition: ClangTidy.h:127
clang::tidy::misc::ForwardingReferenceOverloadCheck
The checker looks for constructors that can act as copy or move constructors through their forwarding...
Definition: ForwardingReferenceOverloadCheck.h:30
clang::tidy::misc::ForwardingReferenceOverloadCheck::registerMatchers
void registerMatchers(ast_matchers::MatchFinder *Finder) override
Override this to register AST matchers with Finder.
Definition: ForwardingReferenceOverloadCheck.cpp:63
clang
Definition: AndroidTidyModule.cpp:28
clang::tidy::misc::ForwardingReferenceOverloadCheck::ForwardingReferenceOverloadCheck
ForwardingReferenceOverloadCheck(StringRef Name, ClangTidyContext *Context)
Definition: ForwardingReferenceOverloadCheck.h:32
clang::tidy::ClangTidyContext
Every ClangTidyCheck reports errors through a DiagnosticsEngine provided by this context.
Definition: ClangTidyDiagnosticConsumer.h:104
clang::tidy::misc::ForwardingReferenceOverloadCheck::check
void check(const ast_matchers::MatchFinder::MatchResult &Result) override
ClangTidyChecks that register ASTMatchers should do the actual work in here.
Definition: ForwardingReferenceOverloadCheck.cpp:89