r277070 - Revert "[ObjC] Consider availability of context when emitting availability warnings"
Erik Pilkington via cfe-commits
cfe-commits at lists.llvm.org
Thu Jul 28 15:51:11 PDT 2016
Author: epilk
Date: Thu Jul 28 17:51:11 2016
New Revision: 277070
URL: http://llvm.org/viewvc/llvm-project?rev=277070&view=rev
Log:
Revert "[ObjC] Consider availability of context when emitting availability warnings"
Reverting r277058, while I fugure out why it broke internal bots.
This reverts commit e514ffa8b657416c6784bbe6da9f5de19365103d.
Modified:
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaObjC/attr-availability.m
Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=277070&r1=277069&r2=277070&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Thu Jul 28 17:51:11 2016
@@ -17,7 +17,6 @@
#include "clang/AST/AttrIterator.h"
#include "clang/AST/DeclarationName.h"
#include "clang/Basic/Specifiers.h"
-#include "clang/Basic/VersionTuple.h"
#include "llvm/ADT/PointerUnion.h"
#include "llvm/ADT/iterator.h"
#include "llvm/ADT/iterator_range.h"
@@ -604,12 +603,7 @@ public:
/// AR_Available, will be set to a (possibly empty) message
/// describing why the declaration has not been introduced, is
/// deprecated, or is unavailable.
- ///
- /// \param EnclosingVersion The version to compare with. If empty, assume the
- /// deployment target version.
- AvailabilityResult
- getAvailability(std::string *Message = nullptr,
- VersionTuple EnclosingVersion = VersionTuple()) const;
+ AvailabilityResult getAvailability(std::string *Message = nullptr) const;
/// \brief Determine whether this declaration is marked 'deprecated'.
///
Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=277070&r1=277069&r2=277070&view=diff
==============================================================================
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu Jul 28 17:51:11 2016
@@ -9596,12 +9596,7 @@ public:
}
AvailabilityResult getCurContextAvailability() const;
-
- /// \brief Get the verison that this context implies.
- /// For instance, a method in an interface that is annotated with an
- /// availability attribuite effectively has the availability of the interface.
- VersionTuple getVersionForDecl(const Decl *Ctx) const;
-
+
const DeclContext *getCurObjCLexicalContext() const {
const DeclContext *DC = getCurLexicalContext();
// A category implicitly has the attribute of the interface.
Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=277070&r1=277069&r2=277070&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Thu Jul 28 17:51:11 2016
@@ -400,12 +400,11 @@ const Attr *Decl::getDefiningAttr() cons
/// diagnostics.
static AvailabilityResult CheckAvailability(ASTContext &Context,
const AvailabilityAttr *A,
- std::string *Message,
- VersionTuple EnclosingVersion) {
- if (EnclosingVersion.empty())
- EnclosingVersion = Context.getTargetInfo().getPlatformMinVersion();
+ std::string *Message) {
+ VersionTuple TargetMinVersion =
+ Context.getTargetInfo().getPlatformMinVersion();
- if (EnclosingVersion.empty())
+ if (TargetMinVersion.empty())
return AR_Available;
// Check if this is an App Extension "platform", and if so chop off
@@ -450,7 +449,7 @@ static AvailabilityResult CheckAvailabil
// Make sure that this declaration has already been introduced.
if (!A->getIntroduced().empty() &&
- EnclosingVersion < A->getIntroduced()) {
+ TargetMinVersion < A->getIntroduced()) {
if (Message) {
Message->clear();
llvm::raw_string_ostream Out(*Message);
@@ -464,7 +463,7 @@ static AvailabilityResult CheckAvailabil
}
// Make sure that this declaration hasn't been obsoleted.
- if (!A->getObsoleted().empty() && EnclosingVersion >= A->getObsoleted()) {
+ if (!A->getObsoleted().empty() && TargetMinVersion >= A->getObsoleted()) {
if (Message) {
Message->clear();
llvm::raw_string_ostream Out(*Message);
@@ -478,7 +477,7 @@ static AvailabilityResult CheckAvailabil
}
// Make sure that this declaration hasn't been deprecated.
- if (!A->getDeprecated().empty() && EnclosingVersion >= A->getDeprecated()) {
+ if (!A->getDeprecated().empty() && TargetMinVersion >= A->getDeprecated()) {
if (Message) {
Message->clear();
llvm::raw_string_ostream Out(*Message);
@@ -494,10 +493,9 @@ static AvailabilityResult CheckAvailabil
return AR_Available;
}
-AvailabilityResult Decl::getAvailability(std::string *Message,
- VersionTuple EnclosingVersion) const {
+AvailabilityResult Decl::getAvailability(std::string *Message) const {
if (auto *FTD = dyn_cast<FunctionTemplateDecl>(this))
- return FTD->getTemplatedDecl()->getAvailability(Message, EnclosingVersion);
+ return FTD->getTemplatedDecl()->getAvailability(Message);
AvailabilityResult Result = AR_Available;
std::string ResultMessage;
@@ -522,7 +520,7 @@ AvailabilityResult Decl::getAvailability
if (const auto *Availability = dyn_cast<AvailabilityAttr>(A)) {
AvailabilityResult AR = CheckAvailability(getASTContext(), Availability,
- Message, EnclosingVersion);
+ Message);
if (AR == AR_Unavailable)
return AR_Unavailable;
@@ -581,8 +579,8 @@ bool Decl::isWeakImported() const {
return true;
if (const auto *Availability = dyn_cast<AvailabilityAttr>(A)) {
- if (CheckAvailability(getASTContext(), Availability, nullptr,
- VersionTuple()) == AR_NotYetIntroduced)
+ if (CheckAvailability(getASTContext(), Availability,
+ nullptr) == AR_NotYetIntroduced)
return true;
}
}
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=277070&r1=277069&r2=277070&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Jul 28 17:51:11 2016
@@ -6484,26 +6484,3 @@ void Sema::EmitAvailabilityWarning(Avail
DoEmitAvailabilityWarning(*this, AD, Ctx, D, Message, Loc, UnknownObjCClass,
ObjCProperty, ObjCPropertyAccess);
}
-
-VersionTuple Sema::getVersionForDecl(const Decl *D) const {
- assert(D && "Expected a declaration here!");
-
- VersionTuple DeclVersion;
- if (const auto *AA = getAttrForPlatform(getASTContext(), D))
- DeclVersion = AA->getIntroduced();
-
- const ObjCInterfaceDecl *Interface = nullptr;
-
- if (const auto *MD = dyn_cast<ObjCMethodDecl>(D))
- Interface = MD->getClassInterface();
- else if (const auto *ID = dyn_cast<ObjCImplementationDecl>(D))
- Interface = ID->getClassInterface();
-
- if (Interface) {
- if (const auto *AA = getAttrForPlatform(getASTContext(), Interface))
- if (AA->getIntroduced() > DeclVersion)
- DeclVersion = AA->getIntroduced();
- }
-
- return DeclVersion;
-}
Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=277070&r1=277069&r2=277070&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Jul 28 17:51:11 2016
@@ -107,14 +107,9 @@ static AvailabilityResult
DiagnoseAvailabilityOfDecl(Sema &S, NamedDecl *D, SourceLocation Loc,
const ObjCInterfaceDecl *UnknownObjCClass,
bool ObjCPropertyAccess) {
- VersionTuple ContextVersion;
- if (const DeclContext *DC = S.getCurObjCLexicalContext())
- ContextVersion = S.getVersionForDecl(cast<Decl>(DC));
-
- // See if this declaration is unavailable, deprecated, or partial in the
- // current context.
+ // See if this declaration is unavailable or deprecated.
std::string Message;
- AvailabilityResult Result = D->getAvailability(&Message, ContextVersion);
+ AvailabilityResult Result = D->getAvailability(&Message);
// For typedefs, if the typedef declaration appears available look
// to the underlying type to see if it is more restrictive.
@@ -122,7 +117,7 @@ DiagnoseAvailabilityOfDecl(Sema &S, Name
if (Result == AR_Available) {
if (const TagType *TT = TD->getUnderlyingType()->getAs<TagType>()) {
D = TT->getDecl();
- Result = D->getAvailability(&Message, ContextVersion);
+ Result = D->getAvailability(&Message);
continue;
}
}
@@ -133,7 +128,7 @@ DiagnoseAvailabilityOfDecl(Sema &S, Name
if (ObjCInterfaceDecl *IDecl = dyn_cast<ObjCInterfaceDecl>(D)) {
if (IDecl->getDefinition()) {
D = IDecl->getDefinition();
- Result = D->getAvailability(&Message, ContextVersion);
+ Result = D->getAvailability(&Message);
}
}
@@ -141,7 +136,7 @@ DiagnoseAvailabilityOfDecl(Sema &S, Name
if (Result == AR_Available) {
const DeclContext *DC = ECD->getDeclContext();
if (const EnumDecl *TheEnumDecl = dyn_cast<EnumDecl>(DC))
- Result = TheEnumDecl->getAvailability(&Message, ContextVersion);
+ Result = TheEnumDecl->getAvailability(&Message);
}
const ObjCPropertyDecl *ObjCPDecl = nullptr;
@@ -149,8 +144,7 @@ DiagnoseAvailabilityOfDecl(Sema &S, Name
Result == AR_NotYetIntroduced) {
if (const ObjCMethodDecl *MD = dyn_cast<ObjCMethodDecl>(D)) {
if (const ObjCPropertyDecl *PD = MD->findPropertyDecl()) {
- AvailabilityResult PDeclResult =
- PD->getAvailability(nullptr, ContextVersion);
+ AvailabilityResult PDeclResult = PD->getAvailability(nullptr);
if (PDeclResult == Result)
ObjCPDecl = PD;
}
@@ -204,7 +198,7 @@ DiagnoseAvailabilityOfDecl(Sema &S, Name
break;
}
- return Result;
+ return Result;
}
/// \brief Emit a note explaining that this function is deleted.
Modified: cfe/trunk/test/SemaObjC/attr-availability.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/attr-availability.m?rev=277070&r1=277069&r2=277070&view=diff
==============================================================================
--- cfe/trunk/test/SemaObjC/attr-availability.m (original)
+++ cfe/trunk/test/SemaObjC/attr-availability.m Thu Jul 28 17:51:11 2016
@@ -294,34 +294,3 @@ __attribute__((objc_root_class))
[obj method]; // expected-error{{'method' is unavailable}}
}
@end
-
-#if defined(WARN_PARTIAL)
-
-int fn_10_7() __attribute__((availability(macosx, introduced=10.7))); // expected-note{{marked partial here}}
-int fn_10_8() __attribute__((availability(macosx, introduced=10.8))) { // expected-note{{marked partial here}}
- return fn_10_7();
-}
-
-__attribute__((objc_root_class))
- at interface LookupAvailabilityBase
--(void) method1;
- at end
-
- at implementation LookupAvailabilityBase
--(void)method1 { fn_10_7(); } // expected-warning{{partial}} expected-note{{explicitly redeclare}}
- at end
-
-__attribute__((availability(macosx, introduced=10.7)))
- at interface LookupAvailability : LookupAvailabilityBase
-- (void)method2;
-- (void)method3;
-- (void)method4 __attribute__((availability(macosx, introduced=10.8)));
- at end
-
- at implementation LookupAvailability
--(void)method2 { fn_10_7(); }
--(void)method3 { fn_10_8(); } // expected-warning{{partial}} expected-note{{explicitly redeclare}}
--(void)method4 { fn_10_8(); }
- at end
-
-#endif
More information about the cfe-commits
mailing list