Skip to content

Fix #5: test for implicit conversions - #7

Open
leftibot wants to merge 1 commit into
cpp-best-practices:mainfrom
leftibot:fix/issue-5-test-for-implicit-conversions
Open

leftibot wants to merge 1 commit into
cpp-best-practices:mainfrom
leftibot:fix/issue-5-test-for-implicit-conversions

Conversation

@leftibot

@leftibot leftibot commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Automated fix by @leftibot.

What changed

Fix #5: Port the no-implicit-conversions check as a clang-query check
The misc-no-implicit-conversions clang-tidy check from lefticus/llvm-project
only existed as a C++ clang-tidy module. Its AST matchers are ported here to a
clang-query check with pass/fail cases derived from its upstream test. The
slicing matcher is narrowed to base copy/move constructors so derived-to-base
pointer arguments to explicit constructors are no longer reported.
Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com

Files

 .../no-implicit-conversions.query                  | 34 ++++++++++++++++++++++
 .../tests/fail/arithmetic_conversions_in_calls.cpp | 11 +++++++
 .../tests/fail/conversion_operator.cpp             | 17 +++++++++++
 .../tests/fail/converting_constructor_template.cpp | 22 ++++++++++++++
 .../tests/fail/explicit_bool_in_condition.cpp      | 20 +++++++++++++
 .../tests/fail/non_trivial_object_from_pointer.cpp | 14 +++++++++
 .../no-implicit-conversions/tests/fail/slicing.cpp | 17 +++++++++++
 .../tests/fail/zero_to_pointer.cpp                 |  7 +++++
 .../tests/pass/binding_derived_to_base.cpp         | 17 +++++++++++
 .../derived_pointer_to_explicit_constructor.cpp    | 13 +++++++++
 .../tests/pass/exact_types.cpp                     | 23 +++++++++++++++
 .../tests/pass/explicit_conversions.cpp            | 14 +++++++++
 .../tests/pass/literals_and_switch.cpp             | 14 +++++++++
 13 files changed, 223 insertions(+)

Closes #5

Triggered by @lefticus.

… clang-query check

The misc-no-implicit-conversions clang-tidy check from lefticus/llvm-project
only existed as a C++ clang-tidy module. Its AST matchers are ported here to a
clang-query check with pass/fail cases derived from its upstream test. The
slicing matcher is narrowed to base copy/move constructors so derived-to-base
pointer arguments to explicit constructors are no longer reported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test for implicit conversions

1 participant