clang: lib/Sema/SemaObjC.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

25#include "llvm/Support/ConvertUTF.h"

26

28

35

40 SemaRef.setFunctionHasBranchProtectedScope();

41

44

48 if (!DS->isSingleDecl())

49 return StmtError(Diag((*DS->decl_begin())->getLocation(),

50 diag::err_toomany_element_decls));

51

52 VarDecl *D = dyn_cast(DS->getSingleDecl());

55

57

58

59

62 Diag(D->getLocation(), diag::err_non_local_variable_decl_in_for));

63

64

68 Expr *DeducedInit = &OpaqueId;

75 SemaRef.DiagnoseAutoDeductionFailure(D, DeducedInit);

76 if (FirstType.isNull()) {

79 }

80

82

83 if (SemaRef.inTemplateInstantiation()) {

87 }

88 }

89

90 } else {

94 Diag(First->getBeginLoc(), diag::err_selector_element_not_lvalue)

95 << First->getSourceRange());

96

99 Diag(ForLoc, diag::err_selector_element_const_type)

100 << FirstType << First->getSourceRange();

101 }

105 return StmtError(Diag(ForLoc, diag::err_selector_element_type)

106 << FirstType << First->getSourceRange());

107 }

108

109 if (CollectionExprResult.isInvalid())

111

112 CollectionExprResult = SemaRef.ActOnFinishFullExpr(CollectionExprResult.get(),

113 false);

114 if (CollectionExprResult.isInvalid())

116

118 nullptr, ForLoc, RParenLoc);

119}

120

122 Expr *collection) {

124 if (!collection)

126

127

129 return collection;

130

131

132 ExprResult result = SemaRef.DefaultFunctionArrayLvalueConversion(collection);

135 collection = result.get();

136

137

138

142 return Diag(forLoc, diag::err_collection_expr_type)

144

145

146

149

150

151

152 if (iface &&

154 ? SemaRef.RequireCompleteType(forLoc, QualType(objectType, 0),

155 diag::err_arc_collection_forward,

156 collection)

157 : SemaRef.isCompleteType(forLoc, QualType(objectType, 0)))) {

158

159

160 } else if (iface || !objectType->qual_empty()) {

162 &Context.Idents.get("countByEnumeratingWithState"),

163 &Context.Idents.get("objects"), &Context.Idents.get("count")};

164 Selector selector = Context.Selectors.getSelector(3, &selectorIdents[0]);

165

167

168

169 if (iface) {

171 if (!method)

173 }

174

175

176 if (!method)

178 true);

179

180

181 if (!method) {

182 Diag(forLoc, diag::warn_collection_expr_type)

184 }

185

186

187 }

188

189

190 return collection;

191}

192

194 if (!S || !B)

197

199 return S;

200}

201

204 Stmt *Body) {

206 VarDecl *Var = cast_or_null(Parm);

209

210 return new (Context) ObjCAtCatchStmt(AtLoc, RParen, Var, Body);

211}

212

217

220 Stmt *Finally) {

223 Diag(AtLoc, diag::err_objc_exceptions_disabled) << "@try";

224

225

228 Diag(AtLoc, diag::err_mixing_cxx_try_seh_try) << 1;

229 Diag(FSI->FirstSEHTryLoc, diag::note_conflicting_try_here) << "'__try'";

230 }

231

233 unsigned NumCatchStmts = CatchStmts.size();

235 NumCatchStmts, Finally);

236}

237

240 if (Throw) {

242 if (Result.isInvalid())

244

246 SemaRef.ActOnFinishFullExpr(Result.get(), false);

247 if (Result.isInvalid())

249 Throw = Result.get();

250

252

257 return StmtError(Diag(AtLoc, diag::err_objc_throw_expects_object)

259 }

260 }

261

263}

264

266 Scope *CurScope) {

268 Diag(AtLoc, diag::err_objc_exceptions_disabled) << "@throw";

269

270 if (!Throw) {

271

272

273 Scope *AtCatchParent = CurScope;

274 while (AtCatchParent && !AtCatchParent->isAtCatchScope())

275 AtCatchParent = AtCatchParent->getParent();

276 if (!AtCatchParent)

277 return StmtError(Diag(AtLoc, diag::err_rethrow_used_outside_catch));

278 }

280}

281

283 Expr *operand) {

287 operand = result.get();

288

289

291 if (type->isDependentType() && type->isObjCObjectPointerType()) {

295 if (SemaRef.RequireCompleteType(atLoc, type,

296 diag::err_incomplete_receiver_type))

297 return Diag(atLoc, diag::err_objc_synchronized_expects_object)

299

301 SemaRef.PerformContextuallyConvertToObjCPointer(operand);

305 return Diag(atLoc, diag::err_objc_synchronized_expects_object)

307

308 operand = result.get();

309 } else {

310 return Diag(atLoc, diag::err_objc_synchronized_expects_object)

312 }

313 }

314 }

315

316

317 return SemaRef.ActOnFinishFullExpr(operand, false);

318}

319

321 Expr *SyncExpr,

322 Stmt *SyncBody) {

324

325 SemaRef.setFunctionHasBranchProtectedScope();

327}

328

330 Stmt *Body) {

332 SemaRef.setFunctionHasBranchProtectedScope();

334}

335

340

342 Context.ObjCBuiltinIdTy, {},

344 protocols.size()),

345 false);

346 Result = Context.getObjCObjectPointerType(Result);

347

350

353

354 auto ObjCObjectTL =

357 ObjCObjectTL.getBaseLoc().initialize(Context, SourceLocation());

358

359

362

363

364 ObjCObjectTL.setProtocolLAngleLoc(lAngleLoc);

365 ObjCObjectTL.setProtocolRAngleLoc(rAngleLoc);

366 for (unsigned i = 0, n = protocols.size(); i != n; ++i)

367 ObjCObjectTL.setProtocolLoc(i, protocolLocs[i]);

368

369

370 return SemaRef.CreateParsedType(Result, ResultTInfo);

371}

372

381 QualType T = SemaRef.GetTypeFromParser(BaseType, &BaseTypeInfo);

382 if (T.isNull())

383 return true;

384

385

386 if (!BaseTypeInfo)

387 BaseTypeInfo = Context.getTrivialTypeSourceInfo(T, Loc);

388

389

391 for (unsigned i = 0, n = TypeArgs.size(); i != n; ++i) {

393 QualType TypeArg = SemaRef.GetTypeFromParser(TypeArgs[i], &TypeArgInfo);

394 if (TypeArg.isNull()) {

395 ActualTypeArgInfos.clear();

396 break;

397 }

398

399 assert(TypeArgInfo && "No type source info?");

400 ActualTypeArgInfos.push_back(TypeArgInfo);

401 }

402

403

406 TypeArgsLAngleLoc, ActualTypeArgInfos, TypeArgsRAngleLoc,

407 ProtocolLAngleLoc,

409 Protocols.size()),

410 ProtocolLocs, ProtocolRAngleLoc,

411 false,

412 false);

413

415 return BaseType;

416

417

420

421

422

424

426 ResultTL = ObjCObjectPointerTL.getPointeeLoc();

427 }

428

430

431 if (OTPTL.getNumProtocols() > 0) {

432 assert(OTPTL.getNumProtocols() == Protocols.size());

433 OTPTL.setProtocolLAngleLoc(ProtocolLAngleLoc);

434 OTPTL.setProtocolRAngleLoc(ProtocolRAngleLoc);

435 for (unsigned i = 0, n = Protocols.size(); i != n; ++i)

436 OTPTL.setProtocolLoc(i, ProtocolLocs[i]);

437 }

438

439

440 return SemaRef.CreateParsedType(Result, ResultTInfo);

441 }

442

444

445

446 if (ObjCObjectTL.getNumTypeArgs() > 0) {

447 assert(ObjCObjectTL.getNumTypeArgs() == ActualTypeArgInfos.size());

448 ObjCObjectTL.setTypeArgsLAngleLoc(TypeArgsLAngleLoc);

449 ObjCObjectTL.setTypeArgsRAngleLoc(TypeArgsRAngleLoc);

450 for (unsigned i = 0, n = ActualTypeArgInfos.size(); i != n; ++i)

451 ObjCObjectTL.setTypeArgTInfo(i, ActualTypeArgInfos[i]);

452 } else {

455 }

456

457

458 if (ObjCObjectTL.getNumProtocols() > 0) {

459 assert(ObjCObjectTL.getNumProtocols() == Protocols.size());

460 ObjCObjectTL.setProtocolLAngleLoc(ProtocolLAngleLoc);

461 ObjCObjectTL.setProtocolRAngleLoc(ProtocolRAngleLoc);

462 for (unsigned i = 0, n = Protocols.size(); i != n; ++i)

463 ObjCObjectTL.setProtocolLoc(i, ProtocolLocs[i]);

464 } else {

467 }

468

469

471 if (ObjCObjectTL.getType() == T)

472 ObjCObjectTL.getBaseLoc().initializeFullCopy(BaseTypeInfo->getTypeLoc());

473 else

474 ObjCObjectTL.getBaseLoc().initialize(Context, Loc);

475

476

477 return SemaRef.CreateParsedType(Result, ResultTInfo);

478}

479

484 bool FailOnError) {

487 if (!Protocols.empty()) {

488 bool HasError;

489 Result = Context.applyObjCProtocolQualifiers(Result, Protocols, HasError);

490 if (HasError) {

492 << SourceRange(ProtocolLAngleLoc, ProtocolRAngleLoc);

493 if (FailOnError)

495 }

496 if (FailOnError && Result.isNull())

498 }

499

501}

502

503

506 SourceRange typeArgsRange, bool failOnError,

507 bool rebuilding) {

508

510 if (!objcObjectType || !objcObjectType->getInterface()) {

511 S.Diag(loc, diag::err_objc_type_args_non_class) << type << typeArgsRange;

512

513 if (failOnError)

516 }

517

518

521 if (!typeParams) {

522 S.Diag(loc, diag::err_objc_type_args_non_parameterized_class)

524

525 if (failOnError)

527

529 }

530

531

532 if (objcObjectType->isSpecialized()) {

533 S.Diag(loc, diag::err_objc_type_args_specialized_class)

535

536 if (failOnError)

538

540 }

541

542

544 unsigned numTypeParams = typeParams->size();

545 bool anyPackExpansions = false;

546 for (unsigned i = 0, n = typeArgs.size(); i != n; ++i) {

549

550

551

552

554 bool diagnosed = false;

557 rangeToRemove = attr.getLocalSourceRange();

558 if (attr.getTypePtr()->getImmediateNullability()) {

559 typeArg = attr.getTypePtr()->getModifiedType();

561 diag::err_objc_type_arg_explicit_nullability)

563 diagnosed = true;

564 }

565 }

566

567

568

569 if (!rebuilding && !diagnosed) {

570 S.Diag(qual.getBeginLoc(), diag::err_objc_type_arg_qualified)

573 }

574 }

575

576

578

579 finalTypeArgs.push_back(typeArg);

580

581 if (typeArg->getAs())

582 anyPackExpansions = true;

583

584

586 if (!anyPackExpansions) {

587 if (i < numTypeParams) {

588 typeParam = typeParams->begin()[i];

589 } else {

590

591 S.Diag(loc, diag::err_objc_type_args_wrong_arity)

593 << numTypeParams;

594 S.Diag(objcClass->getLocation(), diag::note_previous_decl) << objcClass;

595

596 if (failOnError)

598

600 }

601 }

602

603

605

606

607

608 if (!typeParam) {

609 assert(anyPackExpansions && "Too many arguments?");

610 continue;

611 }

612

613

616

617

618 if (typeArgObjC->isObjCIdType()) {

619

620

621 if (boundObjC->isObjCIdType())

622 continue;

624

625 continue;

626 }

627

628

630 diag::err_objc_type_arg_does_not_match_bound)

631 << typeArg << bound << typeParam->getDeclName();

632 S.Diag(typeParam->getLocation(), diag::note_objc_type_param_here)

634

635 if (failOnError)

637

639 }

640

641

643

644

645

646 if (!typeParam) {

647 assert(anyPackExpansions && "Too many arguments?");

648 continue;

649 }

650

651

654 continue;

655

656

658 diag::err_objc_type_arg_does_not_match_bound)

659 << typeArg << bound << typeParam->getDeclName();

660 S.Diag(typeParam->getLocation(), diag::note_objc_type_param_here)

662

663 if (failOnError)

665

667 }

668

669

671 continue;

672 }

673

674

676 continue;

677 }

678

679

681 diag::err_objc_type_arg_not_id_compatible)

683

684 if (failOnError)

686

688 }

689

690

691 if (!anyPackExpansions && finalTypeArgs.size() != numTypeParams) {

692 S.Diag(loc, diag::err_objc_type_args_wrong_arity)

693 << (typeArgs.size() < typeParams->size()) << objcClass->getDeclName()

694 << (unsigned)finalTypeArgs.size() << numTypeParams;

695 S.Diag(objcClass->getLocation(), diag::note_previous_decl) << objcClass;

696

697 if (failOnError)

699

701 }

702

703

705}

706

712 bool FailOnError, bool Rebuilding) {

715 if (!TypeArgs.empty()) {

718 SourceRange(TypeArgsLAngleLoc, TypeArgsRAngleLoc),

719 FailOnError, Rebuilding);

720 if (FailOnError && Result.isNull())

722 }

723

724 if (!Protocols.empty()) {

725 bool HasError;

726 Result = Context.applyObjCProtocolQualifiers(Result, Protocols, HasError);

727 if (HasError) {

728 Diag(Loc, diag::err_invalid_protocol_qualifiers)

729 << SourceRange(ProtocolLAngleLoc, ProtocolRAngleLoc);

730 if (FailOnError)

732 }

733 if (FailOnError && Result.isNull())

735 }

736

738}

739

742 QualType T = Context.getObjCInstanceType();

743 TypeSourceInfo *TInfo = Context.getTrivialTypeSourceInfo(T, Loc);

744 return SemaRef.CreateParsedType(T, TInfo);

745}

746

747

748

749namespace {

750

751struct RetainCycleOwner {

752 VarDecl *Variable = nullptr;

755 bool Indirect = false;

756

757 RetainCycleOwner() = default;

758

759 void setLocsFrom(Expr *e) {

762 }

763};

764

765}

766

767

768

770

771

772

774 return false;

775

776 owner.Variable = var;

777 if (ref)

778 owner.setLocsFrom(ref);

779 return true;

780}

781

783 while (true) {

785 if (CastExpr *cast = dyn_cast(e)) {

786 switch (cast->getCastKind()) {

787 case CK_BitCast:

788 case CK_LValueBitCast:

789 case CK_LValueToRValue:

790 case CK_ARCReclaimReturnedObject:

791 e = cast->getSubExpr();

792 continue;

793

794 default:

795 return false;

796 }

797 }

798

799 if (ObjCIvarRefExpr *ref = dyn_cast(e)) {

802 return false;

803

804

806 return false;

807

808 if (ref->isFreeIvar())

809 owner.setLocsFrom(ref);

810 owner.Indirect = true;

811 return true;

812 }

813

814 if (DeclRefExpr *ref = dyn_cast(e)) {

815 VarDecl *var = dyn_cast(ref->getDecl());

816 if (!var)

817 return false;

819 }

820

821 if (MemberExpr *member = dyn_cast(e)) {

822 if (member->isArrow())

823 return false;

824

825

826 e = member->getBase();

827 continue;

828 }

829

830 if (PseudoObjectExpr *pseudo = dyn_cast(e)) {

831

833 pseudo->getSyntacticForm()->IgnoreParens());

834 if (!pre)

835 return false;

837 return false;

839 if (!property->isRetaining() &&

840 !(property->getPropertyIvarDecl() &&

841 property->getPropertyIvarDecl()->getType().getObjCLifetime() ==

843 return false;

844

845 owner.Indirect = true;

848 if (!owner.Variable)

849 return false;

852 return true;

853 }

854 e = const_cast<Expr *>(

856 continue;

857 }

858

859

860

861 return false;

862 }

863}

864

865namespace {

866

867struct FindCaptureVisitor : EvaluatedExprVisitor {

868 VarDecl *Variable;

869 Expr *Capturer = nullptr;

870 bool VarWillBeReased = false;

871

872 FindCaptureVisitor(ASTContext &Context, VarDecl *variable)

873 : EvaluatedExprVisitor(Context), Variable(variable) {}

874

875 void VisitDeclRefExpr(DeclRefExpr *ref) {

876 if (ref->getDecl() == Variable && !Capturer)

877 Capturer = ref;

878 }

879

880 void VisitObjCIvarRefExpr(ObjCIvarRefExpr *ref) {

881 if (Capturer)

882 return;

883 Visit(ref->getBase());

884 if (Capturer && ref->isFreeIvar())

885 Capturer = ref;

886 }

887

888 void VisitBlockExpr(BlockExpr *block) {

889

890 if (block->getBlockDecl()->capturesVariable(Variable))

891 Visit(block->getBlockDecl()->getBody());

892 }

893

894 void VisitOpaqueValueExpr(OpaqueValueExpr *OVE) {

895 if (Capturer)

896 return;

897 if (OVE->getSourceExpr())

898 Visit(OVE->getSourceExpr());

899 }

900

901 void VisitBinaryOperator(BinaryOperator *BinOp) {

902 if (!Variable || VarWillBeReased || BinOp->getOpcode() != BO_Assign)

903 return;

904 Expr *LHS = BinOp->getLHS();

905 if (const DeclRefExpr *DRE = dyn_cast_or_null(LHS)) {

906 if (DRE->getDecl() != Variable)

907 return;

908 if (Expr *RHS = BinOp->getRHS()) {

909 RHS = RHS->IgnoreParenCasts();

910 std::optionalllvm::APSInt Value;

911 VarWillBeReased =

912 (RHS && (Value = RHS->getIntegerConstantExpr(Context)) &&

914 }

915 }

916 }

917};

918

919}

920

921

922

924 assert(owner.Variable && owner.Loc.isValid());

925

927

928

929 if (ObjCMessageExpr *ME = dyn_cast(e)) {

930 Selector Cmd = ME->getSelector();

932 e = ME->getInstanceReceiver();

933 if (!e)

934 return nullptr;

936 }

937 } else if (CallExpr *CE = dyn_cast(e)) {

938 if (CE->getNumArgs() == 1) {

939 FunctionDecl *Fn = dyn_cast_or_null(CE->getCalleeDecl());

940 if (Fn) {

942 if (FnI && FnI->isStr("_Block_copy")) {

944 }

945 }

946 }

947 }

948

949 BlockExpr *block = dyn_cast(e);

951 return nullptr;

952

953 FindCaptureVisitor visitor(S.Context, owner.Variable);

955 return visitor.VarWillBeReased ? nullptr : visitor.Capturer;

956}

957

959 RetainCycleOwner &owner) {

960 assert(capturer);

961 assert(owner.Variable && owner.Loc.isValid());

962

963 S.Diag(capturer->getExprLoc(), diag::warn_arc_retain_cycle)

965 S.Diag(owner.Loc, diag::note_arc_retain_cycle_owner)

966 << owner.Indirect << owner.Range;

967}

968

969

970

973 return false;

974

976 str = str.ltrim('_');

977 if (str.starts_with("set"))

978 str = str.substr(3);

979 else if (str.starts_with("add")) {

980

981 if (sel.getNumArgs() == 1 && str.starts_with("addOperationWithBlock"))

982 return false;

983 str = str.substr(3);

984 } else

985 return false;

986

987 if (str.empty())

988 return true;

990}

991

992static std::optional

994 bool IsMutableArray = S.NSAPIObj->isSubclassOfNSClass(

996 if (!IsMutableArray) {

997 return std::nullopt;

998 }

999

1000 Selector Sel = Message->getSelector();

1001

1002 std::optionalNSAPI::NSArrayMethodKind MKOpt =

1003 S.NSAPIObj->getNSArrayMethodKind(Sel);

1004 if (!MKOpt) {

1005 return std::nullopt;

1006 }

1007

1009

1010 switch (MK) {

1014 return 0;

1016 return 1;

1017

1018 default:

1019 return std::nullopt;

1020 }

1021

1022 return std::nullopt;

1023}

1024

1025static std::optional

1027 bool IsMutableDictionary = S.NSAPIObj->isSubclassOfNSClass(

1029 if (!IsMutableDictionary) {

1030 return std::nullopt;

1031 }

1032

1033 Selector Sel = Message->getSelector();

1034

1035 std::optionalNSAPI::NSDictionaryMethodKind MKOpt =

1036 S.NSAPIObj->getNSDictionaryMethodKind(Sel);

1037 if (!MKOpt) {

1038 return std::nullopt;

1039 }

1040

1042

1043 switch (MK) {

1047 return 0;

1048

1049 default:

1050 return std::nullopt;

1051 }

1052

1053 return std::nullopt;

1054}

1055

1058 bool IsMutableSet = S.NSAPIObj->isSubclassOfNSClass(

1060

1061 bool IsMutableOrderedSet = S.NSAPIObj->isSubclassOfNSClass(

1063 if (!IsMutableSet && !IsMutableOrderedSet) {

1064 return std::nullopt;

1065 }

1066

1067 Selector Sel = Message->getSelector();

1068

1069 std::optionalNSAPI::NSSetMethodKind MKOpt =

1070 S.NSAPIObj->getNSSetMethodKind(Sel);

1071 if (!MKOpt) {

1072 return std::nullopt;

1073 }

1074

1076

1077 switch (MK) {

1082 return 0;

1084 return 1;

1085 }

1086

1087 return std::nullopt;

1088}

1089

1091 if (!Message->isInstanceMessage()) {

1092 return;

1093 }

1094

1095 std::optional ArgOpt;

1096

1100 return;

1101 }

1102

1103 int ArgIndex = *ArgOpt;

1104

1105 Expr *Arg = Message->getArg(ArgIndex)->IgnoreImpCasts();

1106 if (OpaqueValueExpr *OE = dyn_cast(Arg)) {

1108 }

1109

1111 if (DeclRefExpr *ArgRE = dyn_cast(Arg)) {

1112 if (ArgRE->isObjCSelfExpr()) {

1113 Diag(Message->getSourceRange().getBegin(),

1114 diag::warn_objc_circular_container)

1115 << ArgRE->getDecl() << StringRef("'super'");

1116 }

1117 }

1118 } else {

1119 Expr *Receiver = Message->getInstanceReceiver()->IgnoreImpCasts();

1120

1121 if (OpaqueValueExpr *OE = dyn_cast(Receiver)) {

1123 }

1124

1125 if (DeclRefExpr *ReceiverRE = dyn_cast(Receiver)) {

1126 if (DeclRefExpr *ArgRE = dyn_cast(Arg)) {

1127 if (ReceiverRE->getDecl() == ArgRE->getDecl()) {

1129 Diag(Message->getSourceRange().getBegin(),

1130 diag::warn_objc_circular_container)

1132 if (!ArgRE->isObjCSelfExpr()) {

1134 diag::note_objc_circular_container_declared_here)

1136 }

1137 }

1138 }

1139 } else if (ObjCIvarRefExpr *IvarRE = dyn_cast(Receiver)) {

1140 if (ObjCIvarRefExpr *IvarArgRE = dyn_cast(Arg)) {

1141 if (IvarRE->getDecl() == IvarArgRE->getDecl()) {

1143 Diag(Message->getSourceRange().getBegin(),

1144 diag::warn_objc_circular_container)

1147 diag::note_objc_circular_container_declared_here)

1149 }

1150 }

1151 }

1152 }

1153}

1154

1155

1157

1159 return;

1160

1161

1162 RetainCycleOwner owner;

1165 return;

1166 } else {

1168 owner.Variable = SemaRef.getCurMethodDecl()->getSelfDecl();

1171 }

1172

1173

1175 for (unsigned i = 0, e = msg->getNumArgs(); i != e; ++i) {

1177

1178 if (MD && MD->parameters()[i]->hasAttr())

1179 continue;

1181 }

1182 }

1183}

1184

1185

1187 RetainCycleOwner owner;

1189 return;

1190

1193}

1194

1196 RetainCycleOwner Owner;

1198 return;

1199

1200

1201

1204

1207}

1208

1209

1210

1211

1212

1215 StringLiteral *Literal = dyn_cast(Arg);

1216

1217 if (!Literal || !Literal->isOrdinary()) {

1218 Diag(Arg->getBeginLoc(), diag::err_cfstring_literal_not_string_constant)

1220 return true;

1221 }

1222

1223 if (Literal->containsNonAsciiOrNull()) {

1224 StringRef String = Literal->getString();

1225 unsigned NumBytes = String.size();

1227 const llvm::UTF8 *FromPtr = (const llvm::UTF8 *)String.data();

1228 llvm::UTF16 *ToPtr = &ToBuf[0];

1229

1230 llvm::ConversionResult Result =

1231 llvm::ConvertUTF8toUTF16(&FromPtr, FromPtr + NumBytes, &ToPtr,

1232 ToPtr + NumBytes, llvm::strictConversion);

1233

1234 if (Result != llvm::conversionOK)

1237 }

1238 return false;

1239}

1240

1246

1247 SemaRef.checkCall(Method, nullptr, nullptr, Args,

1248 false, lbrac, Method->getSourceRange(),

1249 CallType);

1250

1252

1253 return false;

1254}

1255

1258

1259 if (const ObjCCategoryDecl *CatD = dyn_cast(DC))

1260 DC = CatD->getClassInterface();

1261 return DC;

1262}

1263

1264

1266 if (!Ident_NSError)

1267 Ident_NSError = SemaRef.PP.getIdentifierInfo("NSError");

1268

1269 return Ident_NSError;

1270}

1271

1273 assert(

1275 "The next DeclContext should be lexically contained in the current one.");

1276 SemaRef.CurContext = IDecl;

1277}

1278

1280

1281 SemaRef.PopDeclContext();

1282}

1283

1286 assert(ObjCCtx == SemaRef.CurContext && "Mismatch of container contexts");

1287 SemaRef.OriginalLexicalContext = ObjCCtx;

1289}

1290

1293 SemaRef.OriginalLexicalContext = nullptr;

1294}

1295

1296

1302 return cast_or_null(D);

1303}

1304

1305

1306

1307

1308

1309

1310

1311

1312

1313

1318 Context.hasSameUnqualifiedType(FromType, ToType))

1319 return false;

1320

1321

1325 else

1326 return false;

1327

1332 return false;

1333

1334

1338 else

1339 return false;

1340

1345 return false;

1346

1347

1350 return false;

1351

1352

1353

1354

1356

1357

1359 bool IncompatibleObjC;

1360 if (Context.typesAreCompatible(FromPointee, ToPointee))

1361 FromPointee = ToPointee;

1362 else if (SemaRef.isObjCPointerConversion(FromPointee, ToPointee, FromPointee,

1363 IncompatibleObjC))

1364 return false;

1365

1366

1367

1368 FromPointee = Context.getQualifiedType(FromPointee, FromQuals);

1369 ConvertedType = Context.getPointerType(FromPointee);

1370 return true;

1371}

1372

1373

1374

1376

1378 if (T->isIntegralOrEnumerationType())

1380

1381

1382

1383 const RecordType *RecordTy = T->getAsCanonical();

1384 if (!RecordTy && (T->isObjCObjectPointerType() || T->isVoidPointerType()))

1385

1386

1388 if (getLangOpts().CPlusPlus || !RecordTy || RecordTy->isIncompleteType()) {

1389

1392 Diag(FromE->getExprLoc(), diag::err_objc_subscript_pointer)

1394 else

1395 Diag(FromE->getExprLoc(), diag::err_objc_subscript_type_conversion) << T;

1397 }

1398

1399

1401 diag::err_objc_index_incomplete_class_type,

1402 FromE))

1404

1405

1406

1407 int NoIntegrals = 0, NoObjCIdPointers = 0;

1409

1411 ->getDefinitionOrSelf()

1412 ->getVisibleConversionFunctions()) {

1414 dyn_cast(D->getUnderlyingDecl())) {

1415 QualType CT = Conversion->getConversionType().getNonReferenceType();

1417 ++NoIntegrals;

1418 ConversionDecls.push_back(Conversion);

1420 ++NoObjCIdPointers;

1421 ConversionDecls.push_back(Conversion);

1422 }

1423 }

1424 }

1425 if (NoIntegrals == 1 && NoObjCIdPointers == 0)

1427 if (NoIntegrals == 0 && NoObjCIdPointers == 1)

1429 if (NoIntegrals == 0 && NoObjCIdPointers == 0) {

1430

1431 Diag(FromE->getExprLoc(), diag::err_objc_subscript_type_conversion)

1434 }

1435 Diag(FromE->getExprLoc(), diag::err_objc_multiple_subscript_type_conversion)

1437 for (unsigned int i = 0; i < ConversionDecls.size(); i++)

1438 Diag(ConversionDecls[i]->getLocation(),

1439 diag::note_conv_function_declared_at);

1440

1442}

1443

1446 auto IdLoc = SemaRef.PP.getPragmaARCCFCodeAuditedInfo();

1447 if (!IdLoc.getLoc().isValid())

1448 return;

1449

1450

1451 if (D->hasAttr() ||

1452 D->hasAttr())

1453 return;

1454

1458 D->addAttr(CFAuditedTransferAttr::CreateImplicit(Context, Info));

1459}

1460

1462

1465

1466

1467

1468

1469

1472 if (auto bridgeAttr = RD->getAttr())

1473 bridgedType = bridgeAttr->getBridgedType();

1474 else if (auto bridgeAttr = RD->getAttr())

1475 bridgedType = bridgeAttr->getBridgedType();

1476

1479 return true;

1480 }

1481 }

1482

1483 return false;

1484}

1485

1488 if (!PT)

1489 return false;

1490

1492 if (!Cls)

1493 return false;

1494

1496

1497 if (AllowNSAttributedString &&

1498 ClsName == &getASTContext().Idents.get("NSAttributedString"))

1499 return true;

1500

1503}

1504

1507 if (!PT)

1508 return false;

1509

1511 if (!RT)

1512 return false;

1513

1514 const RecordDecl *RD = RT->getDecl();

1516 return false;

1517

1519}

1520

1522

1523

1524

1525 if (const auto *VD = dyn_cast(D)) {

1527 S.Diag(AL.getLoc(), diag::warn_iboutlet_object_type)

1528 << AL << VD->getType() << 0;

1529 return false;

1530 }

1531 } else if (const auto *PD = dyn_cast(D)) {

1533 S.Diag(AL.getLoc(), diag::warn_iboutlet_object_type)

1534 << AL << PD->getType() << 1;

1535 return false;

1536 }

1537 } else {

1538 S.Diag(AL.getLoc(), diag::warn_attribute_iboutlet) << AL;

1539 return false;

1540 }

1541

1542 return true;

1543}

1544

1551

1553

1555

1557 Diag(AL.getLoc(), diag::err_attribute_wrong_number_arguments) << AL << 1;

1558 return;

1559 }

1560

1562 return;

1563

1565

1568 else {

1569 PT = SemaRef.getTypeName(

1570 Context.Idents.get("NSObject"), AL.getLoc(),

1572 if (!PT) {

1573 Diag(AL.getLoc(), diag::err_iboutletcollection_type) << "NSObject";

1574 return;

1575 }

1576 }

1577

1580 if (!QTLoc)

1581 QTLoc = Context.getTrivialTypeSourceInfo(QT, AL.getLoc());

1582

1583

1584

1585

1586

1589 ? diag::err_iboutletcollection_builtintype

1590 : diag::err_iboutletcollection_type)

1591 << QT;

1592 return;

1593 }

1594

1595 D->addAttr(::new (Context) IBOutletCollectionAttr(Context, AL, QTLoc));

1596}

1597

1600 Diag(AL.getLoc(), diag::err_objc_attr_protocol_requires_definition)

1602 return;

1603 }

1604

1606 ObjCExplicitProtocolImplAttr(getASTContext(), AL));

1607}

1608

1610

1612 Diag(AL.getLoc(), diag::err_objc_direct_on_protocol) << false;

1613 return;

1614 }

1615

1618 } else {

1619 Diag(AL.getLoc(), diag::warn_objc_direct_ignored) << AL;

1620 }

1621}

1622

1626 } else {

1627 Diag(AL.getLoc(), diag::warn_objc_direct_ignored) << AL;

1628 }

1629}

1630

1634 Diag(AL.getLoc(), diag::err_attribute_argument_n_type)

1636 return;

1637 }

1638

1640 ObjCMethodFamilyAttr::FamilyKind F;

1641 if (!ObjCMethodFamilyAttr::ConvertStrToFamilyKind(

1643 Diag(IL->getLoc(), diag::warn_attribute_type_not_supported)

1645 return;

1646 }

1647

1648 if (F == ObjCMethodFamilyAttr::OMF_init &&

1649 !M->getReturnType()->isObjCObjectPointerType()) {

1650 Diag(M->getLocation(), diag::err_init_method_bad_return_type)

1651 << M->getReturnType();

1652

1653 return;

1654 }

1655

1658}

1659

1661 if (const auto *TD = dyn_cast(D)) {

1662 QualType T = TD->getUnderlyingType();

1663 if (T->isCARCBridgableType()) {

1664 Diag(TD->getLocation(), diag::err_nsobject_attribute);

1665 return;

1666 }

1667 } else if (const auto *PD = dyn_cast(D)) {

1669 if (T->isCARCBridgableType()) {

1670 Diag(PD->getLocation(), diag::err_nsobject_attribute);

1671 return;

1672 }

1673 } else {

1674

1675

1676

1677

1678

1679

1681 }

1683}

1684

1686 if (const auto *TD = dyn_cast(D)) {

1687 QualType T = TD->getUnderlyingType();

1688 if (T->isObjCObjectPointerType()) {

1689 Diag(TD->getLocation(), diag::warn_ptr_independentclass_attribute);

1690 return;

1691 }

1692 } else {

1693 Diag(D->getLocation(), diag::warn_independentclass_attribute);

1694 return;

1695 }

1698}

1699

1702 Diag(AL.getLoc(), diag::err_attribute_argument_n_type)

1704 return;

1705 }

1706

1708 BlocksAttr::BlockType type;

1709 if (!BlocksAttr::ConvertStrToBlockType(II->getName(), type)) {

1710 Diag(AL.getLoc(), diag::warn_attribute_type_not_supported) << AL << II;

1711 return;

1712 }

1713

1715}

1716

1720

1725

1730

1737

1740 bool IsTemplateInstantiation) {

1742 switch (K) {

1746 diag::warn_ns_attribute_wrong_parameter_type,

1747 CI.getRange(), "os_consumed", 1);

1748 return;

1752

1753

1754

1755

1756

1757 ((IsTemplateInstantiation && getLangOpts().ObjCAutoRefCount)

1758 ? diag::err_ns_attribute_wrong_parameter_type

1759 : diag::warn_ns_attribute_wrong_parameter_type),

1760 CI.getRange(), "ns_consumed", 0);

1761 return;

1765 diag::warn_ns_attribute_wrong_parameter_type,

1766 CI.getRange(), "cf_consumed", 1);

1767 return;

1768 }

1769}

1770

1774 case ParsedAttr::AT_CFConsumed:

1775 case ParsedAttr::AT_CFReturnsRetained:

1776 case ParsedAttr::AT_CFReturnsNotRetained:

1778 case ParsedAttr::AT_OSConsumesThis:

1779 case ParsedAttr::AT_OSConsumed:

1780 case ParsedAttr::AT_OSReturnsRetained:

1781 case ParsedAttr::AT_OSReturnsNotRetained:

1782 case ParsedAttr::AT_OSReturnsRetainedOnZero:

1783 case ParsedAttr::AT_OSReturnsRetainedOnNonZero:

1785 case ParsedAttr::AT_NSConsumesSelf:

1786 case ParsedAttr::AT_NSConsumed:

1787 case ParsedAttr::AT_NSReturnsRetained:

1788 case ParsedAttr::AT_NSReturnsNotRetained:

1789 case ParsedAttr::AT_NSReturnsAutoreleased:

1791 default:

1792 llvm_unreachable("Wrong argument supplied");

1793 }

1794}

1795

1799 return false;

1800

1801 Diag(Loc, diag::warn_ns_attribute_wrong_return_type)

1802 << "'ns_returns_retained'" << 0 << 0;

1803 return true;

1804}

1805

1806

1808 const auto *PVD = dyn_cast(D);

1809 if (!PVD)

1810 return false;

1811 QualType QT = PVD->getType();

1814}

1815

1819

1820 if (const auto *MD = dyn_cast(D)) {

1821 ReturnType = MD->getReturnType();

1823 (AL.getKind() == ParsedAttr::AT_NSReturnsRetained)) {

1824 return;

1825 } else if (const auto *PD = dyn_cast(D)) {

1826 ReturnType = PD->getType();

1827 } else if (const auto *FD = dyn_cast(D)) {

1828 ReturnType = FD->getReturnType();

1829 } else if (const auto *Param = dyn_cast(D)) {

1830

1831

1833 ? 2

1834 : 3;

1836 if (ReturnType.isNull()) {

1837 Diag(D->getBeginLoc(), diag::warn_ns_attribute_wrong_parameter_type)

1838 << AL << DiagID << AL.getRange();

1839 return;

1840 }

1842 return;

1843 } else {

1846 default:

1847 llvm_unreachable("invalid ownership attribute");

1848 case ParsedAttr::AT_NSReturnsRetained:

1849 case ParsedAttr::AT_NSReturnsAutoreleased:

1850 case ParsedAttr::AT_NSReturnsNotRetained:

1852 break;

1853

1854 case ParsedAttr::AT_OSReturnsRetained:

1855 case ParsedAttr::AT_OSReturnsNotRetained:

1856 case ParsedAttr::AT_CFReturnsRetained:

1857 case ParsedAttr::AT_CFReturnsNotRetained:

1859 break;

1860 }

1861 Diag(D->getBeginLoc(), diag::warn_attribute_wrong_decl_type)

1863 << ExpectedDeclKind;

1864 return;

1865 }

1866

1867 bool TypeOK;

1868 bool Cf;

1869 unsigned ParmDiagID = 2;

1871 default:

1872 llvm_unreachable("invalid ownership attribute");

1873 case ParsedAttr::AT_NSReturnsRetained:

1875 Cf = false;

1876 break;

1877

1878 case ParsedAttr::AT_NSReturnsAutoreleased:

1879 case ParsedAttr::AT_NSReturnsNotRetained:

1881 Cf = false;

1882 break;

1883

1884 case ParsedAttr::AT_CFReturnsRetained:

1885 case ParsedAttr::AT_CFReturnsNotRetained:

1887 Cf = true;

1888 break;

1889

1890 case ParsedAttr::AT_OSReturnsRetained:

1891 case ParsedAttr::AT_OSReturnsNotRetained:

1893 Cf = true;

1894 ParmDiagID = 3;

1895 break;

1896 }

1897

1898 if (!TypeOK) {

1900 return;

1901

1903 Diag(D->getBeginLoc(), diag::warn_ns_attribute_wrong_parameter_type)

1904 << AL << ParmDiagID << AL.getRange();

1905 } else {

1906

1909 SubjectKind = Method;

1912 Diag(D->getBeginLoc(), diag::warn_ns_attribute_wrong_return_type)

1913 << AL << SubjectKind << Cf << AL.getRange();

1914 }

1915 return;

1916 }

1917

1919 default:

1920 llvm_unreachable("invalid ownership attribute");

1921 case ParsedAttr::AT_NSReturnsAutoreleased:

1923 return;

1924 case ParsedAttr::AT_CFReturnsNotRetained:

1926 return;

1927 case ParsedAttr::AT_NSReturnsNotRetained:

1929 return;

1930 case ParsedAttr::AT_CFReturnsRetained:

1932 return;

1933 case ParsedAttr::AT_NSReturnsRetained:

1935 return;

1936 case ParsedAttr::AT_OSReturnsRetained:

1938 return;

1939 case ParsedAttr::AT_OSReturnsNotRetained:

1941 return;

1942 };

1943}

1944

1946 const int EP_ObjCMethod = 1;

1947 const int EP_ObjCProperty = 2;

1948

1953 else

1955

1958 Diag(D->getBeginLoc(), diag::warn_ns_attribute_wrong_return_type)

1961 << 2;

1962

1963

1964 return;

1965 }

1966

1968 ObjCReturnsInnerPointerAttr(getASTContext(), Attrs));

1969}

1970

1973

1975 if (const auto *PDecl = dyn_cast_if_present(DC)) {

1976 Diag(D->getBeginLoc(), diag::warn_objc_requires_super_protocol)

1977 << Attrs << 0;

1978 Diag(PDecl->getLocation(), diag::note_protocol_decl);

1979 return;

1980 }

1982 Diag(D->getBeginLoc(), diag::warn_objc_requires_super_protocol)

1983 << Attrs << 1;

1984 return;

1985 }

1986

1989}

1990

1993 Diag(D->getBeginLoc(), diag::err_nserrordomain_invalid_decl) << 0;

1994 return;

1995 }

1996

1998 Attr.isArgIdent(0) ? Attr.getArgAsIdent(0) : nullptr;

2000

2002 if (Attr.isArgExpr(0) && Attr.getArgAsExpr(0))

2003 Loc = Attr.getArgAsExpr(0)->getBeginLoc();

2004

2005 Diag(Loc, diag::err_nserrordomain_invalid_decl) << 0;

2006 return;

2007 }

2008

2009

2015 Diag(IdentLoc->getLoc(), diag::err_nserrordomain_invalid_decl)

2017 return;

2018 }

2019

2022}

2023

2026

2027 if (!Parm) {

2028 Diag(D->getBeginLoc(), diag::err_objc_attr_not_id) << AL << 0;

2029 return;

2030 }

2031

2032

2033 if (const auto *TD = dyn_cast(D)) {

2035 Diag(AL.getLoc(), diag::err_objc_attr_typedef_not_id) << AL;

2036 return;

2037 }

2038

2039

2040 QualType T = TD->getUnderlyingType();

2041 if (T->isVoidPointerType()) {

2042 Diag(AL.getLoc(), diag::err_objc_attr_typedef_not_void_pointer);

2043 return;

2044 }

2045 }

2046

2049}

2050

2053

2054 if (!Parm) {

2055 Diag(D->getBeginLoc(), diag::err_objc_attr_not_id) << AL << 0;

2056 return;

2057 }

2058

2061}

2062

2066 if (!RelatedClass) {

2067 Diag(D->getBeginLoc(), diag::err_objc_attr_not_id) << AL << 0;

2068 return;

2069 }

2075 getASTContext(), AL, RelatedClass, ClassMethod, InstanceMethod));

2076}

2077

2080

2081

2082

2086 Diag(D->getLocation(), diag::err_designated_init_attr_non_init);

2087 return;

2088 }

2089

2091 if (auto *CatDecl = dyn_cast(Ctx))

2092 IFace = CatDecl->getClassInterface();

2093 else

2095

2096 if (!IFace)

2097 return;

2098

2101 ObjCDesignatedInitializerAttr(getASTContext(), AL));

2102}

2103

2105 StringRef MetaDataName;

2106 if (SemaRef.checkStringLiteralArgumentAttr(AL, 0, MetaDataName))

2107 return;

2109 ObjCRuntimeNameAttr(getASTContext(), AL, MetaDataName));

2110}

2111

2112

2113

2114

2115

2117 bool notify = false;

2118

2119 auto *RD = dyn_cast(D);

2120 if (RD && RD->getDefinition()) {

2121 RD = RD->getDefinition();

2122 notify = true;

2123 }

2124

2125 if (RD) {

2126 ObjCBoxableAttr *BoxableAttr =

2128 RD->addAttr(BoxableAttr);

2129 if (notify) {

2130

2131

2133 L->AddedAttributeToRecord(BoxableAttr, RD);

2134 }

2135 }

2136}

2137

2140 return;

2141

2142 Diag(D->getBeginLoc(), diag::err_attribute_wrong_decl_type)

2145}

2146

2149 QualType QT = VD->getType();

2150

2152 Diag(AL.getLoc(), diag::err_objc_precise_lifetime_bad_type) << QT;

2153 return;

2154 }

2155

2157

2158

2159

2162

2163 switch (Lifetime) {

2166 "didn't infer lifetime for non-dependent type?");

2167 break;

2168

2171 break;

2172

2175 Diag(AL.getLoc(), diag::warn_objc_precise_lifetime_meaningless)

2177 break;

2178 }

2179

2182}

2183

2185 bool DiagnoseFailure) {

2188 if (DiagnoseFailure) {

2189 S.Diag(VD->getBeginLoc(), diag::warn_ignored_objc_externally_retained)

2190 << 0;

2191 }

2192 return false;

2193 }

2194

2196

2197

2198

2199

2202

2203

2204

2206 if (DiagnoseFailure) {

2207 S.Diag(VD->getBeginLoc(), diag::warn_ignored_objc_externally_retained)

2208 << 1;

2209 }

2210 return false;

2211 }

2212

2213

2214

2215

2218 return true;

2219}

2220

2222 if (auto *VD = dyn_cast(D)) {

2223 assert(isa<ParmVarDecl>(VD) && "should be diagnosed automatically");

2224 if (!VD->hasLocalStorage()) {

2225 Diag(D->getBeginLoc(), diag::warn_ignored_objc_externally_retained) << 0;

2226 return;

2227 }

2228

2230 return;

2231

2233 return;

2234 }

2235

2236

2237

2238 unsigned NumParams =

2240 for (unsigned I = 0; I != NumParams; ++I) {

2242 QualType Ty = PVD->getType();

2243

2244

2245

2246

2247

2250 continue;

2251

2253 }

2255}

2256

2260 SemaRef.getFormatStringInfo(Format->getFormatIdx(), Format->getFirstArg(),

2261 false, true, &FSI)) {

2263 return true;

2264 }

2265 return false;

2266}

2267

2268

2269

2271 Expr **Args,

2272 unsigned NumArgs) {

2273 unsigned Idx = 0;

2274 bool Format = false;

2277 Idx = 2;

2278 Format = true;

2279 } else

2280 for (const auto *I : FDecl->specific_attrs()) {

2282 Format = true;

2283 break;

2284 }

2285 }

2286 if (!Format || NumArgs <= Idx)

2287 return;

2288 const Expr *FormatExpr = Args[Idx];

2289 if (const CStyleCastExpr *CSCE = dyn_cast(FormatExpr))

2290 FormatExpr = CSCE->getSubExpr();

2294 FormatString = OSL->getString();

2295 else

2296 FormatString = dyn_cast(FormatExpr->IgnoreParenImpCasts());

2297 if (!FormatString)

2298 return;

2299 if (SemaRef.FormatStringHasSArg(FormatString)) {

2300 Diag(FormatExpr->getExprLoc(), diag::warn_objc_cdirective_format_string)

2301 << "%s" << 1 << 1;

2302 Diag(FDecl->getLocation(), diag::note_entity_declared_at)

2304 }

2305}

2306

2309 NSAPIObj->isObjCBOOLType(Ty);

2310}

2311

2315 if (const auto *OVE = dyn_cast(Ignored))

2316 Ignored = OVE->getSourceExpr();

2321 if (NeedsParens)

2325}

2326

2327

2328

2330 Expr *Element, unsigned ElementKind) {

2331

2332 if (auto ICE = dyn_cast(Element)) {

2333 if (ICE->getCastKind() == CK_BitCast &&

2335 Element = ICE->getSubExpr();

2336 }

2337

2342 TargetElementType, ElementResult, false, false))) {

2343 S.Diag(Element->getBeginLoc(), diag::warn_objc_collection_literal_element)

2344 << ElementType << ElementKind << TargetElementType

2346 }

2347

2348 if (auto ArrayLiteral = dyn_cast(Element))

2350 else if (auto DictionaryLiteral = dyn_cast(Element))

2352}

2353

2354

2355

2359 return;

2360

2362 if (!TargetObjCPtr)

2363 return;

2364

2365 if (TargetObjCPtr->isUnspecialized() ||

2366 TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl() !=

2368 return;

2369

2370 auto TypeArgs = TargetObjCPtr->getTypeArgs();

2371 if (TypeArgs.size() != 1)

2372 return;

2373

2374 QualType TargetElementType = TypeArgs[0];

2375 for (unsigned I = 0, N = ArrayLiteral->getNumElements(); I != N; ++I) {

2378 }

2379}

2380

2384 return;

2385

2387 if (!TargetObjCPtr)

2388 return;

2389

2390 if (TargetObjCPtr->isUnspecialized() ||

2391 TargetObjCPtr->getInterfaceDecl()->getCanonicalDecl() !=

2393 return;

2394

2395 auto TypeArgs = TargetObjCPtr->getTypeArgs();

2396 if (TypeArgs.size() != 2)

2397 return;

2398

2399 QualType TargetKeyType = TypeArgs[0];

2400 QualType TargetObjectType = TypeArgs[1];

2401 for (unsigned I = 0, N = DictionaryLiteral->getNumElements(); I != N; ++I) {

2405 }

2406}

2407

2408}

TokenType getType() const

Returns the token's type, e.g.

Defines the clang::Preprocessor interface.

RedeclarationKind

Specifies whether (or how) name lookup is being performed for a redeclaration (vs.

This file declares semantic analysis for Objective-C.

Defines the Objective-C statement AST node classes.

Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...

Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...

bool canAssignObjCInterfaces(const ObjCObjectPointerType *LHSOPT, const ObjCObjectPointerType *RHSOPT)

canAssignObjCInterfaces - Return true if the two interface types are compatible for assignment from R...

QualType getObjCObjectType(QualType Base, ObjCProtocolDecl *const *Protocols, unsigned NumProtocols) const

Legacy interface: cannot provide type arguments or __kindof.

An abstract interface that should be implemented by listeners that want to be notified when an AST en...

Attr - This represents one attribute.

SourceRange getRange() const

bool isRegularKeywordAttribute() const

SourceLocation getLoc() const

Type source information for an attributed type.

Stmt * getBody() const override

getBody - If this Decl represents a declaration for a body of code, such as a function or method defi...

bool capturesVariable(const VarDecl *var) const

BlockExpr - Adaptor class for mixing a BlockDecl with expressions.

const BlockDecl * getBlockDecl() const

CStyleCastExpr - An explicit cast in C (C99 6.5.4) or a C-style cast in C++ (C++ [expr....

Represents a C++ conversion function within a class.

CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).

CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...

DeclContext - This is used only as base class of specific decl types that can act as declaration cont...

DeclContext * getParent()

getParent - Returns the containing DeclContext.

DeclContext * getLexicalParent()

getLexicalParent - Returns the containing lexical DeclContext.

A reference to a declared variable, function, enum, etc.

DeclStmt - Adaptor class for mixing declarations with statements and expressions.

Decl - This represents one declaration (or definition), e.g.

void setInvalidDecl(bool Invalid=true)

setInvalidDecl - Indicates the Decl had a semantic error.

bool isInvalidDecl() const

llvm::iterator_range< specific_attr_iterator< T > > specific_attrs() const

SourceLocation getLocation() const

DeclContext * getDeclContext()

SourceLocation getBeginLoc() const LLVM_READONLY

The name of a declaration.

SourceLocation getBeginLoc() const LLVM_READONLY

TypeSourceInfo * getTypeSourceInfo() const

This represents one expression.

Expr * IgnoreParenCasts() LLVM_READONLY

Skip past any parentheses and casts which might surround this expression until reaching a fixed point...

bool isTypeDependent() const

Determines whether the type of this expression depends on.

Expr * IgnoreParenImpCasts() LLVM_READONLY

Skip past any parentheses and implicit casts which might surround this expression until reaching a fi...

Expr * IgnoreImplicit() LLVM_READONLY

Skip past any implicit AST nodes which might surround this expression until reaching a fixed point.

Expr * IgnoreParens() LLVM_READONLY

Skip past any parentheses which might surround this expression until reaching a fixed point.

bool isLValue() const

isLValue - True if this expression is an "l-value" according to the rules of the current language.

Expr * IgnoreImpCasts() LLVM_READONLY

Skip past any implicit casts which might surround this expression until reaching a fixed point.

SourceLocation getExprLoc() const LLVM_READONLY

getExprLoc - Return the preferred location for the arrow when diagnosing a problem with a generic exp...

static FixItHint CreateRemoval(CharSourceRange RemoveRange)

Create a code modification hint that removes the given source range.

static FixItHint CreateInsertion(SourceLocation InsertionLoc, StringRef Code, bool BeforePreviousInsertions=false)

Create a code modification hint that inserts the given code string at a specific location.

ForStmt - This represents a 'for (init;cond;inc)' stmt.

Represents a function declaration or definition.

One of these records is kept for each identifier that is lexed.

bool isStr(const char(&Str)[StrLen]) const

Return true if this is the identifier for the specified string.

StringRef getName() const

Return the actual identifier string.

A simple pair of identifier info and location.

SourceLocation getLoc() const

IdentifierInfo * getIdentifierInfo() const

IdentifierInfo & get(StringRef Name)

Return the identifier token info for the specified named identifier.

Represents the results of name lookup.

MemberExpr - [C99 6.5.2.3] Structure and Union Members.

@ ClassId_NSMutableOrderedSet

@ ClassId_NSMutableDictionary

NSSetMethodKind

Enumerates the NSMutableSet/NSOrderedSet methods used to apply some checks.

@ NSOrderedSet_setObjectAtIndex

@ NSOrderedSet_replaceObjectAtIndexWithObject

@ NSOrderedSet_setObjectAtIndexedSubscript

@ NSOrderedSet_insertObjectAtIndex

NSDictionaryMethodKind

Enumerates the NSDictionary/NSMutableDictionary methods used to generate literals and to apply some c...

@ NSMutableDict_setValueForKey

@ NSMutableDict_setObjectForKey

@ NSMutableDict_setObjectForKeyedSubscript

NSArrayMethodKind

Enumerates the NSArray/NSMutableArray methods used to generate literals and to apply some checks.

@ NSMutableArr_setObjectAtIndexedSubscript

@ NSMutableArr_insertObjectAtIndex

@ NSMutableArr_replaceObjectAtIndex

This represents a decl that may have a name.

IdentifierInfo * getIdentifier() const

Get the identifier that names this declaration, if there is one.

DeclarationName getDeclName() const

Get the actual, stored name of the declaration, which may be a special name.

ObjCStringFormatFamily getObjCFStringFormattingFamily() const

ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp,...

Expr * getElement(unsigned Index)

getElement - Return the Element at the specified index.

unsigned getNumElements() const

getNumElements - Return number of elements of objective-c array literal.

Represents Objective-C's @catch statement.

Represents Objective-C's @finally statement.

Represents Objective-C's @synchronized statement.

Represents Objective-C's @throw statement.

static ObjCAtTryStmt * Create(const ASTContext &Context, SourceLocation atTryLoc, Stmt *atTryStmt, Stmt **CatchStmts, unsigned NumCatchStmts, Stmt *atFinallyStmt)

Represents Objective-C's @autoreleasepool Statement.

ObjCCategoryDecl - Represents a category declaration.

ObjCContainerDecl - Represents a container for method declarations.

ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...

unsigned getNumElements() const

getNumElements - Return number of elements of objective-c dictionary literal.

ObjCDictionaryElement getKeyValueElement(unsigned Index) const

Represents Objective-C's collection statement.

Represents an ObjC class declaration.

ObjCTypeParamList * getTypeParamList() const

Retrieve the type parameters of this class.

ObjCMethodDecl * lookupInstanceMethod(Selector Sel) const

Lookup an instance method for a given selector.

ObjCMethodDecl * lookupPrivateMethod(const Selector &Sel, bool Instance=true) const

Lookup a method in the classes implementation hierarchy.

void setHasDesignatedInitializers()

Indicate that this interface decl contains at least one initializer marked with the 'objc_designated_...

ObjCIvarDecl - Represents an ObjC instance variable.

ObjCIvarRefExpr - A reference to an ObjC instance variable.

An expression that sends a message to the given Objective-C object or class.

Expr * getArg(unsigned Arg)

getArg - Return the specified argument.

Expr * getInstanceReceiver()

Returns the object expression (receiver) for an instance message, or null for a message that is not a...

SourceLocation getSuperLoc() const

Retrieve the location of the 'super' keyword for a class or instance message to 'super',...

Selector getSelector() const

@ SuperInstance

The receiver is the instance of the superclass object.

@ Instance

The receiver is an object instance.

bool isInstanceMessage() const

Determine whether this is an instance message to either a computed object or to super.

const ObjCMethodDecl * getMethodDecl() const

ReceiverKind getReceiverKind() const

Determine the kind of receiver that this message is being sent to.

unsigned getNumArgs() const

Return the number of actual arguments in this message, not counting the receiver.

ObjCMethodDecl - Represents an instance or class method declaration.

ImplicitParamDecl * getSelfDecl() const

ArrayRef< ParmVarDecl * > parameters() const

Wraps an ObjCPointerType with source location information.

void setStarLoc(SourceLocation Loc)

Represents a pointer to an Objective C object.

ArrayRef< QualType > getTypeArgs() const

Retrieve the type arguments for this type.

void setHasBaseTypeAsWritten(bool HasBaseType)

Represents one property declaration in an Objective-C interface.

ObjCPropertyRefExpr - A dot-syntax expression to access an ObjC property.

ObjCPropertyDecl * getExplicitProperty() const

const Expr * getBase() const

bool isImplicitProperty() const

SourceLocation getLocation() const

bool isSuperReceiver() const

Represents an Objective-C protocol declaration.

The basic abstraction for the target Objective-C runtime.

bool allowsDirectDispatch() const

Does this runtime supports direct dispatch.

ObjCStringLiteral, used for Objective-C string literals i.e.

Represents the declaration of an Objective-C type parameter.

Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...

unsigned size() const

Determine the number of type parameters in this list.

ProtocolLAngleLoc, ProtocolRAngleLoc, and the source locations for protocol qualifiers are stored aft...

OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class.

Represents a parameter to a function.

ParsedAttr - Represents a syntactic attribute.

IdentifierLoc * getArgAsIdent(unsigned Arg) const

bool hasParsedType() const

const ParsedType & getTypeArg() const

unsigned getNumArgs() const

getNumArgs - Return the number of actual arguments to this attribute.

bool isArgIdent(unsigned Arg) const

bool isUsedAsTypeAttr() const

AttributeCommonInfo::Kind getKind() const

PointerType - C99 6.7.5.1 - Pointer Declarators.

QualType getPointeeType() const

PseudoObjectExpr - An expression which accesses a pseudo-object l-value.

A (possibly-)qualified type.

QualType withConst() const

QualType getLocalUnqualifiedType() const

Return this type with all of the instance-specific qualifiers removed, but without removing any quali...

bool isNull() const

Return true if this QualType doesn't point to a type yet.

Qualifiers getQualifiers() const

Retrieve the set of qualifiers applied to this type.

Qualifiers::ObjCLifetime getObjCLifetime() const

Returns lifetime attribute of this type.

QualType getUnqualifiedType() const

Retrieve the unqualified variant of the given type, removing as little sugar as possible.

bool isConstQualified() const

Determine whether this type is const-qualified.

The collection of all-type qualifiers we support.

@ OCL_Strong

Assigning into this object requires the old value to be released and the new value to be retained.

@ OCL_ExplicitNone

This object can be modified without requiring retains or releases.

@ OCL_None

There is no lifetime qualification on this type.

@ OCL_Weak

Reading or writing from this object requires a barrier call.

@ OCL_Autoreleasing

Assigning into this object requires a lifetime extension.

bool compatiblyIncludes(Qualifiers other, const ASTContext &Ctx) const

Determines if these qualifiers compatibly include another set.

ObjCLifetime getObjCLifetime() const

Qualifiers withoutObjCLifetime() const

std::string getAsString() const

void setObjCLifetime(ObjCLifetime type)

Represents a struct/union/class.

Scope - A scope is a transient data structure that is used while parsing the program.

bool isAtCatchScope() const

isAtCatchScope - Return true if this scope is @catch.

const Scope * getParent() const

getParent - Return the scope that this is nested in.

Smart pointer class that efficiently represents Objective-C method names.

StringRef getNameForSlot(unsigned argIndex) const

Retrieve the name at a given position in the selector.

bool isUnarySelector() const

unsigned getNumArgs() const

A generic diagnostic builder for errors which may or may not be deferred.

ASTContext & getASTContext() const

const LangOptions & getLangOpts() const

SemaDiagnosticBuilder Diag(SourceLocation Loc, unsigned DiagID)

Emit a diagnostic.

bool isCFError(RecordDecl *D)

Definition SemaObjC.cpp:1461

void ActOnObjCReenterContainerContext(ObjCContainerDecl *ObjCCtx)

Definition SemaObjC.cpp:1291

void ActOnObjCTemporaryExitContainerContext(ObjCContainerDecl *ObjCCtx)

Invoked when we must temporarily exit the objective-c container scope for parsing/looking-up C constr...

Definition SemaObjC.cpp:1284

void handleRuntimeName(Decl *D, const ParsedAttr &AL)

Definition SemaObjC.cpp:2104

void handleNSObject(Decl *D, const ParsedAttr &AL)

Definition SemaObjC.cpp:1660

bool isValidOSObjectOutParameter(const Decl *D)

Definition SemaObjC.cpp:1807

ObjCMethodDecl * ValueWithBytesObjCTypeMethod

The declaration of the valueWithBytes:objCType: method.

StmtResult ActOnObjCForCollectionStmt(SourceLocation ForColLoc, Stmt *First, Expr *collection, SourceLocation RParenLoc)

Definition SemaObjC.cpp:36

StmtResult FinishObjCForCollectionStmt(Stmt *ForCollection, Stmt *Body)

FinishObjCForCollectionStmt - Attach the body to a objective-C foreach statement.

Definition SemaObjC.cpp:193

void handleNSErrorDomain(Decl *D, const ParsedAttr &Attr)

Definition SemaObjC.cpp:1991

void handleXReturnsXRetainedAttr(Decl *D, const ParsedAttr &AL)

Definition SemaObjC.cpp:1816

QualType BuildObjCTypeParamType(const ObjCTypeParamDecl *Decl, SourceLocation ProtocolLAngleLoc, ArrayRef< ObjCProtocolDecl * > Protocols, ArrayRef< SourceLocation > ProtocolLocs, SourceLocation ProtocolRAngleLoc, bool FailOnError=false)

Build an Objective-C type parameter type.

Definition SemaObjC.cpp:480

SemaObjC(Sema &S)

Definition SemaObjC.cpp:29

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

Build a specialized and/or protocol-qualified Objective-C type.

Definition SemaObjC.cpp:373

void checkArrayLiteral(QualType TargetType, ObjCArrayLiteral *ArrayLiteral)

Check an Objective-C array literal being converted to the given target type.

Definition SemaObjC.cpp:2356

void handleExternallyRetainedAttr(Decl *D, const ParsedAttr &AL)

Definition SemaObjC.cpp:2221

ObjCSubscriptKind CheckSubscriptingKind(Expr *FromE)

CheckSubscriptingKind - This routine decide what type of indexing represented by "FromE" is being don...

Definition SemaObjC.cpp:1375

IdentifierInfo * getNSErrorIdent()

Retrieve the identifier "NSError".

Definition SemaObjC.cpp:1265

StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *SynchExpr, Stmt *SynchBody)

Definition SemaObjC.cpp:320

ParsedType ActOnObjCInstanceType(SourceLocation Loc)

The parser has parsed the context-sensitive type 'instancetype' in an Objective-C message declaration...

Definition SemaObjC.cpp:740

void handleMethodFamilyAttr(Decl *D, const ParsedAttr &AL)

Definition SemaObjC.cpp:1631

void handleIndependentClass(Decl *D, const ParsedAttr &AL)

Definition SemaObjC.cpp:1685

ObjCInterfaceDecl * NSArrayDecl

The declaration of the Objective-C NSArray class.

RecordDecl * CFError

The struct behind the CFErrorRef pointer.

void handleIBOutlet(Decl *D, const ParsedAttr &AL)

Definition SemaObjC.cpp:1545

void handleReturnsInnerPointerAttr(Decl *D, const ParsedAttr &Attrs)

Definition SemaObjC.cpp:1945

bool isObjCWritebackConversion(QualType FromType, QualType ToType, QualType &ConvertedType)

Determine whether this is an Objective-C writeback conversion, used for parameter passing when perfor...

Definition SemaObjC.cpp:1314

void CheckObjCCircularContainer(ObjCMessageExpr *Message)

Check whether receiver is mutable ObjC container which attempts to add itself into the container.

Definition SemaObjC.cpp:1090

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

Definition SemaObjC.cpp:2312

void handleSuppresProtocolAttr(Decl *D, const ParsedAttr &AL)

Definition SemaObjC.cpp:1598

ObjCInterfaceDecl * NSNumberDecl

The declaration of the Objective-C NSNumber class.

StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try, MultiStmtArg Catch, Stmt *Finally)

Definition SemaObjC.cpp:218

void handleOwnershipAttr(Decl *D, const ParsedAttr &AL)

Definition SemaObjC.cpp:2138

ObjCInterfaceDecl * NSValueDecl

The declaration of the Objective-C NSValue class.

bool isSignedCharBool(QualType Ty)

Definition SemaObjC.cpp:2307

void handleBlocksAttr(Decl *D, const ParsedAttr &AL)

Definition SemaObjC.cpp:1700

ObjCInterfaceDecl * NSStringDecl

The declaration of the Objective-C NSString class.

StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)

Definition SemaObjC.cpp:213

void ActOnObjCContainerFinishDefinition()

Definition SemaObjC.cpp:1279

ObjCMethodDecl * StringWithUTF8StringMethod

The declaration of the stringWithUTF8String: method.

TypeResult actOnObjCProtocolQualifierType(SourceLocation lAngleLoc, ArrayRef< Decl * > protocols, ArrayRef< SourceLocation > protocolLocs, SourceLocation rAngleLoc)

Build a an Objective-C protocol-qualified 'id' type where no base type was specified.

Definition SemaObjC.cpp:336

StmtResult BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw)

Definition SemaObjC.cpp:238

void handleBridgeMutableAttr(Decl *D, const ParsedAttr &AL)

Definition SemaObjC.cpp:2051

Sema::RetainOwnershipKind parsedAttrToRetainOwnershipKind(const ParsedAttr &AL)

Definition SemaObjC.cpp:1772

void handleRequiresSuperAttr(Decl *D, const ParsedAttr &Attrs)

Definition SemaObjC.cpp:1971

ObjCInterfaceDecl * NSDictionaryDecl

The declaration of the Objective-C NSDictionary class.

ObjCMethodDecl * ArrayWithObjectsMethod

The declaration of the arrayWithObjects:count: method.

bool CheckObjCString(Expr *Arg)

CheckObjCString - Checks that the argument to the builtin CFString constructor is correct Note: It mi...

Definition SemaObjC.cpp:1213

QualType 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)

Build an Objective-C object pointer type.

Definition SemaObjC.cpp:707

ExprResult ActOnObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *operand)

Definition SemaObjC.cpp:282

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

Definition SemaObjC.cpp:1738

const DeclContext * getCurObjCLexicalContext() const

Definition SemaObjC.cpp:1256

void handleDesignatedInitializer(Decl *D, const ParsedAttr &AL)

Definition SemaObjC.cpp:2078

void handleBridgeRelatedAttr(Decl *D, const ParsedAttr &AL)

Definition SemaObjC.cpp:2063

void handleIBOutletCollection(Decl *D, const ParsedAttr &AL)

Definition SemaObjC.cpp:1552

ObjCMethodDecl * DictionaryWithObjectsMethod

The declaration of the dictionaryWithObjects:forKeys:count: method.

ObjCProtocolDecl * LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)

Find the protocol with the given name, if any.

Definition SemaObjC.cpp:1297

void DiagnoseCStringFormatDirectiveInCFAPI(const NamedDecl *FDecl, Expr **Args, unsigned NumArgs)

Diagnose use of s directive in an NSString which is being passed as formatting string to formatting m...

Definition SemaObjC.cpp:2270

bool isCFStringType(QualType T)

Definition SemaObjC.cpp:1505

void handleDirectAttr(Decl *D, const ParsedAttr &AL)

Definition SemaObjC.cpp:1609

StmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw, Scope *CurScope)

Definition SemaObjC.cpp:265

void checkRetainCycles(ObjCMessageExpr *msg)

checkRetainCycles - Check whether an Objective-C message send might create an obvious retain cycle.

Definition SemaObjC.cpp:1156

StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParen, Decl *Parm, Stmt *Body)

Definition SemaObjC.cpp:202

bool isNSStringType(QualType T, bool AllowNSAttributedString=false)

Definition SemaObjC.cpp:1486

bool GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx)

Definition SemaObjC.cpp:2257

ExprResult CheckObjCForCollectionOperand(SourceLocation forLoc, Expr *collection)

Definition SemaObjC.cpp:121

void AddCFAuditedAttribute(Decl *D)

AddCFAuditedAttribute - Check whether we're currently within '#pragma clang arc_cf_code_audited' and,...

Definition SemaObjC.cpp:1444

void checkDictionaryLiteral(QualType TargetType, ObjCDictionaryLiteral *DictionaryLiteral)

Check an Objective-C dictionary literal being converted to the given target type.

Definition SemaObjC.cpp:2381

void handleBoxable(Decl *D, const ParsedAttr &AL)

Definition SemaObjC.cpp:2116

bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type)

Definition SemaObjC.cpp:1796

ObjCMethodDecl * LookupMethodInQualifiedType(Selector Sel, const ObjCObjectPointerType *OPT, bool IsInstance)

LookupMethodInQualifiedType - Lookups up a method in protocol qualifier list of a qualified objective...

StmtResult ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)

Definition SemaObjC.cpp:329

void handleDirectMembersAttr(Decl *D, const ParsedAttr &AL)

Definition SemaObjC.cpp:1623

bool CheckObjCMethodCall(ObjCMethodDecl *Method, SourceLocation loc, ArrayRef< const Expr * > Args)

Definition SemaObjC.cpp:1241

void handleBridgeAttr(Decl *D, const ParsedAttr &AL)

Definition SemaObjC.cpp:2024

void handlePreciseLifetimeAttr(Decl *D, const ParsedAttr &AL)

Definition SemaObjC.cpp:2147

std::unique_ptr< NSAPI > NSAPIObj

Caches identifiers/selectors for NSFoundation APIs.

void ActOnObjCContainerStartDefinition(ObjCContainerDecl *IDecl)

Definition SemaObjC.cpp:1272

Sema - This implements semantic analysis and AST building for C.

@ LookupOrdinaryName

Ordinary name lookup, which finds ordinary names (functions, variables, typedefs, etc....

@ LookupObjCProtocolName

Look up the name of an Objective-C protocol.

AssignConvertType CheckSingleAssignmentConstraints(QualType LHSType, ExprResult &RHS, bool Diagnose=true, bool DiagnoseCFAudited=false, bool ConvertRHS=true)

Check assignment constraints for an assignment of RHS to LHSType.

ObjCMethodDecl * getCurMethodDecl()

getCurMethodDecl - If inside of a method body, this returns a pointer to the method decl for the meth...

bool IsAssignConvertCompatible(AssignConvertType ConvTy)

Encodes a location in the source.

bool isValid() const

Return true if this is a valid SourceLocation object.

A trivial tuple used to represent a source range.

SourceLocation getBegin() const

Stmt - This represents one statement.

SourceLocation getEndLoc() const LLVM_READONLY

SourceRange getSourceRange() const LLVM_READONLY

SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...

SourceLocation getBeginLoc() const LLVM_READONLY

StringLiteral - This represents a string literal expression, e.g.

StringRef getString() const

TagKind getTagKind() const

Base wrapper for a particular "section" of type source info.

TypeLoc findExplicitQualifierLoc() const

Find a type with the location of an explicit type qualifier.

T getAs() const

Convert to the specified TypeLoc type, returning a null TypeLoc if this TypeLoc is not of the desired...

T castAs() const

Convert to the specified TypeLoc type, asserting that this TypeLoc is of the desired type.

SourceRange getSourceRange() const LLVM_READONLY

Get the full source range.

SourceLocation getBeginLoc() const

Get the begin source location.

A container of type source information.

TypeLoc getTypeLoc() const

Return the TypeLoc wrapper for the type source info.

QualType getType() const

Return the type wrapped by this type source info.

bool isBlockPointerType() const

CXXRecordDecl * getAsCXXRecordDecl() const

Retrieves the CXXRecordDecl that this type refers to, either because the type is a RecordType or beca...

bool isPointerType() const

const T * castAs() const

Member-template castAs.

bool isReferenceType() const

bool isObjCNSObjectType() const

QualType getPointeeType() const

If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee.

bool isIntegralOrEnumerationType() const

Determine whether this type is an integral or enumeration type.

AutoType * getContainedAutoType() const

Get the AutoType whose type will be deduced for a variable with an initializer of this type.

bool isSpecificBuiltinType(unsigned K) const

Test for a particular builtin type.

bool isBuiltinType() const

Helper methods to distinguish type categories.

bool isDependentType() const

Whether this type is a dependent type, meaning that its definition somehow depends on a template para...

bool isObjCIdType() const

bool isObjCObjectType() const

bool isBlockCompatibleObjCPointerType(ASTContext &ctx) const

bool isObjCLifetimeType() const

Returns true if objects of this type have lifetime semantics under ARC.

Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const

Return the implicit lifetime for this type, which must not be dependent.

bool isObjCObjectPointerType() const

const T * getAsCanonical() const

If this type is canonically the specified type, return its canonical type cast to that specified type...

const T * getAs() const

Member-template getAs'.

bool isObjCRetainableType() const

QualType getUnderlyingType() const

Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...

void setType(QualType newType)

Represents a variable declaration or definition.

void setARCPseudoStrong(bool PS)

SourceRange getSourceRange() const override LLVM_READONLY

Source range that this declaration covers.

bool hasLocalStorage() const

Returns true if a variable with function scope is a non-static local variable.

Retains information about a function, method, or block that is currently being parsed.

void setHasObjCTry(SourceLocation TryLoc)

SourceLocation FirstSEHTryLoc

First SEH '__try' statement in the current function.

Provides information about an attempted template argument deduction, whose success or failure was des...

const internal::VariadicAllOfMatcher< Type > type

Matches Types in the clang AST.

const AstTypeMatcher< PointerType > pointerType

The JSON file list parser is used to communicate input to InstallAPI.

static void checkCollectionLiteralElement(Sema &S, QualType TargetElementType, Expr *Element, unsigned ElementKind)

Check a single element within a collection literal against the target element type.

Definition SemaObjC.cpp:2329

bool isa(CodeGen::Address addr)

AttributeDeclKind

These constants match the enumerated choices of warn_attribute_wrong_decl_type and err_attribute_wron...

@ ExpectedFunctionMethodOrParameter

@ ExpectedFunctionOrMethod

void handleSimpleAttributeOrDiagnose(SemaBase &S, Decl *D, const AttributeCommonInfo &CI, bool PassesCheck, unsigned DiagID, DiagnosticArgs &&...ExtraArgs)

Add an attribute AttrType to declaration D, provided that PassesCheck is true.

bool hasDeclarator(const Decl *D)

Return true if the given decl has a declarator that should have been processed by Sema::GetTypeForDec...

static bool isValidSubjectOfOSAttribute(QualType QT)

Definition SemaObjC.cpp:1731

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

Definition SemaObjC.cpp:958

const ParmVarDecl * getFunctionOrMethodParam(const Decl *D, unsigned Idx)

static bool isSetterLikeSelector(Selector sel)

Check for a keyword selector that starts with the word 'add' or 'set'.

Definition SemaObjC.cpp:971

nullptr

This class represents a compute construct, representing a 'Kind' of ‘parallel’, 'serial',...

static Expr * findCapturingExpr(Sema &S, Expr *e, RetainCycleOwner &owner)

Check whether the given argument is a block which captures a variable.

Definition SemaObjC.cpp:923

static bool considerVariable(VarDecl *var, Expr *ref, RetainCycleOwner &owner)

Consider whether capturing the given variable can possibly lead to a retain cycle.

Definition SemaObjC.cpp:769

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

Definition SemaObjC.cpp:1026

@ AANT_ArgumentIdentifier

@ Property

The type of a property.

@ Result

The result type of a method or function.

ActionResult< ParsedType > TypeResult

const FunctionProtoType * T

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

Definition SemaObjC.cpp:1521

LLVM_READONLY bool isLowercase(unsigned char c)

Return true if this character is a lowercase ASCII letter: [a-z].

@ Struct

The "struct" keyword.

static QualType applyObjCTypeArgs(Sema &S, SourceLocation loc, QualType type, ArrayRef< TypeSourceInfo * > typeArgs, SourceRange typeArgsRange, bool failOnError, bool rebuilding)

Apply Objective-C type arguments to the given type.

Definition SemaObjC.cpp:504

static bool isValidSubjectOfNSAttribute(QualType QT)

Definition SemaObjC.cpp:1721

void handleSimpleAttribute(SemaBase &S, Decl *D, const AttributeCommonInfo &CI)

Applies the given attribute to the Decl without performing any additional semantic checking.

static bool isValidSubjectOfCFAttribute(QualType QT)

Definition SemaObjC.cpp:1726

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

Definition SemaObjC.cpp:1056

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

Definition SemaObjC.cpp:2184

@ VK_PRValue

A pr-value expression (in the C++11 taxonomy) produces a temporary value.

static bool isValidSubjectOfNSReturnsRetainedAttribute(QualType QT)

Definition SemaObjC.cpp:1717

bool hasFunctionProto(const Decl *D)

hasFunctionProto - Return true if the given decl has a argument information.

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

Definition SemaObjC.cpp:782

MutableArrayRef< Stmt * > MultiStmtArg

unsigned getFunctionOrMethodNumParams(const Decl *D)

getFunctionOrMethodNumParams - Return number of function or method parameters.

TemplateDeductionResult

Describes the result of template argument deduction.

@ Success

Template argument deduction was successful.

@ AlreadyDiagnosed

Some error which was already diagnosed.

U cast(CodeGen::Address addr)

OpaquePtr< QualType > ParsedType

An opaque type for threading parsed type information through the parser.

ActionResult< Expr * > ExprResult

ActionResult< Stmt * > StmtResult

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

Definition SemaObjC.cpp:993