diff options
Diffstat (limited to 'contrib/llvm-project/clang/lib/Sema/SemaAvailability.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/Sema/SemaAvailability.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/contrib/llvm-project/clang/lib/Sema/SemaAvailability.cpp b/contrib/llvm-project/clang/lib/Sema/SemaAvailability.cpp index 05ad42780e50..84c06566387c 100644 --- a/contrib/llvm-project/clang/lib/Sema/SemaAvailability.cpp +++ b/contrib/llvm-project/clang/lib/Sema/SemaAvailability.cpp @@ -123,6 +123,18 @@ ShouldDiagnoseAvailabilityInContext(Sema &S, AvailabilityResult K, const NamedDecl *OffendingDecl) { assert(K != AR_Available && "Expected an unavailable declaration here!"); + // If this was defined using CF_OPTIONS, etc. then ignore the diagnostic. + auto DeclLoc = Ctx->getBeginLoc(); + // This is only a problem in Foundation's C++ implementation for CF_OPTIONS. + if (DeclLoc.isMacroID() && S.getLangOpts().CPlusPlus && + isa<TypedefDecl>(OffendingDecl)) { + StringRef MacroName = S.getPreprocessor().getImmediateMacroName(DeclLoc); + if (MacroName == "CF_OPTIONS" || MacroName == "OBJC_OPTIONS" || + MacroName == "SWIFT_OPTIONS" || MacroName == "NS_OPTIONS") { + return false; + } + } + // Checks if we should emit the availability diagnostic in the context of C. auto CheckContext = [&](const Decl *C) { if (K == AR_NotYetIntroduced) { |