File tree Expand file tree Collapse file tree 4 files changed +27
-3
lines changed Expand file tree Collapse file tree 4 files changed +27
-3
lines changed Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ void MissingStdForwardCheck::registerMatchers(MatchFinder *Finder) {
120120 equalsBoundNode (" param" ), equalsBoundNode (" var" )))))),
121121 CapturedInLambda)),
122122 callee (unresolvedLookupExpr (hasAnyDeclaration (
123- namedDecl (hasUnderlyingDecl (hasName (" ::std::forward " )))))),
123+ namedDecl (hasUnderlyingDecl (hasName (ForwardFunction )))))),
124124
125125 unless (anyOf (hasAncestor (typeLoc ()),
126126 hasAncestor (expr (hasUnevaluatedContext ())))));
@@ -149,4 +149,13 @@ void MissingStdForwardCheck::check(const MatchFinder::MatchResult &Result) {
149149 << Param;
150150}
151151
152+ MissingStdForwardCheck::MissingStdForwardCheck (StringRef Name,
153+ ClangTidyContext *Context)
154+ : ClangTidyCheck(Name, Context),
155+ ForwardFunction (Options.get(" ForwardFunction" , " ::std::forward" )) {}
156+
157+ void MissingStdForwardCheck::storeOptions (ClangTidyOptions::OptionMap &Opts) {
158+ Options.store (Opts, " ForwardFunction" , ForwardFunction);
159+ }
160+
152161} // namespace clang::tidy::cppcoreguidelines
Original file line number Diff line number Diff line change @@ -21,8 +21,7 @@ namespace clang::tidy::cppcoreguidelines {
2121// / http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines/missing-std-forward.html
2222class MissingStdForwardCheck : public ClangTidyCheck {
2323public:
24- MissingStdForwardCheck (StringRef Name, ClangTidyContext *Context)
25- : ClangTidyCheck(Name, Context) {}
24+ MissingStdForwardCheck (StringRef Name, ClangTidyContext *Context);
2625 void registerMatchers (ast_matchers::MatchFinder *Finder) override ;
2726 void check (const ast_matchers::MatchFinder::MatchResult &Result) override ;
2827 bool isLanguageVersionSupported (const LangOptions &LangOpts) const override {
@@ -31,6 +30,10 @@ class MissingStdForwardCheck : public ClangTidyCheck {
3130 std::optional<TraversalKind> getCheckTraversalKind () const override {
3231 return TK_IgnoreUnlessSpelledInSource;
3332 }
33+ void storeOptions (ClangTidyOptions::OptionMap &Opts) override ;
34+
35+ private:
36+ const StringRef ForwardFunction;
3437};
3538
3639} // namespace clang::tidy::cppcoreguidelines
Original file line number Diff line number Diff line change @@ -327,6 +327,10 @@ Changes in existing checks
327327 <clang-tidy/checks/readability/redundant-smartptr-get>` check by fixing
328328 some false positives involving smart pointers to arrays.
329329
330+ - Improved :doc: `cppcoreguidelines-missing-std-forward
331+ <clang-tidy/checks/cppcoreguidelines/missing-std-forward>` check by adding a
332+ flag to specify the function used for forwarding instead of ``std::forward ``.
333+
330334Removed checks
331335^^^^^^^^^^^^^^
332336
Original file line number Diff line number Diff line change @@ -35,6 +35,14 @@ Example:
3535 f(1, 2); // Incorrect - may not invoke the desired qualified function operator
3636 }
3737
38+ Options
39+ -------
40+
41+ .. option :: ForwardFunction
42+
43+ Specify the function used for forwarding.
44+ Default is `::std::forward `.
45+
3846This check implements `F.19
3947<http://isocpp.github.io/CppCoreGuidelines/CppCoreGuidelines#Rf-forward> `_
4048from the C++ Core Guidelines.
You can’t perform that action at this time.
0 commit comments