clang-tools 22.0.0git
clang::tidy::bugprone::ForwardingReferenceOverloadCheck Class Reference

The checker looks for constructors that can act as copy or move constructors through their forwarding reference parameters. More...

#include <ForwardingReferenceOverloadCheck.h>

Inheritance diagram for clang::tidy::bugprone::ForwardingReferenceOverloadCheck:
[legend]

Public Member Functions

 ForwardingReferenceOverloadCheck (StringRef Name, ClangTidyContext *Context)
bool isLanguageVersionSupported (const LangOptions &LangOpts) const override
void registerMatchers (ast_matchers::MatchFinder *Finder) override
void check (const ast_matchers::MatchFinder::MatchResult &Result) override

Detailed Description

The checker looks for constructors that can act as copy or move constructors through their forwarding reference parameters.

If a non const lvalue reference is passed to the constructor, the forwarding reference parameter can be a perfect match while the const reference parameter of the copy constructor can't. The forwarding reference constructor will be called, which can lead to confusion. For detailed description of this problem see: Scott Meyers, Effective Modern C++ Design, item 26.

For the user-facing documentation see: https://clang.llvm.org/extra/clang-tidy/checks/bugprone/forwarding-reference-overload.html

Definition at line 27 of file ForwardingReferenceOverloadCheck.h.

Constructor & Destructor Documentation

◆ ForwardingReferenceOverloadCheck()

clang::tidy::bugprone::ForwardingReferenceOverloadCheck::ForwardingReferenceOverloadCheck ( StringRef Name,
ClangTidyContext * Context )
inline

Definition at line 29 of file ForwardingReferenceOverloadCheck.h.

Member Function Documentation

◆ check()

void clang::tidy::bugprone::ForwardingReferenceOverloadCheck::check ( const ast_matchers::MatchFinder::MatchResult & Result)
override

Definition at line 92 of file ForwardingReferenceOverloadCheck.cpp.

References clang::tidy::bugprone::Move.

◆ isLanguageVersionSupported()

bool clang::tidy::bugprone::ForwardingReferenceOverloadCheck::isLanguageVersionSupported ( const LangOptions & LangOpts) const
inlineoverride

Definition at line 31 of file ForwardingReferenceOverloadCheck.h.

◆ registerMatchers()

void clang::tidy::bugprone::ForwardingReferenceOverloadCheck::registerMatchers ( ast_matchers::MatchFinder * Finder)
override

Definition at line 61 of file ForwardingReferenceOverloadCheck.cpp.


The documentation for this class was generated from the following files: