This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Add bugprone-std-forward-type-mismatch check
Needs ReviewPublic

Authored by PiotrZSL on Jul 11 2023, 11:54 AM.

Details

Reviewers
njames93
Summary

Detects instances where std::forward is called with a different type as an
argument compared to the type specified as the template parameter.

Extracted from D144347.

Diff Detail

Event Timeline

PiotrZSL created this revision.Jul 11 2023, 11:54 AM
Herald added a project: Restricted Project. · View Herald Transcript
PiotrZSL requested review of this revision.Jul 11 2023, 11:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 11 2023, 11:54 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
Eugene.Zelenko added inline comments.
clang-tools-extra/docs/clang-tidy/checks/bugprone/std-forward-type-mismatch.rst
28

Excessive newline.

ccotter added a subscriber: ccotter.Aug 3 2023, 3:29 PM
ccotter added inline comments.
clang-tools-extra/docs/clang-tidy/checks/bugprone/std-forward-type-mismatch.rst
18

How confident are we to suggest a fixit to use static_cast? Although equivalent, the code could be incorrect to begin with and merit manual review to decide what the correct cast really should be.

clang-tools-extra/test/clang-tidy/checkers/bugprone/std-forward-type-mismatch.cpp
116

Does this check work if testPartialTemplateBad is not instantiated?