This is an archive of the discontinued LLVM Phabricator instance.

[Sema] print more readable identifier of anonymous struct of -Wconsumed
AbandonedPublic

Authored by inclyc on Sep 28 2022, 10:08 AM.

Details

Reviewers
aaron.ballman
Summary

Working in D133574 we discovered -Wconsumed print '' with anonymous
class/struct. After this patch we give a line number, file name of
anonymous struct/class declaration.

Example:

struct S {
  struct {
    __attribute__((callable_when(consumed))) void func();
  } s;
};
local/anoy-consume.cpp:3:20: warning: consumed analysis attribute is attached to member of class 'S::(unnamed struct at local/anoy-consume.cpp:2:3)' which isn't marked as consumable [-Wconsumed]
    __attribute__((callable_when(consumed))) void func();
                   ^
1 warning generated.

Link: https://reviews.llvm.org/D133574#3817743
Link: https://godbolt.org/z/16vP3voTW

Diff Detail

Event Timeline

inclyc created this revision.Sep 28 2022, 10:08 AM
Herald added a project: Restricted Project. · View Herald Transcript
inclyc published this revision for review.Sep 28 2022, 10:09 AM
Herald added a project: Restricted Project. · View Herald TranscriptSep 28 2022, 10:09 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

FWIW, I approached this in a slightly different way here: https://reviews.llvm.org/D134813 -- I've not landed it yet because I'm still hoping I can find a way to not modify lit just to fix one fragile test, but I think we ultimately want to go this other route because that fixes all of the places we pass in a TagDecl instead of playing whack-a-mole as we find new bad diagnostic behavior.

inclyc abandoned this revision.Sep 28 2022, 10:15 AM