Page MenuHomePhabricator

[clang-tidy] Approximate implicit conversion issues in 'experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type'
Needs ReviewPublic

Authored by whisperity on Feb 24 2020, 4:55 AM.

Details

Reviewers
aaron.ballman
Summary

This patch adds modelling of implicit conversions to the experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type check. This will allow also diagnosing functions such as void f(int i, double d); to have a mix-up chance, i.e. f(some_double, some_int). User-defined conversions are also supported.

Unfortunately, there isn't a sensible way (at least I found none) to ask Sema at "frontend time" whether or not the two parameters could be implicitly converted between one another, as we do not have the Sema instance anymore. Hence there is extra work done here to model the conversions. I believe the check's code under-approximates and thus, there might be cases of false negatives (such as the more arcane implicit conversions like "function pointer to nothrow" -> "function pointer to maybe throw"), but a good grasp on the usual potential issues (such as void g(std::string, const char *);) is given.

Diff Detail

Event Timeline

whisperity created this revision.Feb 24 2020, 4:55 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 24 2020, 4:55 AM
whisperity planned changes to this revision.Feb 24 2020, 4:55 AM
whisperity added subscribers: vingeldal, zporky.

WIP because there's a lot of debug stuff that should be cleared out from here. This is a crude patch. It works fancy, but the code is crude.

whisperity retitled this revision from [WIP][clang-tidy] Approximate implicit conversion issues for the 'cppcoreguidelines-avoid-adjacent-arguments-of-same-type' check to [clang-tidy] Approximate implicit conversion issues for the 'experimental-cppcoreguidelines-avoid-adjacent-arguments-of-the-same-type' check.
whisperity edited the summary of this revision. (Show Details)
whisperity retitled this revision from [clang-tidy] Approximate implicit conversion issues for the 'experimental-cppcoreguidelines-avoid-adjacent-arguments-of-the-same-type' check to [clang-tidy] Approximate implicit conversion issues in 'experimental-cppcoreguidelines-avoid-adjacent-arguments-of-the-same-type'.
  • Re-organised code, removed debug prints, rebased, the usual tidy-up.
  • Bug fixes on certain crashes like incomplete types, conversion operator templates, etc.
  • Even more bug fixes against crashes, hopefully... sorry I lost the individual commits in a squash I think
whisperity marked 2 inline comments as done.Apr 22 2020, 9:57 AM
whisperity added inline comments.
clang-tools-extra/clang-tidy/experimental/CppcoreguidelinesAvoidAdjacentParametersOfTheSameTypeCheck.cpp
747

'chute, I hate merge conflicts...

clang-tools-extra/docs/clang-tidy/checks/experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type.rst
113–120

This change to check the "left half" of a full graph moved to the main checker patch D69560 and there is no significant (few seconds, on large projects like LLVM) time difference between the modes at all even on large projects... so this fearmongering text should be removed.

whisperity marked 2 inline comments as not done.Apr 22 2020, 9:59 AM
whisperity retitled this revision from [clang-tidy] Approximate implicit conversion issues in 'experimental-cppcoreguidelines-avoid-adjacent-arguments-of-the-same-type' to [clang-tidy] Approximate implicit conversion issues in 'experimental-cppcoreguidelines-avoid-adjacent-parameters-of-the-same-type'.Sep 24 2020, 6:23 AM
whisperity edited the summary of this revision. (Show Details)