[clang] [clang][ExtractAPI] Record availability information only for the target platform (PR #76823)

Daniel Grumberg via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 9 06:41:56 PST 2024


================
@@ -1,50 +1,33 @@
 #include "clang/ExtractAPI/AvailabilityInfo.h"
+#include "clang/AST/ASTContext.h"
 #include "clang/AST/Attr.h"
+#include "clang/Basic/TargetInfo.h"
 #include "llvm/ADT/STLExtras.h"
 
 using namespace clang;
 using namespace extractapi;
 
-AvailabilitySet::AvailabilitySet(const Decl *Decl) {
-  // Collect availability attributes from all redeclrations.
-  for (const auto *RD : Decl->redecls()) {
-    if (const auto *A = RD->getAttr<UnavailableAttr>()) {
-      if (!A->isImplicit()) {
-        this->Availabilities.clear();
-        UnconditionallyUnavailable = true;
-      }
-    }
+AvailabilityInfo::AvailabilityInfo(const Decl *Decl) {
----------------
daniel-grumberg wrote:

I would prefer if this wasn't a constructor but rather a static type method of with signature:
```c++
AvailabilityInfo createFromDecl(const Decl *D);
```
that way you don't have to do line 19-21 in that way.

https://github.com/llvm/llvm-project/pull/76823


More information about the cfe-commits mailing list