Skip to content

clang-tidy: modernize-use-using fails when type is implicitly forward declared #67529

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

Closed
ThomasHuetsch opened this issue Sep 27, 2023 · 1 comment · Fixed by #67639
Closed
Assignees
Labels
bug Indicates an unexpected problem or unintended behavior clang-tidy

Comments

@ThomasHuetsch
Copy link

clang-tidy check modernize-use-using (LLVM 17.0.1 and before) fails to convert typedef to a type alias when the type is implicitly forward declared. The new type alias (BPtr) is an alias for the class itself and not a pointer to the class.

Before

class A;
typedef A* APtr; // OK
typedef class A* APtr2; // OK

typedef class B* BPtr; // * missing

After

class A;
using APtr = A *; // OK
using APtr2 = class A *; // OK

using BPtr = class B; // * missing

Should be

class A;
using APtr = A *; // OK
using APtr2 = class A *; // OK

using BPtr = class B *; // * missing
@llvmbot
Copy link
Member

llvmbot commented Sep 28, 2023

@llvm/issue-subscribers-bug

clang-tidy check modernize-use-using (LLVM 17.0.1 and before) fails to convert typedef to a type alias when the type is implicitly forward declared. The new type alias (BPtr) is an alias for the class itself and not a pointer to the class.

Before

class A;
typedef A* APtr; // OK
typedef class A* APtr2; // OK

typedef class B* BPtr; // * missing

After

class A;
using APtr = A *; // OK
using APtr2 = class A *; // OK

using BPtr = class B; // * missing

Should be

class A;
using APtr = A *; // OK
using APtr2 = class A *; // OK

using BPtr = class B *; // * missing

@PiotrZSL PiotrZSL assigned PiotrZSL and jcsxky and unassigned PiotrZSL Sep 28, 2023
jcsxky added a commit that referenced this issue Oct 5, 2023
…y when it is a definition (#67639)

Fix issue 67529, [clang-tidy: modernize-use-using fails when type is
implicitly forward
declared](#67529)
The problem is that using `Lexer` to get record declaration will lose
the type information when its original type is pointer or reference.
This patch fix this problem by skip adding the tag declaration when it's
only a 'declaration' and not a 'definition'.

Co-authored-by: huqizhi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior clang-tidy
Projects
None yet
4 participants