llvm/clang/lib/Sema/SemaObjC.cpp

//===----- SemaObjC.cpp ---- Semantic Analysis for Objective-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
//
//===----------------------------------------------------------------------===//
/// \file
/// This file implements semantic analysis for Objective-C.
///
//===----------------------------------------------------------------------===//

#include "clang/Sema/SemaObjC.h"
#include "clang/AST/ASTMutationListener.h"
#include "clang/AST/EvaluatedExprVisitor.h"
#include "clang/AST/StmtObjC.h"
#include "clang/Basic/DiagnosticSema.h"
#include "clang/Lex/Preprocessor.h"
#include "clang/Sema/Attr.h"
#include "clang/Sema/Lookup.h"
#include "clang/Sema/ParsedAttr.h"
#include "clang/Sema/ScopeInfo.h"
#include "clang/Sema/Sema.h"
#include "clang/Sema/TemplateDeduction.h"
#include "llvm/Support/ConvertUTF.h"

namespace clang {

SemaObjC::SemaObjC(Sema &S)
    :{}

StmtResult SemaObjC::ActOnObjCForCollectionStmt(SourceLocation ForLoc,
                                                Stmt *First, Expr *collection,
                                                SourceLocation RParenLoc) {}

ExprResult SemaObjC::CheckObjCForCollectionOperand(SourceLocation forLoc,
                                                   Expr *collection) {}

StmtResult SemaObjC::FinishObjCForCollectionStmt(Stmt *S, Stmt *B) {}

StmtResult SemaObjC::ActOnObjCAtCatchStmt(SourceLocation AtLoc,
                                          SourceLocation RParen, Decl *Parm,
                                          Stmt *Body) {}

StmtResult SemaObjC::ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body) {}

StmtResult SemaObjC::ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try,
                                        MultiStmtArg CatchStmts,
                                        Stmt *Finally) {}

StmtResult SemaObjC::BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw) {}

StmtResult SemaObjC::ActOnObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw,
                                          Scope *CurScope) {}

ExprResult SemaObjC::ActOnObjCAtSynchronizedOperand(SourceLocation atLoc,
                                                    Expr *operand) {}

StmtResult SemaObjC::ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc,
                                                 Expr *SyncExpr,
                                                 Stmt *SyncBody) {}

StmtResult SemaObjC::ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc,
                                                  Stmt *Body) {}

TypeResult SemaObjC::actOnObjCProtocolQualifierType(
    SourceLocation lAngleLoc, ArrayRef<Decl *> protocols,
    ArrayRef<SourceLocation> protocolLocs, SourceLocation rAngleLoc) {}

TypeResult SemaObjC::actOnObjCTypeArgsAndProtocolQualifiers(
    Scope *S, SourceLocation Loc, ParsedType BaseType,
    SourceLocation TypeArgsLAngleLoc, ArrayRef<ParsedType> TypeArgs,
    SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc,
    ArrayRef<Decl *> Protocols, ArrayRef<SourceLocation> ProtocolLocs,
    SourceLocation ProtocolRAngleLoc) {}

QualType SemaObjC::BuildObjCTypeParamType(
    const ObjCTypeParamDecl *Decl, SourceLocation ProtocolLAngleLoc,
    ArrayRef<ObjCProtocolDecl *> Protocols,
    ArrayRef<SourceLocation> ProtocolLocs, SourceLocation ProtocolRAngleLoc,
    bool FailOnError) {}

/// Apply Objective-C type arguments to the given type.
static QualType applyObjCTypeArgs(Sema &S, SourceLocation loc, QualType type,
                                  ArrayRef<TypeSourceInfo *> typeArgs,
                                  SourceRange typeArgsRange, bool failOnError,
                                  bool rebuilding) {}

QualType SemaObjC::BuildObjCObjectType(
    QualType BaseType, SourceLocation Loc, SourceLocation TypeArgsLAngleLoc,
    ArrayRef<TypeSourceInfo *> TypeArgs, SourceLocation TypeArgsRAngleLoc,
    SourceLocation ProtocolLAngleLoc, ArrayRef<ObjCProtocolDecl *> Protocols,
    ArrayRef<SourceLocation> ProtocolLocs, SourceLocation ProtocolRAngleLoc,
    bool FailOnError, bool Rebuilding) {}

ParsedType SemaObjC::ActOnObjCInstanceType(SourceLocation Loc) {}

//===--- CHECK: Objective-C retain cycles ----------------------------------//

namespace {

struct RetainCycleOwner {};

} // namespace

/// Consider whether capturing the given variable can possibly lead to
/// a retain cycle.
static bool considerVariable(VarDecl *var, Expr *ref, RetainCycleOwner &owner) {}

static bool findRetainCycleOwner(Sema &S, Expr *e, RetainCycleOwner &owner) {}

namespace {

struct FindCaptureVisitor : EvaluatedExprVisitor<FindCaptureVisitor> {};

} // namespace

/// Check whether the given argument is a block which captures a
/// variable.
static Expr *findCapturingExpr(Sema &S, Expr *e, RetainCycleOwner &owner) {}

static void diagnoseRetainCycle(Sema &S, Expr *capturer,
                                RetainCycleOwner &owner) {}

/// Check for a keyword selector that starts with the word 'add' or
/// 'set'.
static bool isSetterLikeSelector(Selector sel) {}

static std::optional<int>
GetNSMutableArrayArgumentIndex(SemaObjC &S, ObjCMessageExpr *Message) {}

static std::optional<int>
GetNSMutableDictionaryArgumentIndex(SemaObjC &S, ObjCMessageExpr *Message) {}

static std::optional<int> GetNSSetArgumentIndex(SemaObjC &S,
                                                ObjCMessageExpr *Message) {}

void SemaObjC::CheckObjCCircularContainer(ObjCMessageExpr *Message) {}

/// Check a message send to see if it's likely to cause a retain cycle.
void SemaObjC::checkRetainCycles(ObjCMessageExpr *msg) {}

/// Check a property assign to see if it's likely to cause a retain cycle.
void SemaObjC::checkRetainCycles(Expr *receiver, Expr *argument) {}

void SemaObjC::checkRetainCycles(VarDecl *Var, Expr *Init) {}

/// CheckObjCString - Checks that the argument to the builtin
/// CFString constructor is correct
/// Note: It might also make sense to do the UTF-16 conversion here (would
/// simplify the backend).
bool SemaObjC::CheckObjCString(Expr *Arg) {}

bool SemaObjC::CheckObjCMethodCall(ObjCMethodDecl *Method, SourceLocation lbrac,
                                   ArrayRef<const Expr *> Args) {}

const DeclContext *SemaObjC::getCurObjCLexicalContext() const {}

/// Retrieve the identifier "NSError".
IdentifierInfo *SemaObjC::getNSErrorIdent() {}

void SemaObjC::ActOnObjCContainerStartDefinition(ObjCContainerDecl *IDecl) {}

void SemaObjC::ActOnObjCContainerFinishDefinition() {}

void SemaObjC::ActOnObjCTemporaryExitContainerContext(
    ObjCContainerDecl *ObjCCtx) {}

void SemaObjC::ActOnObjCReenterContainerContext(ObjCContainerDecl *ObjCCtx) {}

/// Find the protocol with the given name, if any.
ObjCProtocolDecl *SemaObjC::LookupProtocol(IdentifierInfo *II,
                                           SourceLocation IdLoc,
                                           RedeclarationKind Redecl) {}

/// Determine whether this is an Objective-C writeback conversion,
/// used for parameter passing when performing automatic reference counting.
///
/// \param FromType The type we're converting form.
///
/// \param ToType The type we're converting to.
///
/// \param ConvertedType The type that will be produced after applying
/// this conversion.
bool SemaObjC::isObjCWritebackConversion(QualType FromType, QualType ToType,
                                         QualType &ConvertedType) {}

/// CheckSubscriptingKind - This routine decide what type
/// of indexing represented by "FromE" is being done.
SemaObjC::ObjCSubscriptKind SemaObjC::CheckSubscriptingKind(Expr *FromE) {}

void SemaObjC::AddCFAuditedAttribute(Decl *D) {}

bool SemaObjC::isCFError(RecordDecl *RD) {}

bool SemaObjC::isNSStringType(QualType T, bool AllowNSAttributedString) {}

bool SemaObjC::isCFStringType(QualType T) {}

static bool checkIBOutletCommon(Sema &S, Decl *D, const ParsedAttr &AL) {}

void SemaObjC::handleIBOutlet(Decl *D, const ParsedAttr &AL) {}

void SemaObjC::handleIBOutletCollection(Decl *D, const ParsedAttr &AL) {}

void SemaObjC::handleSuppresProtocolAttr(Decl *D, const ParsedAttr &AL) {}

void SemaObjC::handleDirectAttr(Decl *D, const ParsedAttr &AL) {}

void SemaObjC::handleDirectMembersAttr(Decl *D, const ParsedAttr &AL) {}

void SemaObjC::handleMethodFamilyAttr(Decl *D, const ParsedAttr &AL) {}

void SemaObjC::handleNSObject(Decl *D, const ParsedAttr &AL) {}

void SemaObjC::handleIndependentClass(Decl *D, const ParsedAttr &AL) {}

void SemaObjC::handleBlocksAttr(Decl *D, const ParsedAttr &AL) {}

static bool isValidSubjectOfNSReturnsRetainedAttribute(QualType QT) {}

static bool isValidSubjectOfNSAttribute(QualType QT) {}

static bool isValidSubjectOfCFAttribute(QualType QT) {}

static bool isValidSubjectOfOSAttribute(QualType QT) {}

void SemaObjC::AddXConsumedAttr(Decl *D, const AttributeCommonInfo &CI,
                                Sema::RetainOwnershipKind K,
                                bool IsTemplateInstantiation) {}

Sema::RetainOwnershipKind
SemaObjC::parsedAttrToRetainOwnershipKind(const ParsedAttr &AL) {}

bool SemaObjC::checkNSReturnsRetainedReturnType(SourceLocation Loc,
                                                QualType QT) {}

/// \return whether the parameter is a pointer to OSObject pointer.
bool SemaObjC::isValidOSObjectOutParameter(const Decl *D) {}

void SemaObjC::handleXReturnsXRetainedAttr(Decl *D, const ParsedAttr &AL) {}

void SemaObjC::handleReturnsInnerPointerAttr(Decl *D, const ParsedAttr &Attrs) {}

void SemaObjC::handleRequiresSuperAttr(Decl *D, const ParsedAttr &Attrs) {}

void SemaObjC::handleNSErrorDomain(Decl *D, const ParsedAttr &Attr) {}

void SemaObjC::handleBridgeAttr(Decl *D, const ParsedAttr &AL) {}

void SemaObjC::handleBridgeMutableAttr(Decl *D, const ParsedAttr &AL) {}

void SemaObjC::handleBridgeRelatedAttr(Decl *D, const ParsedAttr &AL) {}

void SemaObjC::handleDesignatedInitializer(Decl *D, const ParsedAttr &AL) {}

void SemaObjC::handleRuntimeName(Decl *D, const ParsedAttr &AL) {}

// When a user wants to use objc_boxable with a union or struct
// but they don't have access to the declaration (legacy/third-party code)
// then they can 'enable' this feature with a typedef:
// typedef struct __attribute((objc_boxable)) legacy_struct legacy_struct;
void SemaObjC::handleBoxable(Decl *D, const ParsedAttr &AL) {}

void SemaObjC::handleOwnershipAttr(Decl *D, const ParsedAttr &AL) {}

void SemaObjC::handlePreciseLifetimeAttr(Decl *D, const ParsedAttr &AL) {}

static bool tryMakeVariablePseudoStrong(Sema &S, VarDecl *VD,
                                        bool DiagnoseFailure) {}

void SemaObjC::handleExternallyRetainedAttr(Decl *D, const ParsedAttr &AL) {}

bool SemaObjC::GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx) {}

/// Diagnose use of %s directive in an NSString which is being passed
/// as formatting string to formatting method.
void SemaObjC::DiagnoseCStringFormatDirectiveInCFAPI(const NamedDecl *FDecl,
                                                     Expr **Args,
                                                     unsigned NumArgs) {}

bool SemaObjC::isSignedCharBool(QualType Ty) {}

void SemaObjC::adornBoolConversionDiagWithTernaryFixit(
    Expr *SourceExpr, const Sema::SemaDiagnosticBuilder &Builder) {}

/// Check a single element within a collection literal against the
/// target element type.
static void checkCollectionLiteralElement(Sema &S, QualType TargetElementType,
                                          Expr *Element, unsigned ElementKind) {}

/// Check an Objective-C array literal being converted to the given
/// target type.
void SemaObjC::checkArrayLiteral(QualType TargetType,
                                 ObjCArrayLiteral *ArrayLiteral) {}

void SemaObjC::checkDictionaryLiteral(
    QualType TargetType, ObjCDictionaryLiteral *DictionaryLiteral) {}

} // namespace clang