llvm/clang/lib/Sema/SemaObjCProperty.cpp

//===--- SemaObjCProperty.cpp - Semantic Analysis for ObjC @property ------===//
//
// 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 implements semantic analysis for Objective C @property and
//  @synthesize declarations.
//
//===----------------------------------------------------------------------===//

#include "clang/AST/ASTMutationListener.h"
#include "clang/AST/DeclObjC.h"
#include "clang/AST/ExprCXX.h"
#include "clang/AST/ExprObjC.h"
#include "clang/Basic/SourceManager.h"
#include "clang/Lex/Lexer.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Sema/Initialization.h"
#include "clang/Sema/SemaInternal.h"
#include "clang/Sema/SemaObjC.h"
#include "llvm/ADT/DenseSet.h"
#include "llvm/ADT/SmallString.h"

usingnamespaceclang;

//===----------------------------------------------------------------------===//
// Grammar actions.
//===----------------------------------------------------------------------===//

/// getImpliedARCOwnership - Given a set of property attributes and a
/// type, infer an expected lifetime.  The type's ownership qualification
/// is not considered.
///
/// Returns OCL_None if the attributes as stated do not imply an ownership.
/// Never returns OCL_Autoreleasing.
static Qualifiers::ObjCLifetime
getImpliedARCOwnership(ObjCPropertyAttribute::Kind attrs, QualType type) {}

/// Check the internal consistency of a property declaration with
/// an explicit ownership qualifier.
static void checkPropertyDeclWithOwnership(Sema &S,
                                           ObjCPropertyDecl *property) {}

/// Check this Objective-C property against a property declared in the
/// given protocol.
static void
CheckPropertyAgainstProtocol(Sema &S, ObjCPropertyDecl *Prop,
                             ObjCProtocolDecl *Proto,
                             llvm::SmallPtrSetImpl<ObjCProtocolDecl *> &Known) {}

static unsigned deducePropertyOwnershipFromType(Sema &S, QualType T) {}

static const unsigned OwnershipMask =;

static unsigned getOwnershipRule(unsigned attr) {}

Decl *SemaObjC::ActOnProperty(Scope *S, SourceLocation AtLoc,
                              SourceLocation LParenLoc, FieldDeclarator &FD,
                              ObjCDeclSpec &ODS, Selector GetterSel,
                              Selector SetterSel,
                              tok::ObjCKeywordKind MethodImplKind,
                              DeclContext *lexicalDC) {}

static ObjCPropertyAttribute::Kind
makePropertyAttributesAsWritten(unsigned Attributes) {}

static bool LocPropertyAttribute( ASTContext &Context, const char *attrName,
                                 SourceLocation LParenLoc, SourceLocation &Loc) {}

/// Check for a mismatch in the atomicity of the given properties.
static void checkAtomicPropertyMismatch(Sema &S,
                                        ObjCPropertyDecl *OldProperty,
                                        ObjCPropertyDecl *NewProperty,
                                        bool PropagateAtomicity) {}

ObjCPropertyDecl *SemaObjC::HandlePropertyInClassExtension(
    Scope *S, SourceLocation AtLoc, SourceLocation LParenLoc,
    FieldDeclarator &FD, Selector GetterSel, SourceLocation GetterNameLoc,
    Selector SetterSel, SourceLocation SetterNameLoc, const bool isReadWrite,
    unsigned &Attributes, const unsigned AttributesAsWritten, QualType T,
    TypeSourceInfo *TSI, tok::ObjCKeywordKind MethodImplKind) {}

ObjCPropertyDecl *SemaObjC::CreatePropertyDecl(
    Scope *S, ObjCContainerDecl *CDecl, SourceLocation AtLoc,
    SourceLocation LParenLoc, FieldDeclarator &FD, Selector GetterSel,
    SourceLocation GetterNameLoc, Selector SetterSel,
    SourceLocation SetterNameLoc, const bool isReadWrite,
    const unsigned Attributes, const unsigned AttributesAsWritten, QualType T,
    TypeSourceInfo *TInfo, tok::ObjCKeywordKind MethodImplKind,
    DeclContext *lexicalDC) {}

static void checkARCPropertyImpl(Sema &S, SourceLocation propertyImplLoc,
                                 ObjCPropertyDecl *property,
                                 ObjCIvarDecl *ivar) {}

/// setImpliedPropertyAttributeForReadOnlyProperty -
/// This routine evaludates life-time attributes for a 'readonly'
/// property with no known lifetime of its own, using backing
/// 'ivar's attribute, if any. If no backing 'ivar', property's
/// life-time is assumed 'strong'.
static void setImpliedPropertyAttributeForReadOnlyProperty(
              ObjCPropertyDecl *property, ObjCIvarDecl *ivar) {}

static bool isIncompatiblePropertyAttribute(unsigned Attr1, unsigned Attr2,
                                            ObjCPropertyAttribute::Kind Kind) {}

static bool areIncompatiblePropertyAttributes(unsigned Attr1, unsigned Attr2,
                                              unsigned Kinds) {}

/// SelectPropertyForSynthesisFromProtocols - Finds the most appropriate
/// property declaration that should be synthesised in all of the inherited
/// protocols. It also diagnoses properties declared in inherited protocols with
/// mismatched types or attributes, since any of them can be candidate for
/// synthesis.
static ObjCPropertyDecl *
SelectPropertyForSynthesisFromProtocols(Sema &S, SourceLocation AtLoc,
                                        ObjCInterfaceDecl *ClassDecl,
                                        ObjCPropertyDecl *Property) {}

/// Determine whether any storage attributes were written on the property.
static bool hasWrittenStorageAttribute(ObjCPropertyDecl *Prop,
                                       ObjCPropertyQueryKind QueryKind) {}

/// Create a synthesized property accessor stub inside the \@implementation.
static ObjCMethodDecl *
RedeclarePropertyAccessor(ASTContext &Context, ObjCImplementationDecl *Impl,
                          ObjCMethodDecl *AccessorDecl, SourceLocation AtLoc,
                          SourceLocation PropertyLoc) {}

/// ActOnPropertyImplDecl - This routine performs semantic checks and
/// builds the AST node for a property implementation declaration; declared
/// as \@synthesize or \@dynamic.
///
Decl *SemaObjC::ActOnPropertyImplDecl(
    Scope *S, SourceLocation AtLoc, SourceLocation PropertyLoc, bool Synthesize,
    IdentifierInfo *PropertyId, IdentifierInfo *PropertyIvar,
    SourceLocation PropertyIvarLoc, ObjCPropertyQueryKind QueryKind) {}

//===----------------------------------------------------------------------===//
// Helper methods.
//===----------------------------------------------------------------------===//

/// DiagnosePropertyMismatch - Compares two properties for their
/// attributes and types and warns on a variety of inconsistencies.
///
void SemaObjC::DiagnosePropertyMismatch(ObjCPropertyDecl *Property,
                                        ObjCPropertyDecl *SuperProperty,
                                        const IdentifierInfo *inheritedName,
                                        bool OverridingProtocolProperty) {}

bool SemaObjC::DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *property,
                                                ObjCMethodDecl *GetterMethod,
                                                SourceLocation Loc) {}

/// CollectImmediateProperties - This routine collects all properties in
/// the class and its conforming protocols; but not those in its super class.
static void
CollectImmediateProperties(ObjCContainerDecl *CDecl,
                           ObjCContainerDecl::PropertyMap &PropMap,
                           ObjCContainerDecl::PropertyMap &SuperPropMap,
                           bool CollectClassPropsOnly = false,
                           bool IncludeProtocols = true) {}

/// CollectSuperClassPropertyImplementations - This routine collects list of
/// properties to be implemented in super class(s) and also coming from their
/// conforming protocols.
static void CollectSuperClassPropertyImplementations(ObjCInterfaceDecl *CDecl,
                                    ObjCInterfaceDecl::PropertyMap &PropMap) {}

/// IvarBacksCurrentMethodAccessor - This routine returns 'true' if 'IV' is
/// an ivar synthesized for 'Method' and 'Method' is a property accessor
/// declared in class 'IFace'.
bool SemaObjC::IvarBacksCurrentMethodAccessor(ObjCInterfaceDecl *IFace,
                                              ObjCMethodDecl *Method,
                                              ObjCIvarDecl *IV) {}

static bool SuperClassImplementsProperty(ObjCInterfaceDecl *IDecl,
                                         ObjCPropertyDecl *Prop) {}

/// Default synthesizes all properties which must be synthesized
/// in class's \@implementation.
void SemaObjC::DefaultSynthesizeProperties(Scope *S, ObjCImplDecl *IMPDecl,
                                           ObjCInterfaceDecl *IDecl,
                                           SourceLocation AtEnd) {}

void SemaObjC::DefaultSynthesizeProperties(Scope *S, Decl *D,
                                           SourceLocation AtEnd) {}

static void DiagnoseUnimplementedAccessor(
    Sema &S, ObjCInterfaceDecl *PrimaryClass, Selector Method,
    ObjCImplDecl *IMPDecl, ObjCContainerDecl *CDecl, ObjCCategoryDecl *C,
    ObjCPropertyDecl *Prop,
    llvm::SmallPtrSet<const ObjCMethodDecl *, 8> &SMap) {}

void SemaObjC::DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl *IMPDecl,
                                               ObjCContainerDecl *CDecl,
                                               bool SynthesizeProperties) {}

void SemaObjC::diagnoseNullResettableSynthesizedSetters(
    const ObjCImplDecl *impDecl) {}

void SemaObjC::AtomicPropertySetterGetterRules(ObjCImplDecl *IMPDecl,
                                               ObjCInterfaceDecl *IDecl) {}

void SemaObjC::DiagnoseOwningPropertyGetterSynthesis(
    const ObjCImplementationDecl *D) {}

void SemaObjC::DiagnoseMissingDesignatedInitOverrides(
    const ObjCImplementationDecl *ImplD, const ObjCInterfaceDecl *IFD) {}

/// AddPropertyAttrs - Propagates attributes from a property to the
/// implicitly-declared getter or setter for that property.
static void AddPropertyAttrs(Sema &S, ObjCMethodDecl *PropertyMethod,
                             ObjCPropertyDecl *Property) {}

/// ProcessPropertyDecl - Make sure that any user-defined setter/getter methods
/// have the property type and issue diagnostics if they don't.
/// Also synthesize a getter/setter method if none exist (and update the
/// appropriate lookup tables.
void SemaObjC::ProcessPropertyDecl(ObjCPropertyDecl *property) {}

void SemaObjC::CheckObjCPropertyAttributes(Decl *PDecl, SourceLocation Loc,
                                           unsigned &Attributes,
                                           bool propertyInPrimaryClass) {}