Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,11 @@ void AvoidCStyleCastCheck::check(const MatchFinder::MatchResult &Result) {
ReplaceWithNamedCast("static_cast");
return;
case CK_NoOp:
if (isa<CXXNullPtrLiteralExpr>(CastExpr->getSubExprAsWritten()->IgnoreImpCasts())) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like a formatting issue? You can run git clang-format HEAD~1 to fix it :)

ReplaceWithNamedCast("static_cast");
return;
}

if (FnToFnCast) {
ReplaceWithNamedCast("static_cast");
return;
Expand Down
4 changes: 4 additions & 0 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,10 @@ Changes in existing checks
on Windows when the check was enabled with a 32-bit :program:`clang-tidy`
binary.

- Improved :doc:`modernize-avoid-c-style-cast
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Clang-Tidy documentations, we want entries in Changes in existing checks to keep alphabetical order, so this new entries should be placed between modernize-avoid-c-arrays and modernize-use-constraints :)

<clang-tidy/checks/modernize/avoid-c-style-cast>` by providing correct fixes
for C-style casts of nullptr.

- Improved :doc:`modernize-use-override
<clang-tidy/checks/modernize/use-override>` by fixing an issue where
the check would sometimes suggest inserting ``override`` in an invalid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,3 +368,12 @@ void functional_casts() {

throw S2(5.0f);
}
void f(int *);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will be good idea to separate with newline.

void f(double *);

void test_nullptr_cast() {
f((int*)nullptr);
}
// CHECK-MESSAGES: warning: C-style casts are discouraged
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please verify the line and column numbers and full message like the remaining part of this file.

// CHECK-FIXES: f(static_cast<int*>(nullptr));

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excessive newline.

Loading