llvm / llvm/llvm-project

[clang-tidy] typeof(expression) being diagnosed as redundant parenthesis around expression

Open
#220,899 1 comment 0 reactions 0 assignees View on GitHub
clang-tidy false-positive
Dominant language
LLVM
Stars
40.5k
Forks
18.7k
PR merge metrics
PR metrics pending

Description

happens when running with `-checks='readability*'`.

e.g.:
```C
typeof(1) var;
```
clang-tidy generates the following for the above code:
```
warning: redundant parentheses around expression [readability-redundant-parentheses]
1 | typeof(1) var;
| ^ ~
|
```
I suspect this is because `typeof` (and `typeof_unqual`) is not being treated as a `UnaryExprOrTypeTrait`

I tried doing [this](https://github.com/aalmkainzi/llvm-project/commit/c86b54aae7459458daa588b522882e4fc21bf2cf), but it didn't work.

Contributor guide

Open the contributing guide

Research direction

Start with the clang-tidy readability-redundant-parentheses check, reproducing the report with -checks='readability*' and the typeof(1) var; example. Trace how the check classifies typeof and typeof_unqual, then verify that the diagnostic no longer appears while ordinary redundant parentheses are still reported.

Written by the indexing model from the issue text.

Assessment

Tech stack
c, cpp
Domain
compilers, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
57/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.