llvm / llvm/llvm-project

[clang-tidy] add option to allow functional casting to `modernize-avoid-c-style-cast`

Open
#186,784 7 comments 0 reactions 0 assignees View on GitHub
clang-tidy enhancement
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

```cpp
static char s_c = char(1);
```

```
:1:19: warning: C-style casts are discouraged; use static_cast [modernize-avoid-c-style-cast]
1 | static char s_c = char(1);
| ^~~~
| static_cast
```

https://godbolt.org/z/G47TxjWfq

The message is also misleading as this is clearly not a "C-style cast".

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the warning from the issue's functional-cast example, using the linked Compiler Explorer case if useful. Then locate the clang-tidy implementation and tests for modernize-avoid-c-style-cast; done means an option permits functional casts and the diagnostic no longer misleadingly calls them C-style casts.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
tooling
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.