[NFC] Refactoring PropertyAttributeKind for ObjCPropertyDecl and ObjCDeclSpec.
This is a code clean up of the PropertyAttributeKind and ObjCPropertyAttributeKind enums in ObjCPropertyDecl and ObjCDeclSpec that are exactly identical. This non-functional change consolidates these enums into one. The changes are to many files across clang (and comments in LLVM) so that everything refers to the new consolidated enum in DeclObjCCommon.h. Differential Revision: https://reviews.llvm.org/D77233
This commit is contained in:
parent
7b5497f258
commit
2aa044ed08
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include "clang/AST/Decl.h"
|
#include "clang/AST/Decl.h"
|
||||||
#include "clang/AST/DeclBase.h"
|
#include "clang/AST/DeclBase.h"
|
||||||
|
#include "clang/AST/DeclObjCCommon.h"
|
||||||
#include "clang/AST/ExternalASTSource.h"
|
#include "clang/AST/ExternalASTSource.h"
|
||||||
#include "clang/AST/Redeclarable.h"
|
#include "clang/AST/Redeclarable.h"
|
||||||
#include "clang/AST/SelectorLocationsKind.h"
|
#include "clang/AST/SelectorLocationsKind.h"
|
||||||
|
@ -742,34 +743,6 @@ class ObjCPropertyDecl : public NamedDecl {
|
||||||
void anchor() override;
|
void anchor() override;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
enum PropertyAttributeKind {
|
|
||||||
OBJC_PR_noattr = 0x00,
|
|
||||||
OBJC_PR_readonly = 0x01,
|
|
||||||
OBJC_PR_getter = 0x02,
|
|
||||||
OBJC_PR_assign = 0x04,
|
|
||||||
OBJC_PR_readwrite = 0x08,
|
|
||||||
OBJC_PR_retain = 0x10,
|
|
||||||
OBJC_PR_copy = 0x20,
|
|
||||||
OBJC_PR_nonatomic = 0x40,
|
|
||||||
OBJC_PR_setter = 0x80,
|
|
||||||
OBJC_PR_atomic = 0x100,
|
|
||||||
OBJC_PR_weak = 0x200,
|
|
||||||
OBJC_PR_strong = 0x400,
|
|
||||||
OBJC_PR_unsafe_unretained = 0x800,
|
|
||||||
/// Indicates that the nullability of the type was spelled with a
|
|
||||||
/// property attribute rather than a type qualifier.
|
|
||||||
OBJC_PR_nullability = 0x1000,
|
|
||||||
OBJC_PR_null_resettable = 0x2000,
|
|
||||||
OBJC_PR_class = 0x4000,
|
|
||||||
OBJC_PR_direct = 0x8000
|
|
||||||
// Adding a property should change NumPropertyAttrsBits
|
|
||||||
};
|
|
||||||
|
|
||||||
enum {
|
|
||||||
/// Number of bits fitting all the property attributes.
|
|
||||||
NumPropertyAttrsBits = 16
|
|
||||||
};
|
|
||||||
|
|
||||||
enum SetterKind { Assign, Retain, Copy, Weak };
|
enum SetterKind { Assign, Retain, Copy, Weak };
|
||||||
enum PropertyControl { None, Required, Optional };
|
enum PropertyControl { None, Required, Optional };
|
||||||
|
|
||||||
|
@ -782,8 +755,8 @@ private:
|
||||||
|
|
||||||
QualType DeclType;
|
QualType DeclType;
|
||||||
TypeSourceInfo *DeclTypeSourceInfo;
|
TypeSourceInfo *DeclTypeSourceInfo;
|
||||||
unsigned PropertyAttributes : NumPropertyAttrsBits;
|
unsigned PropertyAttributes : NumObjCPropertyAttrsBits;
|
||||||
unsigned PropertyAttributesAsWritten : NumPropertyAttrsBits;
|
unsigned PropertyAttributesAsWritten : NumObjCPropertyAttrsBits;
|
||||||
|
|
||||||
// \@required/\@optional
|
// \@required/\@optional
|
||||||
unsigned PropertyImplementation : 2;
|
unsigned PropertyImplementation : 2;
|
||||||
|
@ -810,15 +783,14 @@ private:
|
||||||
ObjCIvarDecl *PropertyIvarDecl = nullptr;
|
ObjCIvarDecl *PropertyIvarDecl = nullptr;
|
||||||
|
|
||||||
ObjCPropertyDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
|
ObjCPropertyDecl(DeclContext *DC, SourceLocation L, IdentifierInfo *Id,
|
||||||
SourceLocation AtLocation, SourceLocation LParenLocation,
|
SourceLocation AtLocation, SourceLocation LParenLocation,
|
||||||
QualType T, TypeSourceInfo *TSI,
|
QualType T, TypeSourceInfo *TSI, PropertyControl propControl)
|
||||||
PropertyControl propControl)
|
: NamedDecl(ObjCProperty, DC, L, Id), AtLoc(AtLocation),
|
||||||
: NamedDecl(ObjCProperty, DC, L, Id), AtLoc(AtLocation),
|
LParenLoc(LParenLocation), DeclType(T), DeclTypeSourceInfo(TSI),
|
||||||
LParenLoc(LParenLocation), DeclType(T), DeclTypeSourceInfo(TSI),
|
PropertyAttributes(ObjCPropertyAttribute::kind_noattr),
|
||||||
PropertyAttributes(OBJC_PR_noattr),
|
PropertyAttributesAsWritten(ObjCPropertyAttribute::kind_noattr),
|
||||||
PropertyAttributesAsWritten(OBJC_PR_noattr),
|
PropertyImplementation(propControl), GetterName(Selector()),
|
||||||
PropertyImplementation(propControl), GetterName(Selector()),
|
SetterName(Selector()) {}
|
||||||
SetterName(Selector()) {}
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static ObjCPropertyDecl *Create(ASTContext &C, DeclContext *DC,
|
static ObjCPropertyDecl *Create(ASTContext &C, DeclContext *DC,
|
||||||
|
@ -850,11 +822,11 @@ public:
|
||||||
/// type.
|
/// type.
|
||||||
QualType getUsageType(QualType objectType) const;
|
QualType getUsageType(QualType objectType) const;
|
||||||
|
|
||||||
PropertyAttributeKind getPropertyAttributes() const {
|
ObjCPropertyAttribute::Kind getPropertyAttributes() const {
|
||||||
return PropertyAttributeKind(PropertyAttributes);
|
return ObjCPropertyAttribute::Kind(PropertyAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPropertyAttributes(PropertyAttributeKind PRVal) {
|
void setPropertyAttributes(ObjCPropertyAttribute::Kind PRVal) {
|
||||||
PropertyAttributes |= PRVal;
|
PropertyAttributes |= PRVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -862,11 +834,11 @@ public:
|
||||||
PropertyAttributes = PRVal;
|
PropertyAttributes = PRVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
PropertyAttributeKind getPropertyAttributesAsWritten() const {
|
ObjCPropertyAttribute::Kind getPropertyAttributesAsWritten() const {
|
||||||
return PropertyAttributeKind(PropertyAttributesAsWritten);
|
return ObjCPropertyAttribute::Kind(PropertyAttributesAsWritten);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setPropertyAttributesAsWritten(PropertyAttributeKind PRVal) {
|
void setPropertyAttributesAsWritten(ObjCPropertyAttribute::Kind PRVal) {
|
||||||
PropertyAttributesAsWritten = PRVal;
|
PropertyAttributesAsWritten = PRVal;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -874,23 +846,28 @@ public:
|
||||||
|
|
||||||
/// isReadOnly - Return true iff the property has a setter.
|
/// isReadOnly - Return true iff the property has a setter.
|
||||||
bool isReadOnly() const {
|
bool isReadOnly() const {
|
||||||
return (PropertyAttributes & OBJC_PR_readonly);
|
return (PropertyAttributes & ObjCPropertyAttribute::kind_readonly);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// isAtomic - Return true if the property is atomic.
|
/// isAtomic - Return true if the property is atomic.
|
||||||
bool isAtomic() const {
|
bool isAtomic() const {
|
||||||
return (PropertyAttributes & OBJC_PR_atomic);
|
return (PropertyAttributes & ObjCPropertyAttribute::kind_atomic);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// isRetaining - Return true if the property retains its value.
|
/// isRetaining - Return true if the property retains its value.
|
||||||
bool isRetaining() const {
|
bool isRetaining() const {
|
||||||
return (PropertyAttributes &
|
return (PropertyAttributes & (ObjCPropertyAttribute::kind_retain |
|
||||||
(OBJC_PR_retain | OBJC_PR_strong | OBJC_PR_copy));
|
ObjCPropertyAttribute::kind_strong |
|
||||||
|
ObjCPropertyAttribute::kind_copy));
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isInstanceProperty() const { return !isClassProperty(); }
|
bool isInstanceProperty() const { return !isClassProperty(); }
|
||||||
bool isClassProperty() const { return PropertyAttributes & OBJC_PR_class; }
|
bool isClassProperty() const {
|
||||||
bool isDirectProperty() const { return PropertyAttributes & OBJC_PR_direct; }
|
return PropertyAttributes & ObjCPropertyAttribute::kind_class;
|
||||||
|
}
|
||||||
|
bool isDirectProperty() const {
|
||||||
|
return PropertyAttributes & ObjCPropertyAttribute::kind_direct;
|
||||||
|
}
|
||||||
|
|
||||||
ObjCPropertyQueryKind getQueryKind() const {
|
ObjCPropertyQueryKind getQueryKind() const {
|
||||||
return isClassProperty() ? ObjCPropertyQueryKind::OBJC_PR_query_class :
|
return isClassProperty() ? ObjCPropertyQueryKind::OBJC_PR_query_class :
|
||||||
|
@ -906,13 +883,13 @@ public:
|
||||||
/// the property setter. This is only valid if the property has been
|
/// the property setter. This is only valid if the property has been
|
||||||
/// defined to have a setter.
|
/// defined to have a setter.
|
||||||
SetterKind getSetterKind() const {
|
SetterKind getSetterKind() const {
|
||||||
if (PropertyAttributes & OBJC_PR_strong)
|
if (PropertyAttributes & ObjCPropertyAttribute::kind_strong)
|
||||||
return getType()->isBlockPointerType() ? Copy : Retain;
|
return getType()->isBlockPointerType() ? Copy : Retain;
|
||||||
if (PropertyAttributes & OBJC_PR_retain)
|
if (PropertyAttributes & ObjCPropertyAttribute::kind_retain)
|
||||||
return Retain;
|
return Retain;
|
||||||
if (PropertyAttributes & OBJC_PR_copy)
|
if (PropertyAttributes & ObjCPropertyAttribute::kind_copy)
|
||||||
return Copy;
|
return Copy;
|
||||||
if (PropertyAttributes & OBJC_PR_weak)
|
if (PropertyAttributes & ObjCPropertyAttribute::kind_weak)
|
||||||
return Weak;
|
return Weak;
|
||||||
return Assign;
|
return Assign;
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
//===- DeclObjCCommon.h - Classes for representing declarations -*- C++ -*-===//
|
||||||
|
//
|
||||||
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
||||||
|
// See https://llvm.org/LICENSE.txt for license information.
|
||||||
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
//
|
||||||
|
// This file contains common ObjC enums and classes used in AST and
|
||||||
|
// Sema.
|
||||||
|
//
|
||||||
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
|
#ifndef LLVM_CLANG_AST_DECLOBJC_COMMON_H
|
||||||
|
#define LLVM_CLANG_AST_DECLOBJC_COMMON_H
|
||||||
|
|
||||||
|
namespace clang {
|
||||||
|
|
||||||
|
/// ObjCPropertyAttribute::Kind - list of property attributes.
|
||||||
|
/// Keep this list in sync with LLVM's Dwarf.h ApplePropertyAttributes.s
|
||||||
|
namespace ObjCPropertyAttribute {
|
||||||
|
enum Kind {
|
||||||
|
kind_noattr = 0x00,
|
||||||
|
kind_readonly = 0x01,
|
||||||
|
kind_getter = 0x02,
|
||||||
|
kind_assign = 0x04,
|
||||||
|
kind_readwrite = 0x08,
|
||||||
|
kind_retain = 0x10,
|
||||||
|
kind_copy = 0x20,
|
||||||
|
kind_nonatomic = 0x40,
|
||||||
|
kind_setter = 0x80,
|
||||||
|
kind_atomic = 0x100,
|
||||||
|
kind_weak = 0x200,
|
||||||
|
kind_strong = 0x400,
|
||||||
|
kind_unsafe_unretained = 0x800,
|
||||||
|
/// Indicates that the nullability of the type was spelled with a
|
||||||
|
/// property attribute rather than a type qualifier.
|
||||||
|
kind_nullability = 0x1000,
|
||||||
|
kind_null_resettable = 0x2000,
|
||||||
|
kind_class = 0x4000,
|
||||||
|
kind_direct = 0x8000,
|
||||||
|
// Adding a property should change NumObjCPropertyAttrsBits
|
||||||
|
// Also, don't forget to update the Clang C API at CXObjCPropertyAttrKind and
|
||||||
|
// clang_Cursor_getObjCPropertyAttributes.
|
||||||
|
};
|
||||||
|
} // namespace ObjCPropertyAttribute::Kind
|
||||||
|
|
||||||
|
enum {
|
||||||
|
/// Number of bits fitting all the property attributes.
|
||||||
|
NumObjCPropertyAttrsBits = 16
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace clang
|
||||||
|
|
||||||
|
#endif // LLVM_CLANG_AST_DECLOBJC_COMMON_H
|
|
@ -23,6 +23,7 @@
|
||||||
#define LLVM_CLANG_SEMA_DECLSPEC_H
|
#define LLVM_CLANG_SEMA_DECLSPEC_H
|
||||||
|
|
||||||
#include "clang/AST/DeclCXX.h"
|
#include "clang/AST/DeclCXX.h"
|
||||||
|
#include "clang/AST/DeclObjCCommon.h"
|
||||||
#include "clang/AST/NestedNameSpecifier.h"
|
#include "clang/AST/NestedNameSpecifier.h"
|
||||||
#include "clang/Basic/ExceptionSpecificationType.h"
|
#include "clang/Basic/ExceptionSpecificationType.h"
|
||||||
#include "clang/Basic/Lambda.h"
|
#include "clang/Basic/Lambda.h"
|
||||||
|
@ -841,31 +842,10 @@ public:
|
||||||
DQ_CSNullability = 0x40
|
DQ_CSNullability = 0x40
|
||||||
};
|
};
|
||||||
|
|
||||||
/// PropertyAttributeKind - list of property attributes.
|
|
||||||
/// Keep this list in sync with LLVM's Dwarf.h ApplePropertyAttributes.
|
|
||||||
enum ObjCPropertyAttributeKind {
|
|
||||||
DQ_PR_noattr = 0x0,
|
|
||||||
DQ_PR_readonly = 0x01,
|
|
||||||
DQ_PR_getter = 0x02,
|
|
||||||
DQ_PR_assign = 0x04,
|
|
||||||
DQ_PR_readwrite = 0x08,
|
|
||||||
DQ_PR_retain = 0x10,
|
|
||||||
DQ_PR_copy = 0x20,
|
|
||||||
DQ_PR_nonatomic = 0x40,
|
|
||||||
DQ_PR_setter = 0x80,
|
|
||||||
DQ_PR_atomic = 0x100,
|
|
||||||
DQ_PR_weak = 0x200,
|
|
||||||
DQ_PR_strong = 0x400,
|
|
||||||
DQ_PR_unsafe_unretained = 0x800,
|
|
||||||
DQ_PR_nullability = 0x1000,
|
|
||||||
DQ_PR_null_resettable = 0x2000,
|
|
||||||
DQ_PR_class = 0x4000,
|
|
||||||
DQ_PR_direct = 0x8000,
|
|
||||||
};
|
|
||||||
|
|
||||||
ObjCDeclSpec()
|
ObjCDeclSpec()
|
||||||
: objcDeclQualifier(DQ_None), PropertyAttributes(DQ_PR_noattr),
|
: objcDeclQualifier(DQ_None),
|
||||||
Nullability(0), GetterName(nullptr), SetterName(nullptr) { }
|
PropertyAttributes(ObjCPropertyAttribute::kind_noattr), Nullability(0),
|
||||||
|
GetterName(nullptr), SetterName(nullptr) {}
|
||||||
|
|
||||||
ObjCDeclQualifier getObjCDeclQualifier() const {
|
ObjCDeclQualifier getObjCDeclQualifier() const {
|
||||||
return (ObjCDeclQualifier)objcDeclQualifier;
|
return (ObjCDeclQualifier)objcDeclQualifier;
|
||||||
|
@ -877,32 +857,35 @@ public:
|
||||||
objcDeclQualifier = (ObjCDeclQualifier) (objcDeclQualifier & ~DQVal);
|
objcDeclQualifier = (ObjCDeclQualifier) (objcDeclQualifier & ~DQVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjCPropertyAttributeKind getPropertyAttributes() const {
|
ObjCPropertyAttribute::Kind getPropertyAttributes() const {
|
||||||
return ObjCPropertyAttributeKind(PropertyAttributes);
|
return ObjCPropertyAttribute::Kind(PropertyAttributes);
|
||||||
}
|
}
|
||||||
void setPropertyAttributes(ObjCPropertyAttributeKind PRVal) {
|
void setPropertyAttributes(ObjCPropertyAttribute::Kind PRVal) {
|
||||||
PropertyAttributes =
|
PropertyAttributes =
|
||||||
(ObjCPropertyAttributeKind)(PropertyAttributes | PRVal);
|
(ObjCPropertyAttribute::Kind)(PropertyAttributes | PRVal);
|
||||||
}
|
}
|
||||||
|
|
||||||
NullabilityKind getNullability() const {
|
NullabilityKind getNullability() const {
|
||||||
assert(((getObjCDeclQualifier() & DQ_CSNullability) ||
|
assert(
|
||||||
(getPropertyAttributes() & DQ_PR_nullability)) &&
|
((getObjCDeclQualifier() & DQ_CSNullability) ||
|
||||||
"Objective-C declspec doesn't have nullability");
|
(getPropertyAttributes() & ObjCPropertyAttribute::kind_nullability)) &&
|
||||||
|
"Objective-C declspec doesn't have nullability");
|
||||||
return static_cast<NullabilityKind>(Nullability);
|
return static_cast<NullabilityKind>(Nullability);
|
||||||
}
|
}
|
||||||
|
|
||||||
SourceLocation getNullabilityLoc() const {
|
SourceLocation getNullabilityLoc() const {
|
||||||
assert(((getObjCDeclQualifier() & DQ_CSNullability) ||
|
assert(
|
||||||
(getPropertyAttributes() & DQ_PR_nullability)) &&
|
((getObjCDeclQualifier() & DQ_CSNullability) ||
|
||||||
"Objective-C declspec doesn't have nullability");
|
(getPropertyAttributes() & ObjCPropertyAttribute::kind_nullability)) &&
|
||||||
|
"Objective-C declspec doesn't have nullability");
|
||||||
return NullabilityLoc;
|
return NullabilityLoc;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setNullability(SourceLocation loc, NullabilityKind kind) {
|
void setNullability(SourceLocation loc, NullabilityKind kind) {
|
||||||
assert(((getObjCDeclQualifier() & DQ_CSNullability) ||
|
assert(
|
||||||
(getPropertyAttributes() & DQ_PR_nullability)) &&
|
((getObjCDeclQualifier() & DQ_CSNullability) ||
|
||||||
"Set the nullability declspec or property attribute first");
|
(getPropertyAttributes() & ObjCPropertyAttribute::kind_nullability)) &&
|
||||||
|
"Set the nullability declspec or property attribute first");
|
||||||
Nullability = static_cast<unsigned>(kind);
|
Nullability = static_cast<unsigned>(kind);
|
||||||
NullabilityLoc = loc;
|
NullabilityLoc = loc;
|
||||||
}
|
}
|
||||||
|
@ -929,8 +912,8 @@ private:
|
||||||
// (space saving is negligible).
|
// (space saving is negligible).
|
||||||
unsigned objcDeclQualifier : 7;
|
unsigned objcDeclQualifier : 7;
|
||||||
|
|
||||||
// NOTE: VC++ treats enums as signed, avoid using ObjCPropertyAttributeKind
|
// NOTE: VC++ treats enums as signed, avoid using ObjCPropertyAttribute::Kind
|
||||||
unsigned PropertyAttributes : 16;
|
unsigned PropertyAttributes : NumObjCPropertyAttrsBits;
|
||||||
|
|
||||||
unsigned Nullability : 2;
|
unsigned Nullability : 2;
|
||||||
|
|
||||||
|
|
|
@ -231,8 +231,7 @@ static void checkAllAtProps(MigrationContext &MigrateCtx,
|
||||||
|
|
||||||
SmallVector<std::pair<AttributedTypeLoc, ObjCPropertyDecl *>, 4> ATLs;
|
SmallVector<std::pair<AttributedTypeLoc, ObjCPropertyDecl *>, 4> ATLs;
|
||||||
bool hasWeak = false, hasStrong = false;
|
bool hasWeak = false, hasStrong = false;
|
||||||
ObjCPropertyDecl::PropertyAttributeKind
|
ObjCPropertyAttribute::Kind Attrs = ObjCPropertyAttribute::kind_noattr;
|
||||||
Attrs = ObjCPropertyDecl::OBJC_PR_noattr;
|
|
||||||
for (IndivPropsTy::iterator
|
for (IndivPropsTy::iterator
|
||||||
PI = IndProps.begin(), PE = IndProps.end(); PI != PE; ++PI) {
|
PI = IndProps.begin(), PE = IndProps.end(); PI != PE; ++PI) {
|
||||||
ObjCPropertyDecl *PD = *PI;
|
ObjCPropertyDecl *PD = *PI;
|
||||||
|
@ -274,7 +273,7 @@ static void checkAllAtProps(MigrationContext &MigrateCtx,
|
||||||
else
|
else
|
||||||
toAttr = "unsafe_unretained";
|
toAttr = "unsafe_unretained";
|
||||||
}
|
}
|
||||||
if (Attrs & ObjCPropertyDecl::OBJC_PR_assign)
|
if (Attrs & ObjCPropertyAttribute::kind_assign)
|
||||||
MigrateCtx.rewritePropertyAttribute("assign", toAttr, AtLoc);
|
MigrateCtx.rewritePropertyAttribute("assign", toAttr, AtLoc);
|
||||||
else
|
else
|
||||||
MigrateCtx.addPropertyAttribute(toAttr, AtLoc);
|
MigrateCtx.addPropertyAttribute(toAttr, AtLoc);
|
||||||
|
@ -302,8 +301,8 @@ static void checkAllProps(MigrationContext &MigrateCtx,
|
||||||
for (unsigned i = 0, e = AllProps.size(); i != e; ++i) {
|
for (unsigned i = 0, e = AllProps.size(); i != e; ++i) {
|
||||||
ObjCPropertyDecl *PD = AllProps[i];
|
ObjCPropertyDecl *PD = AllProps[i];
|
||||||
if (PD->getPropertyAttributesAsWritten() &
|
if (PD->getPropertyAttributesAsWritten() &
|
||||||
(ObjCPropertyDecl::OBJC_PR_assign |
|
(ObjCPropertyAttribute::kind_assign |
|
||||||
ObjCPropertyDecl::OBJC_PR_readonly)) {
|
ObjCPropertyAttribute::kind_readonly)) {
|
||||||
SourceLocation AtLoc = PD->getAtLoc();
|
SourceLocation AtLoc = PD->getAtLoc();
|
||||||
if (AtLoc.isInvalid())
|
if (AtLoc.isInvalid())
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -168,22 +168,22 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
void rewriteProperty(PropsTy &props, SourceLocation atLoc) {
|
void rewriteProperty(PropsTy &props, SourceLocation atLoc) {
|
||||||
ObjCPropertyDecl::PropertyAttributeKind propAttrs = getPropertyAttrs(props);
|
ObjCPropertyAttribute::Kind propAttrs = getPropertyAttrs(props);
|
||||||
|
|
||||||
if (propAttrs & (ObjCPropertyDecl::OBJC_PR_copy |
|
if (propAttrs &
|
||||||
ObjCPropertyDecl::OBJC_PR_unsafe_unretained |
|
(ObjCPropertyAttribute::kind_copy |
|
||||||
ObjCPropertyDecl::OBJC_PR_strong |
|
ObjCPropertyAttribute::kind_unsafe_unretained |
|
||||||
ObjCPropertyDecl::OBJC_PR_weak))
|
ObjCPropertyAttribute::kind_strong | ObjCPropertyAttribute::kind_weak))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (propAttrs & ObjCPropertyDecl::OBJC_PR_retain) {
|
if (propAttrs & ObjCPropertyAttribute::kind_retain) {
|
||||||
// strong is the default.
|
// strong is the default.
|
||||||
return doPropAction(PropAction_RetainReplacedWithStrong, props, atLoc);
|
return doPropAction(PropAction_RetainReplacedWithStrong, props, atLoc);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HasIvarAssignedAPlusOneObject = hasIvarAssignedAPlusOneObject(props);
|
bool HasIvarAssignedAPlusOneObject = hasIvarAssignedAPlusOneObject(props);
|
||||||
|
|
||||||
if (propAttrs & ObjCPropertyDecl::OBJC_PR_assign) {
|
if (propAttrs & ObjCPropertyAttribute::kind_assign) {
|
||||||
if (HasIvarAssignedAPlusOneObject)
|
if (HasIvarAssignedAPlusOneObject)
|
||||||
return doPropAction(PropAction_AssignRemoved, props, atLoc);
|
return doPropAction(PropAction_AssignRemoved, props, atLoc);
|
||||||
return doPropAction(PropAction_AssignRewritten, props, atLoc);
|
return doPropAction(PropAction_AssignRewritten, props, atLoc);
|
||||||
|
@ -354,11 +354,10 @@ private:
|
||||||
return ty;
|
return ty;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjCPropertyDecl::PropertyAttributeKind
|
ObjCPropertyAttribute::Kind getPropertyAttrs(PropsTy &props) const {
|
||||||
getPropertyAttrs(PropsTy &props) const {
|
|
||||||
assert(!props.empty());
|
assert(!props.empty());
|
||||||
ObjCPropertyDecl::PropertyAttributeKind
|
ObjCPropertyAttribute::Kind attrs =
|
||||||
attrs = props[0].PropD->getPropertyAttributesAsWritten();
|
props[0].PropD->getPropertyAttributesAsWritten();
|
||||||
|
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I)
|
for (PropsTy::iterator I = props.begin(), E = props.end(); I != E; ++I)
|
||||||
|
|
|
@ -118,13 +118,11 @@ public:
|
||||||
ObjCPropertyDecl *PD = PID->getPropertyDecl();
|
ObjCPropertyDecl *PD = PID->getPropertyDecl();
|
||||||
ObjCMethodDecl *setterM = PD->getSetterMethodDecl();
|
ObjCMethodDecl *setterM = PD->getSetterMethodDecl();
|
||||||
if (!(setterM && setterM->isDefined())) {
|
if (!(setterM && setterM->isDefined())) {
|
||||||
ObjCPropertyDecl::PropertyAttributeKind AttrKind =
|
ObjCPropertyAttribute::Kind AttrKind = PD->getPropertyAttributes();
|
||||||
PD->getPropertyAttributes();
|
if (AttrKind & (ObjCPropertyAttribute::kind_retain |
|
||||||
if (AttrKind &
|
ObjCPropertyAttribute::kind_copy |
|
||||||
(ObjCPropertyDecl::OBJC_PR_retain |
|
ObjCPropertyAttribute::kind_strong))
|
||||||
ObjCPropertyDecl::OBJC_PR_copy |
|
SynthesizedProperties[PD] = PID;
|
||||||
ObjCPropertyDecl::OBJC_PR_strong))
|
|
||||||
SynthesizedProperties[PD] = PID;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6770,11 +6770,11 @@ ASTContext::getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD,
|
||||||
|
|
||||||
if (PD->isReadOnly()) {
|
if (PD->isReadOnly()) {
|
||||||
S += ",R";
|
S += ",R";
|
||||||
if (PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_copy)
|
if (PD->getPropertyAttributes() & ObjCPropertyAttribute::kind_copy)
|
||||||
S += ",C";
|
S += ",C";
|
||||||
if (PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_retain)
|
if (PD->getPropertyAttributes() & ObjCPropertyAttribute::kind_retain)
|
||||||
S += ",&";
|
S += ",&";
|
||||||
if (PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_weak)
|
if (PD->getPropertyAttributes() & ObjCPropertyAttribute::kind_weak)
|
||||||
S += ",W";
|
S += ",W";
|
||||||
} else {
|
} else {
|
||||||
switch (PD->getSetterKind()) {
|
switch (PD->getSetterKind()) {
|
||||||
|
@ -6790,15 +6790,15 @@ ASTContext::getObjCEncodingForPropertyDecl(const ObjCPropertyDecl *PD,
|
||||||
if (Dynamic)
|
if (Dynamic)
|
||||||
S += ",D";
|
S += ",D";
|
||||||
|
|
||||||
if (PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_nonatomic)
|
if (PD->getPropertyAttributes() & ObjCPropertyAttribute::kind_nonatomic)
|
||||||
S += ",N";
|
S += ",N";
|
||||||
|
|
||||||
if (PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_getter) {
|
if (PD->getPropertyAttributes() & ObjCPropertyAttribute::kind_getter) {
|
||||||
S += ",G";
|
S += ",G";
|
||||||
S += PD->getGetterName().getAsString();
|
S += PD->getGetterName().getAsString();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_setter) {
|
if (PD->getPropertyAttributes() & ObjCPropertyAttribute::kind_setter) {
|
||||||
S += ",S";
|
S += ",S";
|
||||||
S += PD->getSetterName().getAsString();
|
S += PD->getSetterName().getAsString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -146,7 +146,8 @@ bool ObjCContainerDecl::HasUserDeclaredSetterMethod(
|
||||||
// auto-synthesized).
|
// auto-synthesized).
|
||||||
for (const auto *P : Cat->properties())
|
for (const auto *P : Cat->properties())
|
||||||
if (P->getIdentifier() == Property->getIdentifier()) {
|
if (P->getIdentifier() == Property->getIdentifier()) {
|
||||||
if (P->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_readwrite)
|
if (P->getPropertyAttributes() &
|
||||||
|
ObjCPropertyAttribute::kind_readwrite)
|
||||||
return true;
|
return true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1428,85 +1428,83 @@ void DeclPrinter::VisitObjCPropertyDecl(ObjCPropertyDecl *PDecl) {
|
||||||
QualType T = PDecl->getType();
|
QualType T = PDecl->getType();
|
||||||
|
|
||||||
Out << "@property";
|
Out << "@property";
|
||||||
if (PDecl->getPropertyAttributes() != ObjCPropertyDecl::OBJC_PR_noattr) {
|
if (PDecl->getPropertyAttributes() != ObjCPropertyAttribute::kind_noattr) {
|
||||||
bool first = true;
|
bool first = true;
|
||||||
Out << "(";
|
Out << "(";
|
||||||
if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_class) {
|
if (PDecl->getPropertyAttributes() & ObjCPropertyAttribute::kind_class) {
|
||||||
Out << (first ? "" : ", ") << "class";
|
Out << (first ? "" : ", ") << "class";
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_direct) {
|
if (PDecl->getPropertyAttributes() & ObjCPropertyAttribute::kind_direct) {
|
||||||
Out << (first ? "" : ", ") << "direct";
|
Out << (first ? "" : ", ") << "direct";
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PDecl->getPropertyAttributes() &
|
if (PDecl->getPropertyAttributes() &
|
||||||
ObjCPropertyDecl::OBJC_PR_nonatomic) {
|
ObjCPropertyAttribute::kind_nonatomic) {
|
||||||
Out << (first ? "" : ", ") << "nonatomic";
|
Out << (first ? "" : ", ") << "nonatomic";
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
if (PDecl->getPropertyAttributes() &
|
if (PDecl->getPropertyAttributes() & ObjCPropertyAttribute::kind_atomic) {
|
||||||
ObjCPropertyDecl::OBJC_PR_atomic) {
|
|
||||||
Out << (first ? "" : ", ") << "atomic";
|
Out << (first ? "" : ", ") << "atomic";
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_assign) {
|
if (PDecl->getPropertyAttributes() & ObjCPropertyAttribute::kind_assign) {
|
||||||
Out << (first ? "" : ", ") << "assign";
|
Out << (first ? "" : ", ") << "assign";
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_retain) {
|
if (PDecl->getPropertyAttributes() & ObjCPropertyAttribute::kind_retain) {
|
||||||
Out << (first ? "" : ", ") << "retain";
|
Out << (first ? "" : ", ") << "retain";
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_strong) {
|
if (PDecl->getPropertyAttributes() & ObjCPropertyAttribute::kind_strong) {
|
||||||
Out << (first ? "" : ", ") << "strong";
|
Out << (first ? "" : ", ") << "strong";
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_copy) {
|
if (PDecl->getPropertyAttributes() & ObjCPropertyAttribute::kind_copy) {
|
||||||
Out << (first ? "" : ", ") << "copy";
|
Out << (first ? "" : ", ") << "copy";
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_weak) {
|
if (PDecl->getPropertyAttributes() & ObjCPropertyAttribute::kind_weak) {
|
||||||
Out << (first ? "" : ", ") << "weak";
|
Out << (first ? "" : ", ") << "weak";
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
if (PDecl->getPropertyAttributes()
|
if (PDecl->getPropertyAttributes() &
|
||||||
& ObjCPropertyDecl::OBJC_PR_unsafe_unretained) {
|
ObjCPropertyAttribute::kind_unsafe_unretained) {
|
||||||
Out << (first ? "" : ", ") << "unsafe_unretained";
|
Out << (first ? "" : ", ") << "unsafe_unretained";
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PDecl->getPropertyAttributes() &
|
if (PDecl->getPropertyAttributes() &
|
||||||
ObjCPropertyDecl::OBJC_PR_readwrite) {
|
ObjCPropertyAttribute::kind_readwrite) {
|
||||||
Out << (first ? "" : ", ") << "readwrite";
|
Out << (first ? "" : ", ") << "readwrite";
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
if (PDecl->getPropertyAttributes() &
|
if (PDecl->getPropertyAttributes() & ObjCPropertyAttribute::kind_readonly) {
|
||||||
ObjCPropertyDecl::OBJC_PR_readonly) {
|
|
||||||
Out << (first ? "" : ", ") << "readonly";
|
Out << (first ? "" : ", ") << "readonly";
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_getter) {
|
if (PDecl->getPropertyAttributes() & ObjCPropertyAttribute::kind_getter) {
|
||||||
Out << (first ? "" : ", ") << "getter = ";
|
Out << (first ? "" : ", ") << "getter = ";
|
||||||
PDecl->getGetterName().print(Out);
|
PDecl->getGetterName().print(Out);
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
if (PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_setter) {
|
if (PDecl->getPropertyAttributes() & ObjCPropertyAttribute::kind_setter) {
|
||||||
Out << (first ? "" : ", ") << "setter = ";
|
Out << (first ? "" : ", ") << "setter = ";
|
||||||
PDecl->getSetterName().print(Out);
|
PDecl->getSetterName().print(Out);
|
||||||
first = false;
|
first = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PDecl->getPropertyAttributes() &
|
if (PDecl->getPropertyAttributes() &
|
||||||
ObjCPropertyDecl::OBJC_PR_nullability) {
|
ObjCPropertyAttribute::kind_nullability) {
|
||||||
if (auto nullability = AttributedType::stripOuterNullability(T)) {
|
if (auto nullability = AttributedType::stripOuterNullability(T)) {
|
||||||
if (*nullability == NullabilityKind::Unspecified &&
|
if (*nullability == NullabilityKind::Unspecified &&
|
||||||
(PDecl->getPropertyAttributes() &
|
(PDecl->getPropertyAttributes() &
|
||||||
ObjCPropertyDecl::OBJC_PR_null_resettable)) {
|
ObjCPropertyAttribute::kind_null_resettable)) {
|
||||||
Out << (first ? "" : ", ") << "null_resettable";
|
Out << (first ? "" : ", ") << "null_resettable";
|
||||||
} else {
|
} else {
|
||||||
Out << (first ? "" : ", ")
|
Out << (first ? "" : ", ")
|
||||||
|
|
|
@ -999,31 +999,32 @@ void JSONNodeDumper::VisitObjCPropertyDecl(const ObjCPropertyDecl *D) {
|
||||||
case ObjCPropertyDecl::Optional: JOS.attribute("control", "optional"); break;
|
case ObjCPropertyDecl::Optional: JOS.attribute("control", "optional"); break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ObjCPropertyDecl::PropertyAttributeKind Attrs = D->getPropertyAttributes();
|
ObjCPropertyAttribute::Kind Attrs = D->getPropertyAttributes();
|
||||||
if (Attrs != ObjCPropertyDecl::OBJC_PR_noattr) {
|
if (Attrs != ObjCPropertyAttribute::kind_noattr) {
|
||||||
if (Attrs & ObjCPropertyDecl::OBJC_PR_getter)
|
if (Attrs & ObjCPropertyAttribute::kind_getter)
|
||||||
JOS.attribute("getter", createBareDeclRef(D->getGetterMethodDecl()));
|
JOS.attribute("getter", createBareDeclRef(D->getGetterMethodDecl()));
|
||||||
if (Attrs & ObjCPropertyDecl::OBJC_PR_setter)
|
if (Attrs & ObjCPropertyAttribute::kind_setter)
|
||||||
JOS.attribute("setter", createBareDeclRef(D->getSetterMethodDecl()));
|
JOS.attribute("setter", createBareDeclRef(D->getSetterMethodDecl()));
|
||||||
attributeOnlyIfTrue("readonly", Attrs & ObjCPropertyDecl::OBJC_PR_readonly);
|
attributeOnlyIfTrue("readonly",
|
||||||
attributeOnlyIfTrue("assign", Attrs & ObjCPropertyDecl::OBJC_PR_assign);
|
Attrs & ObjCPropertyAttribute::kind_readonly);
|
||||||
|
attributeOnlyIfTrue("assign", Attrs & ObjCPropertyAttribute::kind_assign);
|
||||||
attributeOnlyIfTrue("readwrite",
|
attributeOnlyIfTrue("readwrite",
|
||||||
Attrs & ObjCPropertyDecl::OBJC_PR_readwrite);
|
Attrs & ObjCPropertyAttribute::kind_readwrite);
|
||||||
attributeOnlyIfTrue("retain", Attrs & ObjCPropertyDecl::OBJC_PR_retain);
|
attributeOnlyIfTrue("retain", Attrs & ObjCPropertyAttribute::kind_retain);
|
||||||
attributeOnlyIfTrue("copy", Attrs & ObjCPropertyDecl::OBJC_PR_copy);
|
attributeOnlyIfTrue("copy", Attrs & ObjCPropertyAttribute::kind_copy);
|
||||||
attributeOnlyIfTrue("nonatomic",
|
attributeOnlyIfTrue("nonatomic",
|
||||||
Attrs & ObjCPropertyDecl::OBJC_PR_nonatomic);
|
Attrs & ObjCPropertyAttribute::kind_nonatomic);
|
||||||
attributeOnlyIfTrue("atomic", Attrs & ObjCPropertyDecl::OBJC_PR_atomic);
|
attributeOnlyIfTrue("atomic", Attrs & ObjCPropertyAttribute::kind_atomic);
|
||||||
attributeOnlyIfTrue("weak", Attrs & ObjCPropertyDecl::OBJC_PR_weak);
|
attributeOnlyIfTrue("weak", Attrs & ObjCPropertyAttribute::kind_weak);
|
||||||
attributeOnlyIfTrue("strong", Attrs & ObjCPropertyDecl::OBJC_PR_strong);
|
attributeOnlyIfTrue("strong", Attrs & ObjCPropertyAttribute::kind_strong);
|
||||||
attributeOnlyIfTrue("unsafe_unretained",
|
attributeOnlyIfTrue("unsafe_unretained",
|
||||||
Attrs & ObjCPropertyDecl::OBJC_PR_unsafe_unretained);
|
Attrs & ObjCPropertyAttribute::kind_unsafe_unretained);
|
||||||
attributeOnlyIfTrue("class", Attrs & ObjCPropertyDecl::OBJC_PR_class);
|
attributeOnlyIfTrue("class", Attrs & ObjCPropertyAttribute::kind_class);
|
||||||
attributeOnlyIfTrue("direct", Attrs & ObjCPropertyDecl::OBJC_PR_direct);
|
attributeOnlyIfTrue("direct", Attrs & ObjCPropertyAttribute::kind_direct);
|
||||||
attributeOnlyIfTrue("nullability",
|
attributeOnlyIfTrue("nullability",
|
||||||
Attrs & ObjCPropertyDecl::OBJC_PR_nullability);
|
Attrs & ObjCPropertyAttribute::kind_nullability);
|
||||||
attributeOnlyIfTrue("null_resettable",
|
attributeOnlyIfTrue("null_resettable",
|
||||||
Attrs & ObjCPropertyDecl::OBJC_PR_null_resettable);
|
Attrs & ObjCPropertyAttribute::kind_null_resettable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1958,35 +1958,35 @@ void TextNodeDumper::VisitObjCPropertyDecl(const ObjCPropertyDecl *D) {
|
||||||
else if (D->getPropertyImplementation() == ObjCPropertyDecl::Optional)
|
else if (D->getPropertyImplementation() == ObjCPropertyDecl::Optional)
|
||||||
OS << " optional";
|
OS << " optional";
|
||||||
|
|
||||||
ObjCPropertyDecl::PropertyAttributeKind Attrs = D->getPropertyAttributes();
|
ObjCPropertyAttribute::Kind Attrs = D->getPropertyAttributes();
|
||||||
if (Attrs != ObjCPropertyDecl::OBJC_PR_noattr) {
|
if (Attrs != ObjCPropertyAttribute::kind_noattr) {
|
||||||
if (Attrs & ObjCPropertyDecl::OBJC_PR_readonly)
|
if (Attrs & ObjCPropertyAttribute::kind_readonly)
|
||||||
OS << " readonly";
|
OS << " readonly";
|
||||||
if (Attrs & ObjCPropertyDecl::OBJC_PR_assign)
|
if (Attrs & ObjCPropertyAttribute::kind_assign)
|
||||||
OS << " assign";
|
OS << " assign";
|
||||||
if (Attrs & ObjCPropertyDecl::OBJC_PR_readwrite)
|
if (Attrs & ObjCPropertyAttribute::kind_readwrite)
|
||||||
OS << " readwrite";
|
OS << " readwrite";
|
||||||
if (Attrs & ObjCPropertyDecl::OBJC_PR_retain)
|
if (Attrs & ObjCPropertyAttribute::kind_retain)
|
||||||
OS << " retain";
|
OS << " retain";
|
||||||
if (Attrs & ObjCPropertyDecl::OBJC_PR_copy)
|
if (Attrs & ObjCPropertyAttribute::kind_copy)
|
||||||
OS << " copy";
|
OS << " copy";
|
||||||
if (Attrs & ObjCPropertyDecl::OBJC_PR_nonatomic)
|
if (Attrs & ObjCPropertyAttribute::kind_nonatomic)
|
||||||
OS << " nonatomic";
|
OS << " nonatomic";
|
||||||
if (Attrs & ObjCPropertyDecl::OBJC_PR_atomic)
|
if (Attrs & ObjCPropertyAttribute::kind_atomic)
|
||||||
OS << " atomic";
|
OS << " atomic";
|
||||||
if (Attrs & ObjCPropertyDecl::OBJC_PR_weak)
|
if (Attrs & ObjCPropertyAttribute::kind_weak)
|
||||||
OS << " weak";
|
OS << " weak";
|
||||||
if (Attrs & ObjCPropertyDecl::OBJC_PR_strong)
|
if (Attrs & ObjCPropertyAttribute::kind_strong)
|
||||||
OS << " strong";
|
OS << " strong";
|
||||||
if (Attrs & ObjCPropertyDecl::OBJC_PR_unsafe_unretained)
|
if (Attrs & ObjCPropertyAttribute::kind_unsafe_unretained)
|
||||||
OS << " unsafe_unretained";
|
OS << " unsafe_unretained";
|
||||||
if (Attrs & ObjCPropertyDecl::OBJC_PR_class)
|
if (Attrs & ObjCPropertyAttribute::kind_class)
|
||||||
OS << " class";
|
OS << " class";
|
||||||
if (Attrs & ObjCPropertyDecl::OBJC_PR_direct)
|
if (Attrs & ObjCPropertyAttribute::kind_direct)
|
||||||
OS << " direct";
|
OS << " direct";
|
||||||
if (Attrs & ObjCPropertyDecl::OBJC_PR_getter)
|
if (Attrs & ObjCPropertyAttribute::kind_getter)
|
||||||
dumpDeclRef(D->getGetterMethodDecl(), "getter");
|
dumpDeclRef(D->getGetterMethodDecl(), "getter");
|
||||||
if (Attrs & ObjCPropertyDecl::OBJC_PR_setter)
|
if (Attrs & ObjCPropertyAttribute::kind_setter)
|
||||||
dumpDeclRef(D->getSetterMethodDecl(), "setter");
|
dumpDeclRef(D->getSetterMethodDecl(), "setter");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -762,7 +762,7 @@ static Stmt *createObjCPropertyGetter(ASTContext &Ctx,
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
// Ignore weak variables, which have special behavior.
|
// Ignore weak variables, which have special behavior.
|
||||||
if (Prop->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_weak)
|
if (Prop->getPropertyAttributes() & ObjCPropertyAttribute::kind_weak)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
// Look to see if Sema has synthesized a body for us. This happens in
|
// Look to see if Sema has synthesized a body for us. This happens in
|
||||||
|
|
|
@ -3505,7 +3505,7 @@ CodeGenFunction::GenerateObjCAtomicSetterCopyHelperFunction(
|
||||||
if (!Ty->isRecordType())
|
if (!Ty->isRecordType())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
const ObjCPropertyDecl *PD = PID->getPropertyDecl();
|
const ObjCPropertyDecl *PD = PID->getPropertyDecl();
|
||||||
if ((!(PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_atomic)))
|
if ((!(PD->getPropertyAttributes() & ObjCPropertyAttribute::kind_atomic)))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
llvm::Constant *HelperFn = nullptr;
|
llvm::Constant *HelperFn = nullptr;
|
||||||
if (hasTrivialSetExpr(PID))
|
if (hasTrivialSetExpr(PID))
|
||||||
|
@ -3589,7 +3589,7 @@ CodeGenFunction::GenerateObjCAtomicGetterCopyHelperFunction(
|
||||||
QualType Ty = PD->getType();
|
QualType Ty = PD->getType();
|
||||||
if (!Ty->isRecordType())
|
if (!Ty->isRecordType())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
if ((!(PD->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_atomic)))
|
if ((!(PD->getPropertyAttributes() & ObjCPropertyAttribute::kind_atomic)))
|
||||||
return nullptr;
|
return nullptr;
|
||||||
llvm::Constant *HelperFn = nullptr;
|
llvm::Constant *HelperFn = nullptr;
|
||||||
if (hasTrivialGetExpr(PID))
|
if (hasTrivialGetExpr(PID))
|
||||||
|
|
|
@ -255,11 +255,11 @@ protected:
|
||||||
isDynamic=true) {
|
isDynamic=true) {
|
||||||
int attrs = property->getPropertyAttributes();
|
int attrs = property->getPropertyAttributes();
|
||||||
// For read-only properties, clear the copy and retain flags
|
// For read-only properties, clear the copy and retain flags
|
||||||
if (attrs & ObjCPropertyDecl::OBJC_PR_readonly) {
|
if (attrs & ObjCPropertyAttribute::kind_readonly) {
|
||||||
attrs &= ~ObjCPropertyDecl::OBJC_PR_copy;
|
attrs &= ~ObjCPropertyAttribute::kind_copy;
|
||||||
attrs &= ~ObjCPropertyDecl::OBJC_PR_retain;
|
attrs &= ~ObjCPropertyAttribute::kind_retain;
|
||||||
attrs &= ~ObjCPropertyDecl::OBJC_PR_weak;
|
attrs &= ~ObjCPropertyAttribute::kind_weak;
|
||||||
attrs &= ~ObjCPropertyDecl::OBJC_PR_strong;
|
attrs &= ~ObjCPropertyAttribute::kind_strong;
|
||||||
}
|
}
|
||||||
// The first flags field has the same attribute values as clang uses internally
|
// The first flags field has the same attribute values as clang uses internally
|
||||||
Fields.addInt(Int8Ty, attrs & 0xff);
|
Fields.addInt(Int8Ty, attrs & 0xff);
|
||||||
|
|
|
@ -941,9 +941,10 @@ void RewriteModernObjC::RewritePropertyImplDecl(ObjCPropertyImplDecl *PID,
|
||||||
|
|
||||||
unsigned Attributes = PD->getPropertyAttributes();
|
unsigned Attributes = PD->getPropertyAttributes();
|
||||||
if (mustSynthesizeSetterGetterMethod(IMD, PD, true /*getter*/)) {
|
if (mustSynthesizeSetterGetterMethod(IMD, PD, true /*getter*/)) {
|
||||||
bool GenGetProperty = !(Attributes & ObjCPropertyDecl::OBJC_PR_nonatomic) &&
|
bool GenGetProperty =
|
||||||
(Attributes & (ObjCPropertyDecl::OBJC_PR_retain |
|
!(Attributes & ObjCPropertyAttribute::kind_nonatomic) &&
|
||||||
ObjCPropertyDecl::OBJC_PR_copy));
|
(Attributes & (ObjCPropertyAttribute::kind_retain |
|
||||||
|
ObjCPropertyAttribute::kind_copy));
|
||||||
std::string Getr;
|
std::string Getr;
|
||||||
if (GenGetProperty && !objcGetPropertyDefined) {
|
if (GenGetProperty && !objcGetPropertyDefined) {
|
||||||
objcGetPropertyDefined = true;
|
objcGetPropertyDefined = true;
|
||||||
|
@ -1002,8 +1003,8 @@ void RewriteModernObjC::RewritePropertyImplDecl(ObjCPropertyImplDecl *PID,
|
||||||
|
|
||||||
// Generate the 'setter' function.
|
// Generate the 'setter' function.
|
||||||
std::string Setr;
|
std::string Setr;
|
||||||
bool GenSetProperty = Attributes & (ObjCPropertyDecl::OBJC_PR_retain |
|
bool GenSetProperty = Attributes & (ObjCPropertyAttribute::kind_retain |
|
||||||
ObjCPropertyDecl::OBJC_PR_copy);
|
ObjCPropertyAttribute::kind_copy);
|
||||||
if (GenSetProperty && !objcSetPropertyDefined) {
|
if (GenSetProperty && !objcSetPropertyDefined) {
|
||||||
objcSetPropertyDefined = true;
|
objcSetPropertyDefined = true;
|
||||||
// FIXME. Is this attribute correct in all cases?
|
// FIXME. Is this attribute correct in all cases?
|
||||||
|
@ -1022,11 +1023,11 @@ void RewriteModernObjC::RewritePropertyImplDecl(ObjCPropertyImplDecl *PID,
|
||||||
Setr += ", (id)";
|
Setr += ", (id)";
|
||||||
Setr += PD->getName();
|
Setr += PD->getName();
|
||||||
Setr += ", ";
|
Setr += ", ";
|
||||||
if (Attributes & ObjCPropertyDecl::OBJC_PR_nonatomic)
|
if (Attributes & ObjCPropertyAttribute::kind_nonatomic)
|
||||||
Setr += "0, ";
|
Setr += "0, ";
|
||||||
else
|
else
|
||||||
Setr += "1, ";
|
Setr += "1, ";
|
||||||
if (Attributes & ObjCPropertyDecl::OBJC_PR_copy)
|
if (Attributes & ObjCPropertyAttribute::kind_copy)
|
||||||
Setr += "1)";
|
Setr += "1)";
|
||||||
else
|
else
|
||||||
Setr += "0)";
|
Setr += "0)";
|
||||||
|
|
|
@ -789,9 +789,10 @@ void RewriteObjC::RewritePropertyImplDecl(ObjCPropertyImplDecl *PID,
|
||||||
|
|
||||||
unsigned Attributes = PD->getPropertyAttributes();
|
unsigned Attributes = PD->getPropertyAttributes();
|
||||||
if (PID->getGetterMethodDecl() && !PID->getGetterMethodDecl()->isDefined()) {
|
if (PID->getGetterMethodDecl() && !PID->getGetterMethodDecl()->isDefined()) {
|
||||||
bool GenGetProperty = !(Attributes & ObjCPropertyDecl::OBJC_PR_nonatomic) &&
|
bool GenGetProperty =
|
||||||
(Attributes & (ObjCPropertyDecl::OBJC_PR_retain |
|
!(Attributes & ObjCPropertyAttribute::kind_nonatomic) &&
|
||||||
ObjCPropertyDecl::OBJC_PR_copy));
|
(Attributes & (ObjCPropertyAttribute::kind_retain |
|
||||||
|
ObjCPropertyAttribute::kind_copy));
|
||||||
std::string Getr;
|
std::string Getr;
|
||||||
if (GenGetProperty && !objcGetPropertyDefined) {
|
if (GenGetProperty && !objcGetPropertyDefined) {
|
||||||
objcGetPropertyDefined = true;
|
objcGetPropertyDefined = true;
|
||||||
|
@ -850,8 +851,8 @@ void RewriteObjC::RewritePropertyImplDecl(ObjCPropertyImplDecl *PID,
|
||||||
|
|
||||||
// Generate the 'setter' function.
|
// Generate the 'setter' function.
|
||||||
std::string Setr;
|
std::string Setr;
|
||||||
bool GenSetProperty = Attributes & (ObjCPropertyDecl::OBJC_PR_retain |
|
bool GenSetProperty = Attributes & (ObjCPropertyAttribute::kind_retain |
|
||||||
ObjCPropertyDecl::OBJC_PR_copy);
|
ObjCPropertyAttribute::kind_copy);
|
||||||
if (GenSetProperty && !objcSetPropertyDefined) {
|
if (GenSetProperty && !objcSetPropertyDefined) {
|
||||||
objcSetPropertyDefined = true;
|
objcSetPropertyDefined = true;
|
||||||
// FIXME. Is this attribute correct in all cases?
|
// FIXME. Is this attribute correct in all cases?
|
||||||
|
@ -870,11 +871,11 @@ void RewriteObjC::RewritePropertyImplDecl(ObjCPropertyImplDecl *PID,
|
||||||
Setr += ", (id)";
|
Setr += ", (id)";
|
||||||
Setr += PD->getName();
|
Setr += PD->getName();
|
||||||
Setr += ", ";
|
Setr += ", ";
|
||||||
if (Attributes & ObjCPropertyDecl::OBJC_PR_nonatomic)
|
if (Attributes & ObjCPropertyAttribute::kind_nonatomic)
|
||||||
Setr += "0, ";
|
Setr += "0, ";
|
||||||
else
|
else
|
||||||
Setr += "1, ";
|
Setr += "1, ";
|
||||||
if (Attributes & ObjCPropertyDecl::OBJC_PR_copy)
|
if (Attributes & ObjCPropertyAttribute::kind_copy)
|
||||||
Setr += "1)";
|
Setr += "1)";
|
||||||
else
|
else
|
||||||
Setr += "0)";
|
Setr += "0)";
|
||||||
|
|
|
@ -740,7 +740,8 @@ void Parser::ParseObjCInterfaceDeclList(tok::ObjCKeywordKind contextKey,
|
||||||
|
|
||||||
// Map a nullability property attribute to a context-sensitive keyword
|
// Map a nullability property attribute to a context-sensitive keyword
|
||||||
// attribute.
|
// attribute.
|
||||||
if (OCDS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_nullability)
|
if (OCDS.getPropertyAttributes() &
|
||||||
|
ObjCPropertyAttribute::kind_nullability)
|
||||||
addContextSensitiveTypeNullability(*this, FD.D, OCDS.getNullability(),
|
addContextSensitiveTypeNullability(*this, FD.D, OCDS.getNullability(),
|
||||||
OCDS.getNullabilityLoc(),
|
OCDS.getNullabilityLoc(),
|
||||||
addedToDeclSpec);
|
addedToDeclSpec);
|
||||||
|
@ -860,25 +861,25 @@ void Parser::ParseObjCPropertyAttribute(ObjCDeclSpec &DS) {
|
||||||
SourceLocation AttrName = ConsumeToken(); // consume last attribute name
|
SourceLocation AttrName = ConsumeToken(); // consume last attribute name
|
||||||
|
|
||||||
if (II->isStr("readonly"))
|
if (II->isStr("readonly"))
|
||||||
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_readonly);
|
DS.setPropertyAttributes(ObjCPropertyAttribute::kind_readonly);
|
||||||
else if (II->isStr("assign"))
|
else if (II->isStr("assign"))
|
||||||
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_assign);
|
DS.setPropertyAttributes(ObjCPropertyAttribute::kind_assign);
|
||||||
else if (II->isStr("unsafe_unretained"))
|
else if (II->isStr("unsafe_unretained"))
|
||||||
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_unsafe_unretained);
|
DS.setPropertyAttributes(ObjCPropertyAttribute::kind_unsafe_unretained);
|
||||||
else if (II->isStr("readwrite"))
|
else if (II->isStr("readwrite"))
|
||||||
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_readwrite);
|
DS.setPropertyAttributes(ObjCPropertyAttribute::kind_readwrite);
|
||||||
else if (II->isStr("retain"))
|
else if (II->isStr("retain"))
|
||||||
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_retain);
|
DS.setPropertyAttributes(ObjCPropertyAttribute::kind_retain);
|
||||||
else if (II->isStr("strong"))
|
else if (II->isStr("strong"))
|
||||||
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_strong);
|
DS.setPropertyAttributes(ObjCPropertyAttribute::kind_strong);
|
||||||
else if (II->isStr("copy"))
|
else if (II->isStr("copy"))
|
||||||
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_copy);
|
DS.setPropertyAttributes(ObjCPropertyAttribute::kind_copy);
|
||||||
else if (II->isStr("nonatomic"))
|
else if (II->isStr("nonatomic"))
|
||||||
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_nonatomic);
|
DS.setPropertyAttributes(ObjCPropertyAttribute::kind_nonatomic);
|
||||||
else if (II->isStr("atomic"))
|
else if (II->isStr("atomic"))
|
||||||
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_atomic);
|
DS.setPropertyAttributes(ObjCPropertyAttribute::kind_atomic);
|
||||||
else if (II->isStr("weak"))
|
else if (II->isStr("weak"))
|
||||||
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_weak);
|
DS.setPropertyAttributes(ObjCPropertyAttribute::kind_weak);
|
||||||
else if (II->isStr("getter") || II->isStr("setter")) {
|
else if (II->isStr("getter") || II->isStr("setter")) {
|
||||||
bool IsSetter = II->getNameStart()[0] == 's';
|
bool IsSetter = II->getNameStart()[0] == 's';
|
||||||
|
|
||||||
|
@ -910,7 +911,7 @@ void Parser::ParseObjCPropertyAttribute(ObjCDeclSpec &DS) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsSetter) {
|
if (IsSetter) {
|
||||||
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_setter);
|
DS.setPropertyAttributes(ObjCPropertyAttribute::kind_setter);
|
||||||
DS.setSetterName(SelIdent, SelLoc);
|
DS.setSetterName(SelIdent, SelLoc);
|
||||||
|
|
||||||
if (ExpectAndConsume(tok::colon,
|
if (ExpectAndConsume(tok::colon,
|
||||||
|
@ -919,44 +920,44 @@ void Parser::ParseObjCPropertyAttribute(ObjCDeclSpec &DS) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_getter);
|
DS.setPropertyAttributes(ObjCPropertyAttribute::kind_getter);
|
||||||
DS.setGetterName(SelIdent, SelLoc);
|
DS.setGetterName(SelIdent, SelLoc);
|
||||||
}
|
}
|
||||||
} else if (II->isStr("nonnull")) {
|
} else if (II->isStr("nonnull")) {
|
||||||
if (DS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_nullability)
|
if (DS.getPropertyAttributes() & ObjCPropertyAttribute::kind_nullability)
|
||||||
diagnoseRedundantPropertyNullability(*this, DS,
|
diagnoseRedundantPropertyNullability(*this, DS,
|
||||||
NullabilityKind::NonNull,
|
NullabilityKind::NonNull,
|
||||||
Tok.getLocation());
|
Tok.getLocation());
|
||||||
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_nullability);
|
DS.setPropertyAttributes(ObjCPropertyAttribute::kind_nullability);
|
||||||
DS.setNullability(Tok.getLocation(), NullabilityKind::NonNull);
|
DS.setNullability(Tok.getLocation(), NullabilityKind::NonNull);
|
||||||
} else if (II->isStr("nullable")) {
|
} else if (II->isStr("nullable")) {
|
||||||
if (DS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_nullability)
|
if (DS.getPropertyAttributes() & ObjCPropertyAttribute::kind_nullability)
|
||||||
diagnoseRedundantPropertyNullability(*this, DS,
|
diagnoseRedundantPropertyNullability(*this, DS,
|
||||||
NullabilityKind::Nullable,
|
NullabilityKind::Nullable,
|
||||||
Tok.getLocation());
|
Tok.getLocation());
|
||||||
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_nullability);
|
DS.setPropertyAttributes(ObjCPropertyAttribute::kind_nullability);
|
||||||
DS.setNullability(Tok.getLocation(), NullabilityKind::Nullable);
|
DS.setNullability(Tok.getLocation(), NullabilityKind::Nullable);
|
||||||
} else if (II->isStr("null_unspecified")) {
|
} else if (II->isStr("null_unspecified")) {
|
||||||
if (DS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_nullability)
|
if (DS.getPropertyAttributes() & ObjCPropertyAttribute::kind_nullability)
|
||||||
diagnoseRedundantPropertyNullability(*this, DS,
|
diagnoseRedundantPropertyNullability(*this, DS,
|
||||||
NullabilityKind::Unspecified,
|
NullabilityKind::Unspecified,
|
||||||
Tok.getLocation());
|
Tok.getLocation());
|
||||||
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_nullability);
|
DS.setPropertyAttributes(ObjCPropertyAttribute::kind_nullability);
|
||||||
DS.setNullability(Tok.getLocation(), NullabilityKind::Unspecified);
|
DS.setNullability(Tok.getLocation(), NullabilityKind::Unspecified);
|
||||||
} else if (II->isStr("null_resettable")) {
|
} else if (II->isStr("null_resettable")) {
|
||||||
if (DS.getPropertyAttributes() & ObjCDeclSpec::DQ_PR_nullability)
|
if (DS.getPropertyAttributes() & ObjCPropertyAttribute::kind_nullability)
|
||||||
diagnoseRedundantPropertyNullability(*this, DS,
|
diagnoseRedundantPropertyNullability(*this, DS,
|
||||||
NullabilityKind::Unspecified,
|
NullabilityKind::Unspecified,
|
||||||
Tok.getLocation());
|
Tok.getLocation());
|
||||||
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_nullability);
|
DS.setPropertyAttributes(ObjCPropertyAttribute::kind_nullability);
|
||||||
DS.setNullability(Tok.getLocation(), NullabilityKind::Unspecified);
|
DS.setNullability(Tok.getLocation(), NullabilityKind::Unspecified);
|
||||||
|
|
||||||
// Also set the null_resettable bit.
|
// Also set the null_resettable bit.
|
||||||
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_null_resettable);
|
DS.setPropertyAttributes(ObjCPropertyAttribute::kind_null_resettable);
|
||||||
} else if (II->isStr("class")) {
|
} else if (II->isStr("class")) {
|
||||||
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_class);
|
DS.setPropertyAttributes(ObjCPropertyAttribute::kind_class);
|
||||||
} else if (II->isStr("direct")) {
|
} else if (II->isStr("direct")) {
|
||||||
DS.setPropertyAttributes(ObjCDeclSpec::DQ_PR_direct);
|
DS.setPropertyAttributes(ObjCPropertyAttribute::kind_direct);
|
||||||
} else {
|
} else {
|
||||||
Diag(AttrName, diag::err_objc_expected_property_attr) << II;
|
Diag(AttrName, diag::err_objc_expected_property_attr) << II;
|
||||||
SkipUntil(tok::r_paren, StopAtSemi);
|
SkipUntil(tok::r_paren, StopAtSemi);
|
||||||
|
|
|
@ -13917,12 +13917,12 @@ void Sema::checkUnsafeExprAssigns(SourceLocation Loc,
|
||||||
return;
|
return;
|
||||||
|
|
||||||
unsigned Attributes = PD->getPropertyAttributes();
|
unsigned Attributes = PD->getPropertyAttributes();
|
||||||
if (Attributes & ObjCPropertyDecl::OBJC_PR_assign) {
|
if (Attributes & ObjCPropertyAttribute::kind_assign) {
|
||||||
// when 'assign' attribute was not explicitly specified
|
// when 'assign' attribute was not explicitly specified
|
||||||
// by user, ignore it and rely on property type itself
|
// by user, ignore it and rely on property type itself
|
||||||
// for lifetime info.
|
// for lifetime info.
|
||||||
unsigned AsWrittenAttr = PD->getPropertyAttributesAsWritten();
|
unsigned AsWrittenAttr = PD->getPropertyAttributesAsWritten();
|
||||||
if (!(AsWrittenAttr & ObjCPropertyDecl::OBJC_PR_assign) &&
|
if (!(AsWrittenAttr & ObjCPropertyAttribute::kind_assign) &&
|
||||||
LHSType->isObjCRetainableType())
|
LHSType->isObjCRetainableType())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
@ -13934,8 +13934,7 @@ void Sema::checkUnsafeExprAssigns(SourceLocation Loc,
|
||||||
}
|
}
|
||||||
RHS = cast->getSubExpr();
|
RHS = cast->getSubExpr();
|
||||||
}
|
}
|
||||||
}
|
} else if (Attributes & ObjCPropertyAttribute::kind_weak) {
|
||||||
else if (Attributes & ObjCPropertyDecl::OBJC_PR_weak) {
|
|
||||||
if (checkUnsafeAssignObject(*this, Loc, Qualifiers::OCL_Weak, RHS, true))
|
if (checkUnsafeAssignObject(*this, Loc, Qualifiers::OCL_Weak, RHS, true))
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -6513,22 +6513,24 @@ static bool ObjCPropertyFlagConflicts(unsigned Attributes, unsigned NewFlag) {
|
||||||
Attributes |= NewFlag;
|
Attributes |= NewFlag;
|
||||||
|
|
||||||
// Check for collisions with "readonly".
|
// Check for collisions with "readonly".
|
||||||
if ((Attributes & ObjCDeclSpec::DQ_PR_readonly) &&
|
if ((Attributes & ObjCPropertyAttribute::kind_readonly) &&
|
||||||
(Attributes & ObjCDeclSpec::DQ_PR_readwrite))
|
(Attributes & ObjCPropertyAttribute::kind_readwrite))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Check for more than one of { assign, copy, retain, strong, weak }.
|
// Check for more than one of { assign, copy, retain, strong, weak }.
|
||||||
unsigned AssignCopyRetMask =
|
unsigned AssignCopyRetMask =
|
||||||
Attributes &
|
Attributes &
|
||||||
(ObjCDeclSpec::DQ_PR_assign | ObjCDeclSpec::DQ_PR_unsafe_unretained |
|
(ObjCPropertyAttribute::kind_assign |
|
||||||
ObjCDeclSpec::DQ_PR_copy | ObjCDeclSpec::DQ_PR_retain |
|
ObjCPropertyAttribute::kind_unsafe_unretained |
|
||||||
ObjCDeclSpec::DQ_PR_strong | ObjCDeclSpec::DQ_PR_weak);
|
ObjCPropertyAttribute::kind_copy | ObjCPropertyAttribute::kind_retain |
|
||||||
if (AssignCopyRetMask && AssignCopyRetMask != ObjCDeclSpec::DQ_PR_assign &&
|
ObjCPropertyAttribute::kind_strong | ObjCPropertyAttribute::kind_weak);
|
||||||
AssignCopyRetMask != ObjCDeclSpec::DQ_PR_unsafe_unretained &&
|
if (AssignCopyRetMask &&
|
||||||
AssignCopyRetMask != ObjCDeclSpec::DQ_PR_copy &&
|
AssignCopyRetMask != ObjCPropertyAttribute::kind_assign &&
|
||||||
AssignCopyRetMask != ObjCDeclSpec::DQ_PR_retain &&
|
AssignCopyRetMask != ObjCPropertyAttribute::kind_unsafe_unretained &&
|
||||||
AssignCopyRetMask != ObjCDeclSpec::DQ_PR_strong &&
|
AssignCopyRetMask != ObjCPropertyAttribute::kind_copy &&
|
||||||
AssignCopyRetMask != ObjCDeclSpec::DQ_PR_weak)
|
AssignCopyRetMask != ObjCPropertyAttribute::kind_retain &&
|
||||||
|
AssignCopyRetMask != ObjCPropertyAttribute::kind_strong &&
|
||||||
|
AssignCopyRetMask != ObjCPropertyAttribute::kind_weak)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
@ -6544,32 +6546,41 @@ void Sema::CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS) {
|
||||||
CodeCompleter->getCodeCompletionTUInfo(),
|
CodeCompleter->getCodeCompletionTUInfo(),
|
||||||
CodeCompletionContext::CCC_Other);
|
CodeCompletionContext::CCC_Other);
|
||||||
Results.EnterNewScope();
|
Results.EnterNewScope();
|
||||||
if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_readonly))
|
if (!ObjCPropertyFlagConflicts(Attributes,
|
||||||
|
ObjCPropertyAttribute::kind_readonly))
|
||||||
Results.AddResult(CodeCompletionResult("readonly"));
|
Results.AddResult(CodeCompletionResult("readonly"));
|
||||||
if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_assign))
|
if (!ObjCPropertyFlagConflicts(Attributes,
|
||||||
|
ObjCPropertyAttribute::kind_assign))
|
||||||
Results.AddResult(CodeCompletionResult("assign"));
|
Results.AddResult(CodeCompletionResult("assign"));
|
||||||
if (!ObjCPropertyFlagConflicts(Attributes,
|
if (!ObjCPropertyFlagConflicts(Attributes,
|
||||||
ObjCDeclSpec::DQ_PR_unsafe_unretained))
|
ObjCPropertyAttribute::kind_unsafe_unretained))
|
||||||
Results.AddResult(CodeCompletionResult("unsafe_unretained"));
|
Results.AddResult(CodeCompletionResult("unsafe_unretained"));
|
||||||
if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_readwrite))
|
if (!ObjCPropertyFlagConflicts(Attributes,
|
||||||
|
ObjCPropertyAttribute::kind_readwrite))
|
||||||
Results.AddResult(CodeCompletionResult("readwrite"));
|
Results.AddResult(CodeCompletionResult("readwrite"));
|
||||||
if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_retain))
|
if (!ObjCPropertyFlagConflicts(Attributes,
|
||||||
|
ObjCPropertyAttribute::kind_retain))
|
||||||
Results.AddResult(CodeCompletionResult("retain"));
|
Results.AddResult(CodeCompletionResult("retain"));
|
||||||
if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_strong))
|
if (!ObjCPropertyFlagConflicts(Attributes,
|
||||||
|
ObjCPropertyAttribute::kind_strong))
|
||||||
Results.AddResult(CodeCompletionResult("strong"));
|
Results.AddResult(CodeCompletionResult("strong"));
|
||||||
if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_copy))
|
if (!ObjCPropertyFlagConflicts(Attributes, ObjCPropertyAttribute::kind_copy))
|
||||||
Results.AddResult(CodeCompletionResult("copy"));
|
Results.AddResult(CodeCompletionResult("copy"));
|
||||||
if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_nonatomic))
|
if (!ObjCPropertyFlagConflicts(Attributes,
|
||||||
|
ObjCPropertyAttribute::kind_nonatomic))
|
||||||
Results.AddResult(CodeCompletionResult("nonatomic"));
|
Results.AddResult(CodeCompletionResult("nonatomic"));
|
||||||
if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_atomic))
|
if (!ObjCPropertyFlagConflicts(Attributes,
|
||||||
|
ObjCPropertyAttribute::kind_atomic))
|
||||||
Results.AddResult(CodeCompletionResult("atomic"));
|
Results.AddResult(CodeCompletionResult("atomic"));
|
||||||
|
|
||||||
// Only suggest "weak" if we're compiling for ARC-with-weak-references or GC.
|
// Only suggest "weak" if we're compiling for ARC-with-weak-references or GC.
|
||||||
if (getLangOpts().ObjCWeak || getLangOpts().getGC() != LangOptions::NonGC)
|
if (getLangOpts().ObjCWeak || getLangOpts().getGC() != LangOptions::NonGC)
|
||||||
if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_weak))
|
if (!ObjCPropertyFlagConflicts(Attributes,
|
||||||
|
ObjCPropertyAttribute::kind_weak))
|
||||||
Results.AddResult(CodeCompletionResult("weak"));
|
Results.AddResult(CodeCompletionResult("weak"));
|
||||||
|
|
||||||
if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_setter)) {
|
if (!ObjCPropertyFlagConflicts(Attributes,
|
||||||
|
ObjCPropertyAttribute::kind_setter)) {
|
||||||
CodeCompletionBuilder Setter(Results.getAllocator(),
|
CodeCompletionBuilder Setter(Results.getAllocator(),
|
||||||
Results.getCodeCompletionTUInfo());
|
Results.getCodeCompletionTUInfo());
|
||||||
Setter.AddTypedTextChunk("setter");
|
Setter.AddTypedTextChunk("setter");
|
||||||
|
@ -6577,7 +6588,8 @@ void Sema::CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS) {
|
||||||
Setter.AddPlaceholderChunk("method");
|
Setter.AddPlaceholderChunk("method");
|
||||||
Results.AddResult(CodeCompletionResult(Setter.TakeString()));
|
Results.AddResult(CodeCompletionResult(Setter.TakeString()));
|
||||||
}
|
}
|
||||||
if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_getter)) {
|
if (!ObjCPropertyFlagConflicts(Attributes,
|
||||||
|
ObjCPropertyAttribute::kind_getter)) {
|
||||||
CodeCompletionBuilder Getter(Results.getAllocator(),
|
CodeCompletionBuilder Getter(Results.getAllocator(),
|
||||||
Results.getCodeCompletionTUInfo());
|
Results.getCodeCompletionTUInfo());
|
||||||
Getter.AddTypedTextChunk("getter");
|
Getter.AddTypedTextChunk("getter");
|
||||||
|
@ -6585,7 +6597,8 @@ void Sema::CodeCompleteObjCPropertyFlags(Scope *S, ObjCDeclSpec &ODS) {
|
||||||
Getter.AddPlaceholderChunk("method");
|
Getter.AddPlaceholderChunk("method");
|
||||||
Results.AddResult(CodeCompletionResult(Getter.TakeString()));
|
Results.AddResult(CodeCompletionResult(Getter.TakeString()));
|
||||||
}
|
}
|
||||||
if (!ObjCPropertyFlagConflicts(Attributes, ObjCDeclSpec::DQ_PR_nullability)) {
|
if (!ObjCPropertyFlagConflicts(Attributes,
|
||||||
|
ObjCPropertyAttribute::kind_nullability)) {
|
||||||
Results.AddResult(CodeCompletionResult("nonnull"));
|
Results.AddResult(CodeCompletionResult("nonnull"));
|
||||||
Results.AddResult(CodeCompletionResult("nullable"));
|
Results.AddResult(CodeCompletionResult("nullable"));
|
||||||
Results.AddResult(CodeCompletionResult("null_unspecified"));
|
Results.AddResult(CodeCompletionResult("null_unspecified"));
|
||||||
|
|
|
@ -1953,7 +1953,8 @@ HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT,
|
||||||
if (const ObjCPropertyDecl *PDecl = Setter->findPropertyDecl()) {
|
if (const ObjCPropertyDecl *PDecl = Setter->findPropertyDecl()) {
|
||||||
// Do not warn if user is using property-dot syntax to make call to
|
// Do not warn if user is using property-dot syntax to make call to
|
||||||
// user named setter.
|
// user named setter.
|
||||||
if (!(PDecl->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_setter))
|
if (!(PDecl->getPropertyAttributes() &
|
||||||
|
ObjCPropertyAttribute::kind_setter))
|
||||||
Diag(MemberLoc,
|
Diag(MemberLoc,
|
||||||
diag::warn_property_access_suggest)
|
diag::warn_property_access_suggest)
|
||||||
<< MemberName << QualType(OPT, 0) << PDecl->getName()
|
<< MemberName << QualType(OPT, 0) << PDecl->getName()
|
||||||
|
@ -3258,7 +3259,7 @@ ExprResult Sema::BuildInstanceMessage(Expr *Receiver,
|
||||||
if (!isImplicit && Method) {
|
if (!isImplicit && Method) {
|
||||||
if (const ObjCPropertyDecl *Prop = Method->findPropertyDecl()) {
|
if (const ObjCPropertyDecl *Prop = Method->findPropertyDecl()) {
|
||||||
bool IsWeak =
|
bool IsWeak =
|
||||||
Prop->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_weak;
|
Prop->getPropertyAttributes() & ObjCPropertyAttribute::kind_weak;
|
||||||
if (!IsWeak && Sel.isUnarySelector())
|
if (!IsWeak && Sel.isUnarySelector())
|
||||||
IsWeak = ReturnType.getObjCLifetime() & Qualifiers::OCL_Weak;
|
IsWeak = ReturnType.getObjCLifetime() & Qualifiers::OCL_Weak;
|
||||||
if (IsWeak && !isUnevaluatedContext() &&
|
if (IsWeak && !isUnevaluatedContext() &&
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -580,7 +580,7 @@ bool ObjCPropertyOpBuilder::isWeakProperty() const {
|
||||||
QualType T;
|
QualType T;
|
||||||
if (RefExpr->isExplicitProperty()) {
|
if (RefExpr->isExplicitProperty()) {
|
||||||
const ObjCPropertyDecl *Prop = RefExpr->getExplicitProperty();
|
const ObjCPropertyDecl *Prop = RefExpr->getExplicitProperty();
|
||||||
if (Prop->getPropertyAttributes() & ObjCPropertyDecl::OBJC_PR_weak)
|
if (Prop->getPropertyAttributes() & ObjCPropertyAttribute::kind_weak)
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
T = Prop->getType();
|
T = Prop->getType();
|
||||||
|
|
|
@ -1280,10 +1280,9 @@ void ASTDeclReader::VisitObjCPropertyDecl(ObjCPropertyDecl *D) {
|
||||||
QualType T = Record.readType();
|
QualType T = Record.readType();
|
||||||
TypeSourceInfo *TSI = readTypeSourceInfo();
|
TypeSourceInfo *TSI = readTypeSourceInfo();
|
||||||
D->setType(T, TSI);
|
D->setType(T, TSI);
|
||||||
D->setPropertyAttributes(
|
D->setPropertyAttributes((ObjCPropertyAttribute::Kind)Record.readInt());
|
||||||
(ObjCPropertyDecl::PropertyAttributeKind)Record.readInt());
|
|
||||||
D->setPropertyAttributesAsWritten(
|
D->setPropertyAttributesAsWritten(
|
||||||
(ObjCPropertyDecl::PropertyAttributeKind)Record.readInt());
|
(ObjCPropertyAttribute::Kind)Record.readInt());
|
||||||
D->setPropertyImplementation(
|
D->setPropertyImplementation(
|
||||||
(ObjCPropertyDecl::PropertyControl)Record.readInt());
|
(ObjCPropertyDecl::PropertyControl)Record.readInt());
|
||||||
DeclarationName GetterName = Record.readDeclarationName();
|
DeclarationName GetterName = Record.readDeclarationName();
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
#include "CursorVisitor.h"
|
#include "CursorVisitor.h"
|
||||||
#include "clang-c/FatalErrorHandler.h"
|
#include "clang-c/FatalErrorHandler.h"
|
||||||
#include "clang/AST/Attr.h"
|
#include "clang/AST/Attr.h"
|
||||||
|
#include "clang/AST/DeclObjCCommon.h"
|
||||||
#include "clang/AST/Mangle.h"
|
#include "clang/AST/Mangle.h"
|
||||||
#include "clang/AST/OpenMPClause.h"
|
#include "clang/AST/OpenMPClause.h"
|
||||||
#include "clang/AST/StmtVisitor.h"
|
#include "clang/AST/StmtVisitor.h"
|
||||||
|
@ -8146,11 +8147,10 @@ unsigned clang_Cursor_getObjCPropertyAttributes(CXCursor C, unsigned reserved) {
|
||||||
|
|
||||||
unsigned Result = CXObjCPropertyAttr_noattr;
|
unsigned Result = CXObjCPropertyAttr_noattr;
|
||||||
const ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(getCursorDecl(C));
|
const ObjCPropertyDecl *PD = dyn_cast<ObjCPropertyDecl>(getCursorDecl(C));
|
||||||
ObjCPropertyDecl::PropertyAttributeKind Attr =
|
ObjCPropertyAttribute::Kind Attr = PD->getPropertyAttributesAsWritten();
|
||||||
PD->getPropertyAttributesAsWritten();
|
|
||||||
|
|
||||||
#define SET_CXOBJCPROP_ATTR(A) \
|
#define SET_CXOBJCPROP_ATTR(A) \
|
||||||
if (Attr & ObjCPropertyDecl::OBJC_PR_##A) \
|
if (Attr & ObjCPropertyAttribute::kind_##A) \
|
||||||
Result |= CXObjCPropertyAttr_##A
|
Result |= CXObjCPropertyAttr_##A
|
||||||
SET_CXOBJCPROP_ATTR(readonly);
|
SET_CXOBJCPROP_ATTR(readonly);
|
||||||
SET_CXOBJCPROP_ATTR(getter);
|
SET_CXOBJCPROP_ATTR(getter);
|
||||||
|
|
|
@ -898,7 +898,8 @@ HANDLE_DW_CFA_PRED(0x2d, AARCH64_negate_ra_state, SELECT_AARCH64)
|
||||||
HANDLE_DW_CFA_PRED(0x2e, GNU_args_size, SELECT_X86)
|
HANDLE_DW_CFA_PRED(0x2e, GNU_args_size, SELECT_X86)
|
||||||
|
|
||||||
// Apple Objective-C Property Attributes.
|
// Apple Objective-C Property Attributes.
|
||||||
// Keep this list in sync with clang's DeclSpec.h ObjCPropertyAttributeKind!
|
// Keep this list in sync with clang's DeclObjCCommon.h
|
||||||
|
// ObjCPropertyAttribute::Kind!
|
||||||
HANDLE_DW_APPLE_PROPERTY(0x01, readonly)
|
HANDLE_DW_APPLE_PROPERTY(0x01, readonly)
|
||||||
HANDLE_DW_APPLE_PROPERTY(0x02, getter)
|
HANDLE_DW_APPLE_PROPERTY(0x02, getter)
|
||||||
HANDLE_DW_APPLE_PROPERTY(0x04, assign)
|
HANDLE_DW_APPLE_PROPERTY(0x04, assign)
|
||||||
|
|
|
@ -357,7 +357,8 @@ enum Constants {
|
||||||
};
|
};
|
||||||
|
|
||||||
/// Constants for the DW_APPLE_PROPERTY_attributes attribute.
|
/// Constants for the DW_APPLE_PROPERTY_attributes attribute.
|
||||||
/// Keep this list in sync with clang's DeclSpec.h ObjCPropertyAttributeKind!
|
/// Keep this list in sync with clang's DeclObjCCommon.h
|
||||||
|
/// ObjCPropertyAttribute::Kind!
|
||||||
enum ApplePropertyAttributes {
|
enum ApplePropertyAttributes {
|
||||||
#define HANDLE_DW_APPLE_PROPERTY(ID, NAME) DW_APPLE_PROPERTY_##NAME = ID,
|
#define HANDLE_DW_APPLE_PROPERTY(ID, NAME) DW_APPLE_PROPERTY_##NAME = ID,
|
||||||
#include "llvm/BinaryFormat/Dwarf.def"
|
#include "llvm/BinaryFormat/Dwarf.def"
|
||||||
|
|
Loading…
Reference in New Issue