[PATCH] D39913: [ObjC] warn about availability attributes missing from a method's declaration when they're specified for a method's definition

Erik Pilkington via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Nov 10 13:15:40 PST 2017


erik.pilkington added a comment.

Any thoughts on having this for regular functions and C++ member functions? Seems just as useful there.



================
Comment at: include/clang/Sema/Sema.h:2406
+  /// This will warn on any missing clauses in the declaration.
+  void checkMissingAvailabilityClausesInDeclaration(NamedDecl *Original, NamedDecl *Implementation);
+
----------------
Looks longer than 80 chars!


================
Comment at: lib/Sema/SemaDeclAttr.cpp:2300
+  };
+
+  llvm::SmallPtrSet<const IdentifierInfo *, 4> MissingPlatformAttributes;
----------------
I hate to rewrite your function, but have you considered just doing the second loop over the attrs inline instead of hidden in the lambda? I think it would make the function more simple to avoid all the lambdas and callbacks:
```
for (auto *A : Implementation->specific_attrs<AvailabilityAttr>()) {
  for (auto *B : Original->specific_attrs<AvailabilityAttr>()) {
    if (A->getPlatform() != B->getPlatform()) continue;
    if (A->getIntroduced() != B->getIntroduced() || ...) {
      Diag();
    }
  }
}
```
You can do the deprecated check outside of the loop like:
```
if (Impl->hasAttr<Dep>() && !Original->hasAttr<Dep>())
```


Repository:
  rL LLVM

https://reviews.llvm.org/D39913





More information about the cfe-commits mailing list