[PATCH] D45699: [Availability] Improve availability to consider functions run at load time

Steven Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Apr 16 15:54:16 PDT 2018


steven_wu added a comment.

Thanks for reviewing Erik!



================
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>()) {
----------------
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.


================
Comment at: lib/Sema/SemaDecl.cpp:9136
+  // that are run during load/unload.
+  for (const auto& attr: NewFD->attrs()) {
+    if (!isa<AvailabilityAttr>(attr))
----------------
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.


Repository:
  rC Clang

https://reviews.llvm.org/D45699





More information about the cfe-commits mailing list