[PATCH] D45699: [Availability] Improve availability to consider functions run at load time
Erik Pilkington via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Apr 16 16:18:03 PDT 2018
erik.pilkington accepted this revision.
erik.pilkington added a comment.
This revision is now accepted and ready to land.
LGTM, thanks!
================
Comment at: lib/Sema/SemaDecl.cpp:9134-9151
+ // Diagnose availability attributes. Availability cannot be used on functions
+ // that are run during load/unload.
+ for (const auto& attr: NewFD->attrs()) {
+ if (!isa<AvailabilityAttr>(attr))
+ continue;
+
+ if (NewFD->hasAttr<ConstructorAttr>()) {
----------------
steven_wu wrote:
> erik.pilkington wrote:
> > Shouldn't this be in ProcessDeclAttributeList in SemaDeclAttr.cpp?
> This has to happen after mergeDeclAttributes, otherwise, you won't catch the case which the availability attributes and constructor attributes are on different decl that gets merged. It can't be in mergeDeclAttributes as well, then it won't catch the case they are on a single decl.
Ah, okay. Makes sense.
================
Comment at: lib/Sema/SemaDecl.cpp:9136
+ // that are run during load/unload.
+ for (const auto& attr: NewFD->attrs()) {
+ if (!isa<AvailabilityAttr>(attr))
----------------
steven_wu wrote:
> erik.pilkington wrote:
> > Can't this just be: `if (NewFD->hasAttr<AvailabilityAttr>())`?
> The location of the diagnostics need to be on attributes and that is why it is a for loop.
Maybe `if (auto *AA = NewFD->getAttr<AvailabilityAttr>())` then?
Repository:
rC Clang
https://reviews.llvm.org/D45699
More information about the cfe-commits
mailing list