This is an archive of the discontinued LLVM Phabricator instance.

[clang] Properly print unnamed members in diagnostics
ClosedPublic

Authored by Fznamznon on Aug 22 2023, 9:43 AM.

Details

Summary

Use member's type when printing.
This also fixes a bug in warning diagnostic for out of order
initialization with designated initializers so it points to a valid
source location when an anonymous member is being initialized.

Fixes https://github.com/llvm/llvm-project/issues/63759

Diff Detail

Event Timeline

Fznamznon created this revision.Aug 22 2023, 9:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 22 2023, 9:43 AM
Fznamznon requested review of this revision.Aug 22 2023, 9:43 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 22 2023, 9:43 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

Thank you for this fix, it is a lot cleaner than I was expecting.

clang/include/clang/AST/Decl.h
3186

So it looks like w/o this we would end up using NamedDecl::printName(...) is that right?

clang/test/AST/ast-dump-APValue-anon-union.cpp
43

I am curious what the rest of the diagnostic message from anonymous union at... says.

Fznamznon added inline comments.Aug 23 2023, 1:05 AM
clang/include/clang/AST/Decl.h
3186

Right.

clang/test/AST/ast-dump-APValue-anon-union.cpp
43

It points to the source location of anonymous member definition, I'm seeing "/absolute/path/to/file/ast-dump-APValue-anon-union.cpp::20:3"

shafik accepted this revision.Aug 23 2023, 10:11 AM

LGTM

This revision is now accepted and ready to land.Aug 23 2023, 10:11 AM
aaron.ballman accepted this revision.Aug 24 2023, 5:57 AM

LGTM aside from a small nit

clang/lib/AST/Decl.cpp
4567–4569

This way we're not reimplementing the same logic that NamedDecl does (in case we update that logic at some point in the future).

This revision was landed with ongoing or failed builds.Aug 24 2023, 7:38 AM
This revision was automatically updated to reflect the committed changes.