Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang-tidy][modernize-use-using]fix function pointer typedef correctly #65558

Merged
merged 3 commits into from
Sep 7, 2023
Merged

[clang-tidy][modernize-use-using]fix function pointer typedef correctly #65558

merged 3 commits into from
Sep 7, 2023

Conversation

HerrCai0907
Copy link
Contributor

@HerrCai0907 HerrCai0907 commented Sep 7, 2023

Fixed #65055
For normal type, typedef is from typedef to the end of original type, but for function pointer it is from typedef to the end.
So it needs to consider alias name length for normal type.

Copy link
Member

@PiotrZSL PiotrZSL left a comment

Choose a reason for hiding this comment

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

LGTM,

This is weird issues because it always happen when two typedefs are one after other.
I would personally thing more that LastReplacementEnd is to big, not too small.
But if tests check this properly, then I'm fine with it.

@HerrCai0907
Copy link
Contributor Author

This is weird issues because it always happen when two typedefs are one after other.

typedef void (*ISSUE_65055_1)(int);
typedef bool (*ISSUE_65055_2)(int);
typedef void VOID;

The typedef matcher will match following position:

TypedefDecl 0x1610ba960 <ID/test.cpp:1:1, col:34> col:16 ISSUE_65055_1 'void (*)(int)'
TypedefDecl 0x1610bab30 <line:2:1, col:34> col:16 ISSUE_65055_2 'bool (*)(int)'
TypedefDecl 0x1610bab98 <line:3:1, col:14> col:14 VOID 'void'

That means typedef normal type is from typedef to the end of original type but for function pointer is from typedef to the end.

@HerrCai0907 HerrCai0907 merged commit 31ded49 into llvm:main Sep 7, 2023
1 of 2 checks passed
@HerrCai0907 HerrCai0907 deleted the 65055-clang-tidy-modernize-use-using-wrongly-modifies-typedef-of-function-pointer branch September 7, 2023 09:06
avillega pushed a commit to avillega/llvm-project that referenced this pull request Sep 11, 2023
…ly (llvm#65558)

Fixed llvm#65055
For normal type, typedef is from typedef to the end of original type,
but for function pointer it is from typedef to the end.
So it needs to consider alias name length for normal type.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

clang-tidy: modernize-use-using wrongly modifies typedef of function pointer
2 participants