clang 20.0.0git
SemaObjC.h
Go to the documentation of this file.
1//===----- SemaObjC.h ------ Semantic Analysis for Objective-C ------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8/// \file
9/// This file declares semantic analysis for Objective-C.
10///
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_CLANG_SEMA_SEMAOBJC_H
14#define LLVM_CLANG_SEMA_SEMAOBJC_H
15
16#include "clang/AST/ASTFwd.h"
17#include "clang/AST/DeclObjC.h"
18#include "clang/AST/NSAPI.h"
20#include "clang/AST/Type.h"
22#include "clang/Basic/LLVM.h"
26#include "clang/Sema/DeclSpec.h"
30#include "clang/Sema/Sema.h"
31#include "clang/Sema/SemaBase.h"
32#include "llvm/ADT/DenseMap.h"
33#include "llvm/ADT/MapVector.h"
34#include "llvm/ADT/SmallPtrSet.h"
35#include <memory>
36#include <optional>
37#include <utility>
38
39namespace clang {
40
41class AttributeCommonInfo;
42class AvailabilitySpec;
43enum class CheckedConversionKind;
44class DeclGroupRef;
45class LookupResult;
46struct ObjCDictionaryElement;
47class ParsedAttr;
48class ParsedAttributesView;
49class Scope;
50struct SkipBodyInfo;
51
52class SemaObjC : public SemaBase {
53public:
54 SemaObjC(Sema &S);
55
57 Expr *collection);
59 Expr *collection,
60 SourceLocation RParenLoc);
61 /// FinishObjCForCollectionStmt - Attach the body to a objective-C foreach
62 /// statement.
63 StmtResult FinishObjCForCollectionStmt(Stmt *ForCollection, Stmt *Body);
64
66 Decl *Parm, Stmt *Body);
67
69
71 MultiStmtArg Catch, Stmt *Finally);
72
75 Scope *CurScope);
77 Expr *operand);
79 Stmt *SynchBody);
80
82
83 /// Build a an Objective-C protocol-qualified 'id' type where no
84 /// base type was specified.
86 SourceLocation lAngleLoc, ArrayRef<Decl *> protocols,
87 ArrayRef<SourceLocation> protocolLocs, SourceLocation rAngleLoc);
88
89 /// Build a specialized and/or protocol-qualified Objective-C type.
91 Scope *S, SourceLocation Loc, ParsedType BaseType,
92 SourceLocation TypeArgsLAngleLoc, ArrayRef<ParsedType> TypeArgs,
93 SourceLocation TypeArgsRAngleLoc, SourceLocation ProtocolLAngleLoc,
94 ArrayRef<Decl *> Protocols, ArrayRef<SourceLocation> ProtocolLocs,
95 SourceLocation ProtocolRAngleLoc);
96
97 /// Build an Objective-C type parameter type.
99 SourceLocation ProtocolLAngleLoc,
101 ArrayRef<SourceLocation> ProtocolLocs,
102 SourceLocation ProtocolRAngleLoc,
103 bool FailOnError = false);
104
105 /// Build an Objective-C object pointer type.
107 QualType BaseType, SourceLocation Loc, SourceLocation TypeArgsLAngleLoc,
108 ArrayRef<TypeSourceInfo *> TypeArgs, SourceLocation TypeArgsRAngleLoc,
109 SourceLocation ProtocolLAngleLoc, ArrayRef<ObjCProtocolDecl *> Protocols,
110 ArrayRef<SourceLocation> ProtocolLocs, SourceLocation ProtocolRAngleLoc,
111 bool FailOnError, bool Rebuilding);
112
113 /// The parser has parsed the context-sensitive type 'instancetype'
114 /// in an Objective-C message declaration. Return the appropriate type.
116
117 /// checkRetainCycles - Check whether an Objective-C message send
118 /// might create an obvious retain cycle.
120 void checkRetainCycles(Expr *receiver, Expr *argument);
121 void checkRetainCycles(VarDecl *Var, Expr *Init);
122
123 bool CheckObjCString(Expr *Arg);
126 /// Check whether receiver is mutable ObjC container which
127 /// attempts to add itself into the container
129
132
133 /// Invoked when we must temporarily exit the objective-c container
134 /// scope for parsing/looking-up C constructs.
135 ///
136 /// Must be followed by a call to \see ActOnObjCReenterContainerContext
139
141
144 RedeclarationKind Redecl = RedeclarationKind::NotForRedeclaration);
145
146 bool isObjCWritebackConversion(QualType FromType, QualType ToType,
147 QualType &ConvertedType);
148
151
152 /// AddCFAuditedAttribute - Check whether we're currently within
153 /// '\#pragma clang arc_cf_code_audited' and, if so, consider adding
154 /// the appropriate attribute.
156
157 /// The struct behind the CFErrorRef pointer.
158 RecordDecl *CFError = nullptr;
159 bool isCFError(RecordDecl *D);
160
162
163 bool GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx);
164
165 /// Diagnose use of %s directive in an NSString which is being passed
166 /// as formatting string to formatting method.
168 Expr **Args, unsigned NumArgs);
169
170 bool isSignedCharBool(QualType Ty);
171
173 Expr *SourceExpr, const Sema::SemaDiagnosticBuilder &Builder);
174
175 /// Check an Objective-C dictionary literal being converted to the given
176 /// target type.
177 void checkDictionaryLiteral(QualType TargetType,
178 ObjCDictionaryLiteral *DictionaryLiteral);
179
180 /// Check an Objective-C array literal being converted to the given
181 /// target type.
182 void checkArrayLiteral(QualType TargetType, ObjCArrayLiteral *ArrayLiteral);
183
184private:
185 IdentifierInfo *Ident_NSError = nullptr;
186
187 //
188 //
189 // -------------------------------------------------------------------------
190 //
191 //
192
193 /// \name ObjC Declarations
194 /// Implementations are in SemaDeclObjC.cpp
195 ///@{
196
197public:
205 };
206
207 /// Method selectors used in a \@selector expression. Used for implementation
208 /// of -Wselector.
209 llvm::MapVector<Selector, SourceLocation> ReferencedSelectors;
210
212 public:
213 using Lists = std::pair<ObjCMethodList, ObjCMethodList>;
214 using iterator = llvm::DenseMap<Selector, Lists>::iterator;
215 iterator begin() { return Methods.begin(); }
216 iterator end() { return Methods.end(); }
217 iterator find(Selector Sel) { return Methods.find(Sel); }
218 std::pair<iterator, bool> insert(std::pair<Selector, Lists> &&Val) {
219 return Methods.insert(Val);
220 }
221 int count(Selector Sel) const { return Methods.count(Sel); }
222 bool empty() const { return Methods.empty(); }
223
224 private:
225 llvm::DenseMap<Selector, Lists> Methods;
226 };
227
228 /// Method Pool - allows efficient lookup when typechecking messages to "id".
229 /// We need to maintain a list, since selectors can have differing signatures
230 /// across classes. In Cocoa, this happens to be extremely uncommon (only 1%
231 /// of selectors are "overloaded").
232 /// At the head of the list it is recorded whether there were 0, 1, or >= 2
233 /// methods inside categories with a particular selector.
235
237
239
248 };
250
252 SourceLocation varianceLoc, unsigned index,
253 IdentifierInfo *paramName,
254 SourceLocation paramLoc,
255 SourceLocation colonLoc, ParsedType typeBound);
256
258 ArrayRef<Decl *> typeParams,
259 SourceLocation rAngleLoc);
260 void popObjCTypeParamList(Scope *S, ObjCTypeParamList *typeParamList);
261
263 Scope *S, SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName,
264 SourceLocation ClassLoc, ObjCTypeParamList *typeParamList,
265 IdentifierInfo *SuperName, SourceLocation SuperLoc,
266 ArrayRef<ParsedType> SuperTypeArgs, SourceRange SuperTypeArgsRange,
267 Decl *const *ProtoRefs, unsigned NumProtoRefs,
268 const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc,
269 const ParsedAttributesView &AttrList, SkipBodyInfo *SkipBody);
270
272 Scope *S, SourceLocation AtInterfaceLoc, ObjCInterfaceDecl *IDecl,
273 IdentifierInfo *ClassName, SourceLocation ClassLoc,
274 IdentifierInfo *SuperName, SourceLocation SuperLoc,
275 ArrayRef<ParsedType> SuperTypeArgs, SourceRange SuperTypeArgsRange);
276
279 IdentifierInfo *SuperName,
280 SourceLocation SuperLoc);
281
282 Decl *ActOnCompatibilityAlias(SourceLocation AtCompatibilityAliasLoc,
283 IdentifierInfo *AliasName,
284 SourceLocation AliasLocation,
285 IdentifierInfo *ClassName,
286 SourceLocation ClassLocation);
287
289 IdentifierInfo *PName, SourceLocation &PLoc, SourceLocation PrevLoc,
290 const ObjCList<ObjCProtocolDecl> &PList);
291
293 SourceLocation AtProtoInterfaceLoc, IdentifierInfo *ProtocolName,
294 SourceLocation ProtocolLoc, Decl *const *ProtoRefNames,
295 unsigned NumProtoRefs, const SourceLocation *ProtoLocs,
296 SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList,
297 SkipBodyInfo *SkipBody);
298
300 SourceLocation AtInterfaceLoc, const IdentifierInfo *ClassName,
301 SourceLocation ClassLoc, ObjCTypeParamList *typeParamList,
302 const IdentifierInfo *CategoryName, SourceLocation CategoryLoc,
303 Decl *const *ProtoRefs, unsigned NumProtoRefs,
304 const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc,
305 const ParsedAttributesView &AttrList);
306
308 SourceLocation AtClassImplLoc, const IdentifierInfo *ClassName,
309 SourceLocation ClassLoc, const IdentifierInfo *SuperClassname,
310 SourceLocation SuperClassLoc, const ParsedAttributesView &AttrList);
311
313 SourceLocation AtCatImplLoc, const IdentifierInfo *ClassName,
314 SourceLocation ClassLoc, const IdentifierInfo *CatName,
315 SourceLocation CatLoc, const ParsedAttributesView &AttrList);
316
318
320 ArrayRef<Decl *> Decls);
321
325 const ParsedAttributesView &attrList);
326
327 void FindProtocolDeclaration(bool WarnOnDeclarations, bool ForObjCContainer,
329 SmallVectorImpl<Decl *> &Protocols);
330
332 SourceLocation ProtocolLoc,
333 IdentifierInfo *TypeArgId,
334 SourceLocation TypeArgLoc,
335 bool SelectProtocolFirst = false);
336
337 /// Given a list of identifiers (and their locations), resolve the
338 /// names to either Objective-C protocol qualifiers or type
339 /// arguments, as appropriate.
341 Scope *S, ParsedType baseType, SourceLocation lAngleLoc,
342 ArrayRef<IdentifierInfo *> identifiers,
343 ArrayRef<SourceLocation> identifierLocs, SourceLocation rAngleLoc,
344 SourceLocation &typeArgsLAngleLoc, SmallVectorImpl<ParsedType> &typeArgs,
345 SourceLocation &typeArgsRAngleLoc, SourceLocation &protocolLAngleLoc,
346 SmallVectorImpl<Decl *> &protocols, SourceLocation &protocolRAngleLoc,
347 bool warnOnIncompleteProtocols);
348
351
352 Decl *ActOnAtEnd(Scope *S, SourceRange AtEnd,
353 ArrayRef<Decl *> allMethods = std::nullopt,
354 ArrayRef<DeclGroupPtrTy> allTUVars = std::nullopt);
355
356 struct ObjCArgInfo {
359 // The Type is null if no type was specified, and the DeclSpec is invalid
360 // in this case.
363
364 /// ArgAttrs - Attribute list for this argument.
366 };
367
369 Scope *S,
370 SourceLocation BeginLoc, // location of the + or -.
371 SourceLocation EndLoc, // location of the ; or {.
372 tok::TokenKind MethodType, ObjCDeclSpec &ReturnQT, ParsedType ReturnType,
373 ArrayRef<SourceLocation> SelectorLocs, Selector Sel,
374 // optional arguments. The number of types/arguments is obtained
375 // from the Sel.getNumArgs().
376 ObjCArgInfo *ArgInfo, DeclaratorChunk::ParamInfo *CParamInfo,
377 unsigned CNumArgs, // c-style args
378 const ParsedAttributesView &AttrList, tok::ObjCKeywordKind MethodImplKind,
379 bool isVariadic, bool MethodDefinition);
380
382
383 bool checkInitMethod(ObjCMethodDecl *method, QualType receiverTypeIfCall);
384
385 /// Check whether the given new method is a valid override of the
386 /// given overridden method, and set any properties that should be inherited.
388 const ObjCMethodDecl *Overridden);
389
390 /// Describes the compatibility of a result type with its method.
395 };
396
398 ObjCMethodDecl *overridden);
399
401 ObjCInterfaceDecl *CurrentClass,
403
404 /// AddAnyMethodToGlobalPool - Add any method, instance or factory to global
405 /// pool.
407
409 bool isObjCMethodDecl(Decl *D) { return isa_and_nonnull<ObjCMethodDecl>(D); }
410
411 /// CheckImplementationIvars - This routine checks if the instance variables
412 /// listed in the implelementation match those listed in the interface.
414 ObjCIvarDecl **Fields, unsigned nIvars,
416
418 ObjCMethodDecl *MethodDecl,
419 bool IsProtocolMethodDecl);
420
422 ObjCMethodDecl *Overridden,
423 bool IsProtocolMethodDecl);
424
425 /// WarnExactTypedMethods - This routine issues a warning if method
426 /// implementation declaration matches exactly that of its declaration.
427 void WarnExactTypedMethods(ObjCMethodDecl *Method, ObjCMethodDecl *MethodDecl,
428 bool IsProtocolMethodDecl);
429
430 /// MatchAllMethodDeclarations - Check methods declaraed in interface or
431 /// or protocol against those declared in their implementations.
433 const SelectorSet &InsMap, const SelectorSet &ClsMap,
434 SelectorSet &InsMapSeen, SelectorSet &ClsMapSeen, ObjCImplDecl *IMPDecl,
435 ObjCContainerDecl *IDecl, bool &IncompleteImpl, bool ImmediateClass,
436 bool WarnCategoryMethodImpl = false);
437
438 /// CheckCategoryVsClassMethodMatches - Checks that methods implemented in
439 /// category matches with those implemented in its primary class and
440 /// warns each time an exact match is found.
442
443 /// ImplMethodsVsClassMethods - This is main routine to warn if any method
444 /// remains unimplemented in the class or category \@implementation.
446 ObjCContainerDecl *IDecl,
447 bool IncompleteImpl = false);
448
450 SourceLocation Loc, IdentifierInfo **IdentList, SourceLocation *IdentLocs,
451 ArrayRef<ObjCTypeParamList *> TypeParamLists, unsigned NumElts);
452
453 /// MatchTwoMethodDeclarations - Checks if two methods' type match and returns
454 /// true, or false, accordingly.
456 const ObjCMethodDecl *PrevMethod,
458
459 /// Add the given method to the list of globally-known methods.
461
462 void ReadMethodPool(Selector Sel);
464
465 /// - Returns instance or factory methods in global method pool for
466 /// given selector. It checks the desired kind first, if none is found, and
467 /// parameter checkTheOther is set, it then checks the other kind. If no such
468 /// method or only one method is found, function returns false; otherwise, it
469 /// returns true.
470 bool
473 bool InstanceFirst, bool CheckTheOther,
474 const ObjCObjectType *TypeBound = nullptr);
475
476 bool
478 SourceRange R, bool receiverIdOrClass,
480
481 void
483 Selector Sel, SourceRange R,
484 bool receiverIdOrClass);
485
486 const ObjCMethodDecl *
488 /// LookupImplementedMethodInGlobalPool - Returns the method which has an
489 /// implementation.
491
493
494 /// Checks that the Objective-C declaration is declared in the global scope.
495 /// Emits an error and marks the declaration as invalid if it's not declared
496 /// in the global scope.
498
499 void ActOnDefs(Scope *S, Decl *TagD, SourceLocation DeclStart,
500 const IdentifierInfo *ClassName,
502
504 SourceLocation StartLoc, SourceLocation IdLoc,
505 const IdentifierInfo *Id,
506 bool Invalid = false);
507
509
510 /// CollectIvarsToConstructOrDestruct - Collect those ivars which require
511 /// initialization.
512 void
515
517
518 /// DiagnoseUnusedBackingIvarInAccessor - Issue an 'unused' warning if ivar
519 /// which backs the property is not used in the property's accessor.
521 const ObjCImplementationDecl *ImplD);
522
523 /// GetIvarBackingPropertyAccessor - If method is a property setter/getter and
524 /// it property has a backing ivar, returns this ivar; otherwise, returns
525 /// NULL. It also returns ivar's property on success.
528 const ObjCPropertyDecl *&PDecl) const;
529
530 /// AddInstanceMethodToGlobalPool - All instance methods in a translation
531 /// unit are added to a global pool. This allows us to efficiently associate
532 /// a selector with a method declaraation for purposes of typechecking
533 /// messages sent to "id" (where the class of the object is unknown).
535 bool impl = false) {
536 AddMethodToGlobalPool(Method, impl, /*instance*/ true);
537 }
538
539 /// AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
540 void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl = false) {
541 AddMethodToGlobalPool(Method, impl, /*instance*/ false);
542 }
543
545 SourceLocation NameLoc,
546 TypeSourceInfo *TSInfo);
547
548 /// Look for an Objective-C class in the translation unit.
549 ///
550 /// \param Id The name of the Objective-C class we're looking for. If
551 /// typo-correction fixes this name, the Id will be updated
552 /// to the fixed name.
553 ///
554 /// \param IdLoc The location of the name in the translation unit.
555 ///
556 /// \param DoTypoCorrection If true, this routine will attempt typo correction
557 /// if there is no class with the given name.
558 ///
559 /// \returns The declaration of the named Objective-C class, or NULL if the
560 /// class could not be found.
562 SourceLocation IdLoc,
563 bool TypoCorrection = false);
564
566
567 /// SetIvarInitializers - This routine builds initialization ASTs for the
568 /// Objective-C implementation whose ivars need be initialized.
569 void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation);
570
572 Expr *BitWidth, tok::ObjCKeywordKind visibility);
573
575
576private:
577 /// AddMethodToGlobalPool - Add an instance or factory method to the global
578 /// pool. See descriptoin of AddInstanceMethodToGlobalPool.
579 void AddMethodToGlobalPool(ObjCMethodDecl *Method, bool impl, bool instance);
580
581 /// LookupMethodInGlobalPool - Returns the instance or factory method and
582 /// optionally warns if there are multiple signatures.
583 ObjCMethodDecl *LookupMethodInGlobalPool(Selector Sel, SourceRange R,
584 bool receiverIdOrClass,
585 bool instance);
586
587 ///@}
588
589 //
590 //
591 // -------------------------------------------------------------------------
592 //
593 //
594
595 /// \name ObjC Expressions
596 /// Implementations are in SemaExprObjC.cpp
597 ///@{
598
599public:
600 /// Caches identifiers/selectors for NSFoundation APIs.
601 std::unique_ptr<NSAPI> NSAPIObj;
602
603 /// The declaration of the Objective-C NSNumber class.
605
606 /// The declaration of the Objective-C NSValue class.
608
609 /// Pointer to NSNumber type (NSNumber *).
611
612 /// Pointer to NSValue type (NSValue *).
614
615 /// The Objective-C NSNumber methods used to create NSNumber literals.
617
618 /// The declaration of the Objective-C NSString class.
620
621 /// Pointer to NSString type (NSString *).
623
624 /// The declaration of the stringWithUTF8String: method.
626
627 /// The declaration of the valueWithBytes:objCType: method.
629
630 /// The declaration of the Objective-C NSArray class.
632
633 /// The declaration of the arrayWithObjects:count: method.
635
636 /// The declaration of the Objective-C NSDictionary class.
638
639 /// The declaration of the dictionaryWithObjects:forKeys:count: method.
641
642 /// id<NSCopying> type.
644
645 /// will hold 'respondsToSelector:'
647
649 Expr *BaseExpr, SourceLocation OpLoc,
650 DeclarationName MemberName,
651 SourceLocation MemberLoc,
652 SourceLocation SuperLoc,
653 QualType SuperType, bool Super);
654
656 const IdentifierInfo &propertyName,
657 SourceLocation receiverNameLoc,
658 SourceLocation propertyNameLoc);
659
660 // ParseObjCStringLiteral - Parse Objective-C string literals.
662 ArrayRef<Expr *> Strings);
663
665
666 /// BuildObjCNumericLiteral - builds an ObjCBoxedExpr AST node for the
667 /// numeric literal expression. Type of the expression will be "NSNumber *"
668 /// or "id" if NSNumber is unavailable.
671 bool Value);
673
674 /// BuildObjCBoxedExpr - builds an ObjCBoxedExpr AST node for the
675 /// '@' prefixed parenthesized expression. The type of the expression will
676 /// either be "NSNumber *", "NSString *" or "NSValue *" depending on the type
677 /// of ValueType, which is allowed to be a built-in numeric type, "char *",
678 /// "const char *" or C structure with attribute 'objc_boxable'.
680
682 Expr *IndexExpr,
683 ObjCMethodDecl *getterMethod,
684 ObjCMethodDecl *setterMethod);
685
689
691 TypeSourceInfo *EncodedTypeInfo,
692 SourceLocation RParenLoc);
693
695 SourceLocation EncodeLoc,
696 SourceLocation LParenLoc, ParsedType Ty,
697 SourceLocation RParenLoc);
698
699 /// ParseObjCSelectorExpression - Build selector expression for \@selector
701 SourceLocation SelLoc,
702 SourceLocation LParenLoc,
703 SourceLocation RParenLoc,
704 bool WarnMultipleSelectors);
705
706 /// ParseObjCProtocolExpression - Build protocol expression for \@protocol
708 SourceLocation AtLoc,
709 SourceLocation ProtoLoc,
710 SourceLocation LParenLoc,
711 SourceLocation ProtoIdLoc,
712 SourceLocation RParenLoc);
713
715
716 /// Describes the kind of message expression indicated by a message
717 /// send that starts with an identifier.
719 /// The message is sent to 'super'.
721 /// The message is an instance message.
723 /// The message is a class message, and the identifier is a type
724 /// name.
726 };
727
729 SourceLocation NameLoc, bool IsSuper,
730 bool HasTrailingDot,
731 ParsedType &ReceiverType);
732
734 SourceLocation LBracLoc,
735 ArrayRef<SourceLocation> SelectorLocs,
736 SourceLocation RBracLoc, MultiExprArg Args);
737
739 QualType ReceiverType, SourceLocation SuperLoc,
740 Selector Sel, ObjCMethodDecl *Method,
741 SourceLocation LBracLoc,
742 ArrayRef<SourceLocation> SelectorLocs,
743 SourceLocation RBracLoc, MultiExprArg Args,
744 bool isImplicit = false);
745
747 bool isSuperReceiver, SourceLocation Loc,
748 Selector Sel, ObjCMethodDecl *Method,
749 MultiExprArg Args);
750
752 SourceLocation LBracLoc,
753 ArrayRef<SourceLocation> SelectorLocs,
754 SourceLocation RBracLoc, MultiExprArg Args);
755
756 ExprResult BuildInstanceMessage(Expr *Receiver, QualType ReceiverType,
757 SourceLocation SuperLoc, Selector Sel,
758 ObjCMethodDecl *Method,
759 SourceLocation LBracLoc,
760 ArrayRef<SourceLocation> SelectorLocs,
761 SourceLocation RBracLoc, MultiExprArg Args,
762 bool isImplicit = false);
763
766 ObjCMethodDecl *Method,
767 MultiExprArg Args);
768
770 SourceLocation LBracLoc,
771 ArrayRef<SourceLocation> SelectorLocs,
772 SourceLocation RBracLoc, MultiExprArg Args);
773
776 SourceLocation BridgeKeywordLoc,
777 TypeSourceInfo *TSInfo, Expr *SubExpr);
778
781 SourceLocation BridgeKeywordLoc,
782 ParsedType Type, SourceLocation RParenLoc,
783 Expr *SubExpr);
784
786
788
790 CastKind &Kind);
791
793 QualType SrcType,
794 ObjCInterfaceDecl *&RelatedClass,
795 ObjCMethodDecl *&ClassMethod,
796 ObjCMethodDecl *&InstanceMethod,
797 TypedefNameDecl *&TDNDecl, bool CfToNs,
798 bool Diagnose = true);
799
801 QualType SrcType, Expr *&SrcExpr,
802 bool Diagnose = true);
803
804 /// Private Helper predicate to check for 'self'.
805 bool isSelfExpr(Expr *RExpr);
806 bool isSelfExpr(Expr *RExpr, const ObjCMethodDecl *Method);
807
809 const ObjCObjectPointerType *OPT,
810 bool IsInstance);
812 bool IsInstance);
813
814 bool isKnownName(StringRef name);
815
817
818 /// Checks for invalid conversions and casts between
819 /// retainable pointers and other pointer kinds for ARC and Weak.
821 QualType castType, Expr *&op,
823 bool Diagnose = true,
824 bool DiagnoseCFAudited = false,
825 BinaryOperatorKind Opc = BO_PtrMemD);
826
829
831 QualType ExprType);
832
833 /// CheckMessageArgumentTypes - Check types in an Obj-C message send.
834 /// \param Method - May be null.
835 /// \param [out] ReturnType - The return type of the send.
836 /// \return true iff there were any incompatible types.
837 bool CheckMessageArgumentTypes(const Expr *Receiver, QualType ReceiverType,
838 MultiExprArg Args, Selector Sel,
839 ArrayRef<SourceLocation> SelectorLocs,
840 ObjCMethodDecl *Method, bool isClassMessage,
841 bool isSuperMessage, SourceLocation lbrac,
842 SourceLocation rbrac, SourceRange RecRange,
843 QualType &ReturnType, ExprValueKind &VK);
844
845 /// Determine the result of a message send expression based on
846 /// the type of the receiver, the method expected to receive the message,
847 /// and the form of the message send.
848 QualType getMessageSendResultType(const Expr *Receiver, QualType ReceiverType,
849 ObjCMethodDecl *Method, bool isClassMessage,
850 bool isSuperMessage);
851
852 /// If the given expression involves a message send to a method
853 /// with a related result type, emit a note describing what happened.
854 void EmitRelatedResultTypeNote(const Expr *E);
855
856 /// Given that we had incompatible pointer types in a return
857 /// statement, check whether we're in a method with a related result
858 /// type, and if so, emit a note describing what happened.
860
861 /// LookupInstanceMethodInGlobalPool - Returns the method and warns if
862 /// there are multiple signatures.
865 bool receiverIdOrClass = false) {
866 return LookupMethodInGlobalPool(Sel, R, receiverIdOrClass,
867 /*instance*/ true);
868 }
869
870 /// LookupFactoryMethodInGlobalPool - Returns the method and warns if
871 /// there are multiple signatures.
874 bool receiverIdOrClass = false) {
875 return LookupMethodInGlobalPool(Sel, R, receiverIdOrClass,
876 /*instance*/ false);
877 }
878
879 /// The parser has read a name in, and Sema has detected that we're currently
880 /// inside an ObjC method. Perform some additional checks and determine if we
881 /// should form a reference to an ivar.
882 ///
883 /// Ideally, most of this would be done by lookup, but there's
884 /// actually quite a lot of extra work involved.
886 IdentifierInfo *II);
887
888 /// The parser has read a name in, and Sema has detected that we're currently
889 /// inside an ObjC method. Perform some additional checks and determine if we
890 /// should form a reference to an ivar. If so, build an expression referencing
891 /// that ivar.
893 IdentifierInfo *II,
894 bool AllowBuiltinCreation = false);
895
897
898 /// FindCompositeObjCPointerType - Helper method to find composite type of
899 /// two objective-c pointer types of the two input expressions.
901 SourceLocation QuestionLoc);
902
903 bool CheckConversionToObjCLiteral(QualType DstType, Expr *&SrcExpr,
904 bool Diagnose = true);
905
906 /// ActOnObjCBoolLiteral - Parse {__objc_yes,__objc_no} literals.
908
911 SourceLocation AtLoc, SourceLocation RParen);
912
913 /// Prepare a conversion of the given expression to an ObjC object
914 /// pointer type.
916
917 // Note that LK_String is intentionally after the other literals, as
918 // this is used for diagnostics logic.
926 LK_None
927 };
929
930 ///@}
931
932 //
933 //
934 // -------------------------------------------------------------------------
935 //
936 //
937
938 /// \name ObjC @property and @synthesize
939 /// Implementations are in SemaObjCProperty.cpp
940 ///@{
941
942public:
943 /// Ensure attributes are consistent with type.
944 /// \param [in, out] Attributes The attributes to check; they will
945 /// be modified to be consistent with \p PropertyTy.
947 unsigned &Attributes,
948 bool propertyInPrimaryClass);
949
950 /// Process the specified property declaration and create decls for the
951 /// setters and getters as needed.
952 /// \param property The property declaration being processed
954
957 Selector GetterSel, Selector SetterSel,
958 tok::ObjCKeywordKind MethodImplKind,
959 DeclContext *lexicalDC = nullptr);
960
962 SourceLocation PropertyLoc, bool ImplKind,
963 IdentifierInfo *PropertyId,
964 IdentifierInfo *PropertyIvar,
965 SourceLocation PropertyIvarLoc,
966 ObjCPropertyQueryKind QueryKind);
967
968 /// Called by ActOnProperty to handle \@property declarations in
969 /// class extensions.
971 Scope *S, SourceLocation AtLoc, SourceLocation LParenLoc,
972 FieldDeclarator &FD, Selector GetterSel, SourceLocation GetterNameLoc,
973 Selector SetterSel, SourceLocation SetterNameLoc, const bool isReadWrite,
974 unsigned &Attributes, const unsigned AttributesAsWritten, QualType T,
975 TypeSourceInfo *TSI, tok::ObjCKeywordKind MethodImplKind);
976
977 /// Called by ActOnProperty and HandlePropertyInClassExtension to
978 /// handle creating the ObjcPropertyDecl for a category or \@interface.
981 SourceLocation LParenLoc, FieldDeclarator &FD,
982 Selector GetterSel, SourceLocation GetterNameLoc,
983 Selector SetterSel, SourceLocation SetterNameLoc,
984 const bool isReadWrite, const unsigned Attributes,
985 const unsigned AttributesAsWritten, QualType T,
986 TypeSourceInfo *TSI, tok::ObjCKeywordKind MethodImplKind,
987 DeclContext *lexicalDC = nullptr);
988
990 ObjCPropertyDecl *SuperProperty,
991 const IdentifierInfo *Name,
992 bool OverridingProtocolProperty);
993
995 ObjCMethodDecl *Getter,
997
998 /// DiagnoseUnimplementedProperties - This routine warns on those properties
999 /// which must be implemented by this implementation.
1001 ObjCContainerDecl *CDecl,
1002 bool SynthesizeProperties);
1003
1004 /// Diagnose any null-resettable synthesized setters.
1006
1007 /// DefaultSynthesizeProperties - This routine default synthesizes all
1008 /// properties which must be synthesized in the class's \@implementation.
1010 ObjCInterfaceDecl *IDecl,
1011 SourceLocation AtEnd);
1013
1014 /// IvarBacksCurrentMethodAccessor - This routine returns 'true' if 'IV' is
1015 /// an ivar synthesized for 'Method' and 'Method' is a property accessor
1016 /// declared in class 'IFace'.
1018 ObjCMethodDecl *Method, ObjCIvarDecl *IV);
1019
1021
1022 void
1024 const ObjCInterfaceDecl *IFD);
1025
1026 /// AtomicPropertySetterGetterRules - This routine enforces the rule (via
1027 /// warning) when atomic property has one but not the other user-declared
1028 /// setter or getter.
1030 ObjCInterfaceDecl *IDecl);
1031
1032 ///@}
1033
1034 //
1035 //
1036 // -------------------------------------------------------------------------
1037 //
1038 //
1039
1040 /// \name ObjC Attributes
1041 /// Implementations are in SemaObjC.cpp
1042 ///@{
1043
1044 bool isNSStringType(QualType T, bool AllowNSAttributedString = false);
1046
1047 void handleIBOutlet(Decl *D, const ParsedAttr &AL);
1048 void handleIBOutletCollection(Decl *D, const ParsedAttr &AL);
1049
1050 void handleSuppresProtocolAttr(Decl *D, const ParsedAttr &AL);
1051 void handleDirectAttr(Decl *D, const ParsedAttr &AL);
1052 void handleDirectMembersAttr(Decl *D, const ParsedAttr &AL);
1053 void handleMethodFamilyAttr(Decl *D, const ParsedAttr &AL);
1054 void handleNSObject(Decl *D, const ParsedAttr &AL);
1055 void handleIndependentClass(Decl *D, const ParsedAttr &AL);
1056 void handleBlocksAttr(Decl *D, const ParsedAttr &AL);
1057 void handleReturnsInnerPointerAttr(Decl *D, const ParsedAttr &Attrs);
1058 void handleXReturnsXRetainedAttr(Decl *D, const ParsedAttr &AL);
1059 void handleRequiresSuperAttr(Decl *D, const ParsedAttr &Attrs);
1060 void handleNSErrorDomain(Decl *D, const ParsedAttr &Attr);
1061 void handleBridgeAttr(Decl *D, const ParsedAttr &AL);
1062 void handleBridgeMutableAttr(Decl *D, const ParsedAttr &AL);
1063 void handleBridgeRelatedAttr(Decl *D, const ParsedAttr &AL);
1064 void handleDesignatedInitializer(Decl *D, const ParsedAttr &AL);
1065 void handleRuntimeName(Decl *D, const ParsedAttr &AL);
1066 void handleBoxable(Decl *D, const ParsedAttr &AL);
1067 void handleOwnershipAttr(Decl *D, const ParsedAttr &AL);
1068 void handlePreciseLifetimeAttr(Decl *D, const ParsedAttr &AL);
1070
1071 void AddXConsumedAttr(Decl *D, const AttributeCommonInfo &CI,
1073 bool IsTemplateInstantiation);
1074
1075 /// \return whether the parameter is a pointer to OSObject pointer.
1076 bool isValidOSObjectOutParameter(const Decl *D);
1078
1081
1082 ///@}
1083};
1084
1085} // namespace clang
1086
1087#endif // LLVM_CLANG_SEMA_SEMAOBJC_H
Forward declaration of all AST node types.
static char ID
Definition: Arena.cpp:183
const Decl * D
enum clang::sema::@1655::IndirectLocalPathEntry::EntryKind Kind
Expr * E
Defines the clang::IdentifierInfo, clang::IdentifierTable, and clang::Selector interfaces.
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
RedeclarationKind
Specifies whether (or how) name lookup is being performed for a redeclaration (vs.
Definition: Redeclaration.h:18
uint32_t Id
Definition: SemaARM.cpp:1144
SourceLocation Loc
Definition: SemaObjC.cpp:759
Defines the clang::SourceLocation class and associated facilities.
Defines various enumerations that describe declaration and type specifiers.
Defines the clang::TokenKind enum and support functions.
C Language Family Type Representation.
Attr - This represents one attribute.
Definition: Attr.h:42
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition: DeclBase.h:1436
Decl - This represents one declaration (or definition), e.g.
Definition: DeclBase.h:86
The name of a declaration.
Information about one declarator, including the parsed type information and the identifier.
Definition: DeclSpec.h:1903
This represents one expression.
Definition: Expr.h:110
One of these records is kept for each identifier that is lexed.
Represents the results of name lookup.
Definition: Lookup.h:46
static const unsigned NumNSNumberLiteralMethods
Definition: NSAPI.h:191
This represents a decl that may have a name.
Definition: Decl.h:249
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp,...
Definition: ExprObjC.h:191
ObjCCategoryDecl - Represents a category declaration.
Definition: DeclObjC.h:2328
ObjCCategoryImplDecl - An object of this class encapsulates a category @implementation declaration.
Definition: DeclObjC.h:2544
ObjCContainerDecl - Represents a container for method declarations.
Definition: DeclObjC.h:947
Captures information about "declaration specifiers" specific to Objective-C.
Definition: DeclSpec.h:900
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
Definition: ExprObjC.h:309
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
Definition: DeclObjC.h:2596
Represents an ObjC class declaration.
Definition: DeclObjC.h:1153
ObjCIvarDecl - Represents an ObjC instance variable.
Definition: DeclObjC.h:1951
ObjCList - This is a simple template class used to hold various lists of decls etc,...
Definition: DeclObjC.h:82
An expression that sends a message to the given Objective-C object or class.
Definition: ExprObjC.h:945
ObjCMethodDecl - Represents an instance or class method declaration.
Definition: DeclObjC.h:140
Represents a pointer to an Objective C object.
Definition: Type.h:7404
Represents a class type in Objective C.
Definition: Type.h:7150
Represents one property declaration in an Objective-C interface.
Definition: DeclObjC.h:730
Represents an Objective-C protocol declaration.
Definition: DeclObjC.h:2083
Represents the declaration of an Objective-C type parameter.
Definition: DeclObjC.h:578
Stores a list of Objective-C type parameters for a parameterized class or a category/extension thereo...
Definition: DeclObjC.h:659
ParsedAttr - Represents a syntactic attribute.
Definition: ParsedAttr.h:129
A (possibly-)qualified type.
Definition: Type.h:941
Represents a struct/union/class.
Definition: Decl.h:4145
Scope - A scope is a transient data structure that is used while parsing the program.
Definition: Scope.h:41
Smart pointer class that efficiently represents Objective-C method names.
A generic diagnostic builder for errors which may or may not be deferred.
Definition: SemaBase.h:110
std::pair< iterator, bool > insert(std::pair< Selector, Lists > &&Val)
Definition: SemaObjC.h:218
iterator find(Selector Sel)
Definition: SemaObjC.h:217
llvm::DenseMap< Selector, Lists >::iterator iterator
Definition: SemaObjC.h:214
int count(Selector Sel) const
Definition: SemaObjC.h:221
std::pair< ObjCMethodList, ObjCMethodList > Lists
Definition: SemaObjC.h:213
bool isCFError(RecordDecl *D)
Definition: SemaObjC.cpp:1465
void ActOnObjCReenterContainerContext(ObjCContainerDecl *ObjCCtx)
Definition: SemaObjC.cpp:1295
void ActOnObjCTemporaryExitContainerContext(ObjCContainerDecl *ObjCCtx)
Invoked when we must temporarily exit the objective-c container scope for parsing/looking-up C constr...
Definition: SemaObjC.cpp:1288
void DefaultSynthesizeProperties(Scope *S, ObjCImplDecl *IMPDecl, ObjCInterfaceDecl *IDecl, SourceLocation AtEnd)
DefaultSynthesizeProperties - This routine default synthesizes all properties which must be synthesiz...
void handleRuntimeName(Decl *D, const ParsedAttr &AL)
Definition: SemaObjC.cpp:2106
Decl * ActOnIvar(Scope *S, SourceLocation DeclStart, Declarator &D, Expr *BitWidth, tok::ObjCKeywordKind visibility)
ActOnIvar - Each ivar field of an objective-c class is passed into this in order to create an IvarDec...
void ActOnStartOfObjCMethodDef(Scope *S, Decl *D)
ActOnStartOfObjCMethodDef - This routine sets up parameters; invisible and user declared,...
void handleNSObject(Decl *D, const ParsedAttr &AL)
Definition: SemaObjC.cpp:1662
void ActOnSuperClassOfClassInterface(Scope *S, SourceLocation AtInterfaceLoc, ObjCInterfaceDecl *IDecl, IdentifierInfo *ClassName, SourceLocation ClassLoc, IdentifierInfo *SuperName, SourceLocation SuperLoc, ArrayRef< ParsedType > SuperTypeArgs, SourceRange SuperTypeArgsRange)
bool DiagnosePropertyAccessorMismatch(ObjCPropertyDecl *PD, ObjCMethodDecl *Getter, SourceLocation Loc)
bool isValidOSObjectOutParameter(const Decl *D)
Definition: SemaObjC.cpp:1809
VarDecl * BuildObjCExceptionDecl(TypeSourceInfo *TInfo, QualType ExceptionType, SourceLocation StartLoc, SourceLocation IdLoc, const IdentifierInfo *Id, bool Invalid=false)
Build a type-check a new Objective-C exception variable declaration.
ObjCMessageKind getObjCMessageKind(Scope *S, IdentifierInfo *Name, SourceLocation NameLoc, bool IsSuper, bool HasTrailingDot, ParsedType &ReceiverType)
ObjCMethodDecl * ValueWithBytesObjCTypeMethod
The declaration of the valueWithBytes:objCType: method.
Definition: SemaObjC.h:628
void DiagnoseUnusedBackingIvarInAccessor(Scope *S, const ObjCImplementationDecl *ImplD)
DiagnoseUnusedBackingIvarInAccessor - Issue an 'unused' warning if ivar which backs the property is n...
void SetIvarInitializers(ObjCImplementationDecl *ObjCImplementation)
SetIvarInitializers - This routine builds initialization ASTs for the Objective-C implementation whos...
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:198
ExprResult BuildObjCDictionaryLiteral(SourceRange SR, MutableArrayRef< ObjCDictionaryElement > Elements)
ExprResult HandleExprPropertyRefExpr(const ObjCObjectPointerType *OPT, Expr *BaseExpr, SourceLocation OpLoc, DeclarationName MemberName, SourceLocation MemberLoc, SourceLocation SuperLoc, QualType SuperType, bool Super)
HandleExprPropertyRefExpr - Handle foo.bar where foo is a pointer to an objective C interface.
void handleNSErrorDomain(Decl *D, const ParsedAttr &Attr)
Definition: SemaObjC.cpp:1993
void WarnExactTypedMethods(ObjCMethodDecl *Method, ObjCMethodDecl *MethodDecl, bool IsProtocolMethodDecl)
WarnExactTypedMethods - This routine issues a warning if method implementation declaration matches ex...
ExprResult BuildInstanceMessage(Expr *Receiver, QualType ReceiverType, SourceLocation SuperLoc, Selector Sel, ObjCMethodDecl *Method, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args, bool isImplicit=false)
Build an Objective-C instance message expression.
void handleXReturnsXRetainedAttr(Decl *D, const ParsedAttr &AL)
Definition: SemaObjC.cpp:1818
const ObjCMethodDecl * SelectorsForTypoCorrection(Selector Sel, QualType ObjectType=QualType())
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:485
void ProcessPropertyDecl(ObjCPropertyDecl *property)
Process the specified property declaration and create decls for the setters and getters as needed.
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:378
ExprResult ParseObjCSelectorExpression(Selector Sel, SourceLocation AtLoc, SourceLocation SelLoc, SourceLocation LParenLoc, SourceLocation RParenLoc, bool WarnMultipleSelectors)
ParseObjCSelectorExpression - Build selector expression for @selector.
void addMethodToGlobalList(ObjCMethodList *List, ObjCMethodDecl *Method)
Add the given method to the list of globally-known methods.
void checkArrayLiteral(QualType TargetType, ObjCArrayLiteral *ArrayLiteral)
Check an Objective-C array literal being converted to the given target type.
Definition: SemaObjC.cpp:2357
ObjCPropertyDecl * 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)
Called by ActOnProperty to handle @property declarations in class extensions.
ObjCInterfaceDecl * ActOnStartClassInterface(Scope *S, SourceLocation AtInterfaceLoc, IdentifierInfo *ClassName, SourceLocation ClassLoc, ObjCTypeParamList *typeParamList, IdentifierInfo *SuperName, SourceLocation SuperLoc, ArrayRef< ParsedType > SuperTypeArgs, SourceRange SuperTypeArgsRange, Decl *const *ProtoRefs, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList, SkipBodyInfo *SkipBody)
void handleExternallyRetainedAttr(Decl *D, const ParsedAttr &AL)
Definition: SemaObjC.cpp:2223
ARCConversionResult CheckObjCConversion(SourceRange castRange, QualType castType, Expr *&op, CheckedConversionKind CCK, bool Diagnose=true, bool DiagnoseCFAudited=false, BinaryOperatorKind Opc=BO_PtrMemD)
Checks for invalid conversions and casts between retainable pointers and other pointer kinds for ARC ...
void diagnoseNullResettableSynthesizedSetters(const ObjCImplDecl *impDecl)
Diagnose any null-resettable synthesized setters.
ObjCSubscriptKind CheckSubscriptingKind(Expr *FromE)
CheckSubscriptingKind - This routine decide what type of indexing represented by "FromE" is being don...
Definition: SemaObjC.cpp:1379
void updateOutOfDateSelector(Selector Sel)
llvm::SmallPtrSet< Selector, 8 > SelectorSet
Definition: SemaObjC.h:236
IdentifierInfo * getNSErrorIdent()
Retrieve the identifier "NSError".
Definition: SemaObjC.cpp:1269
ExprResult BuildClassMessage(TypeSourceInfo *ReceiverTypeInfo, QualType ReceiverType, SourceLocation SuperLoc, Selector Sel, ObjCMethodDecl *Method, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args, bool isImplicit=false)
Build an Objective-C class message expression.
void popObjCTypeParamList(Scope *S, ObjCTypeParamList *typeParamList)
ExprResult BuildObjCNumericLiteral(SourceLocation AtLoc, Expr *Number)
BuildObjCNumericLiteral - builds an ObjCBoxedExpr AST node for the numeric literal expression.
ObjCImplementationDecl * ActOnStartClassImplementation(SourceLocation AtClassImplLoc, const IdentifierInfo *ClassName, SourceLocation ClassLoc, const IdentifierInfo *SuperClassname, SourceLocation SuperClassLoc, const ParsedAttributesView &AttrList)
bool AreMultipleMethodsInGlobalPool(Selector Sel, ObjCMethodDecl *BestMethod, SourceRange R, bool receiverIdOrClass, SmallVectorImpl< ObjCMethodDecl * > &Methods)
ObjCMethodDecl * LookupInstanceMethodInGlobalPool(Selector Sel, SourceRange R, bool receiverIdOrClass=false)
LookupInstanceMethodInGlobalPool - Returns the method and warns if there are multiple signatures.
Definition: SemaObjC.h:864
Decl * ActOnObjCExceptionDecl(Scope *S, Declarator &D)
ExprResult ActOnObjCBridgedCast(Scope *S, SourceLocation LParenLoc, ObjCBridgeCastKind Kind, SourceLocation BridgeKeywordLoc, ParsedType Type, SourceLocation RParenLoc, Expr *SubExpr)
ObjCPropertyDecl * 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 *TSI, tok::ObjCKeywordKind MethodImplKind, DeclContext *lexicalDC=nullptr)
Called by ActOnProperty and HandlePropertyInClassExtension to handle creating the ObjcPropertyDecl fo...
StmtResult ActOnObjCAtSynchronizedStmt(SourceLocation AtLoc, Expr *SynchExpr, Stmt *SynchBody)
Definition: SemaObjC.cpp:325
ObjCLiteralKind CheckLiteralKind(Expr *FromE)
ParsedType ActOnObjCInstanceType(SourceLocation Loc)
The parser has parsed the context-sensitive type 'instancetype' in an Objective-C message declaration...
Definition: SemaObjC.cpp:745
void handleMethodFamilyAttr(Decl *D, const ParsedAttr &AL)
Definition: SemaObjC.cpp:1635
void handleIndependentClass(Decl *D, const ParsedAttr &AL)
Definition: SemaObjC.cpp:1687
ExprResult BuildObjCEncodeExpression(SourceLocation AtLoc, TypeSourceInfo *EncodedTypeInfo, SourceLocation RParenLoc)
bool CheckObjCBridgeRelatedConversions(SourceLocation Loc, QualType DestType, QualType SrcType, Expr *&SrcExpr, bool Diagnose=true)
ExprResult BuildObjCArrayLiteral(SourceRange SR, MultiExprArg Elements)
bool CheckObjCDeclScope(Decl *D)
Checks that the Objective-C declaration is declared in the global scope.
ObjCInterfaceDecl * NSArrayDecl
The declaration of the Objective-C NSArray class.
Definition: SemaObjC.h:631
DeclResult actOnObjCTypeParam(Scope *S, ObjCTypeParamVariance variance, SourceLocation varianceLoc, unsigned index, IdentifierInfo *paramName, SourceLocation paramLoc, SourceLocation colonLoc, ParsedType typeBound)
RecordDecl * CFError
The struct behind the CFErrorRef pointer.
Definition: SemaObjC.h:158
ExprResult ActOnClassPropertyRefExpr(const IdentifierInfo &receiverName, const IdentifierInfo &propertyName, SourceLocation receiverNameLoc, SourceLocation propertyNameLoc)
void handleIBOutlet(Decl *D, const ParsedAttr &AL)
Definition: SemaObjC.cpp:1549
ObjCIvarDecl * GetIvarBackingPropertyAccessor(const ObjCMethodDecl *Method, const ObjCPropertyDecl *&PDecl) const
GetIvarBackingPropertyAccessor - If method is a property setter/getter and it property has a backing ...
void handleReturnsInnerPointerAttr(Decl *D, const ParsedAttr &Attrs)
Definition: SemaObjC.cpp:1947
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:1318
void CheckObjCCircularContainer(ObjCMessageExpr *Message)
Check whether receiver is mutable ObjC container which attempts to add itself into the container.
Definition: SemaObjC.cpp:1095
bool CheckARCMethodDecl(ObjCMethodDecl *method)
Check a method declaration for compatibility with the Objective-C ARC conventions.
ObjCContainerKind getObjCContainerKind() const
ObjCInterfaceDecl * getObjCInterfaceDecl(const IdentifierInfo *&Id, SourceLocation IdLoc, bool TypoCorrection=false)
Look for an Objective-C class in the translation unit.
ObjCMethodDecl * LookupMethodInObjectType(Selector Sel, QualType Ty, bool IsInstance)
LookupMethodInType - Look up a method in an ObjCObjectType.
bool IvarBacksCurrentMethodAccessor(ObjCInterfaceDecl *IFace, ObjCMethodDecl *Method, ObjCIvarDecl *IV)
IvarBacksCurrentMethodAccessor - This routine returns 'true' if 'IV' is an ivar synthesized for 'Meth...
DeclGroupPtrTy ActOnFinishObjCImplementation(Decl *ObjCImpDecl, ArrayRef< Decl * > Decls)
ExprResult BuildClassMessageImplicit(QualType ReceiverType, bool isSuperReceiver, SourceLocation Loc, Selector Sel, ObjCMethodDecl *Method, MultiExprArg Args)
ObjCContainerDecl * getObjCDeclContext() const
void handleSuppresProtocolAttr(Decl *D, const ParsedAttr &AL)
Definition: SemaObjC.cpp:1602
ObjCInterfaceDecl * NSNumberDecl
The declaration of the Objective-C NSNumber class.
Definition: SemaObjC.h:604
void CheckObjCBridgeRelatedCast(QualType castType, Expr *castExpr)
ExprResult BuildObjCBoxedExpr(SourceRange SR, Expr *ValueExpr)
BuildObjCBoxedExpr - builds an ObjCBoxedExpr AST node for the '@' prefixed parenthesized expression.
StmtResult ActOnObjCAtTryStmt(SourceLocation AtLoc, Stmt *Try, MultiStmtArg Catch, Stmt *Finally)
Definition: SemaObjC.cpp:223
void WarnConflictingTypedMethods(ObjCMethodDecl *Method, ObjCMethodDecl *MethodDecl, bool IsProtocolMethodDecl)
void handleOwnershipAttr(Decl *D, const ParsedAttr &AL)
Definition: SemaObjC.cpp:2140
ObjCInterfaceDecl * NSValueDecl
The declaration of the Objective-C NSValue class.
Definition: SemaObjC.h:607
bool isSignedCharBool(QualType Ty)
Definition: SemaObjC.cpp:2308
Selector RespondsToSelectorSel
will hold 'respondsToSelector:'
Definition: SemaObjC.h:646
void handleBlocksAttr(Decl *D, const ParsedAttr &AL)
Definition: SemaObjC.cpp:1702
bool MatchTwoMethodDeclarations(const ObjCMethodDecl *Method, const ObjCMethodDecl *PrevMethod, MethodMatchStrategy strategy=MMS_strict)
MatchTwoMethodDeclarations - Checks if two methods' type match and returns true, or false,...
Decl * ActOnMethodDeclaration(Scope *S, SourceLocation BeginLoc, SourceLocation EndLoc, tok::TokenKind MethodType, ObjCDeclSpec &ReturnQT, ParsedType ReturnType, ArrayRef< SourceLocation > SelectorLocs, Selector Sel, ObjCArgInfo *ArgInfo, DeclaratorChunk::ParamInfo *CParamInfo, unsigned CNumArgs, const ParsedAttributesView &AttrList, tok::ObjCKeywordKind MethodImplKind, bool isVariadic, bool MethodDefinition)
bool CheckMessageArgumentTypes(const Expr *Receiver, QualType ReceiverType, MultiExprArg Args, Selector Sel, ArrayRef< SourceLocation > SelectorLocs, ObjCMethodDecl *Method, bool isClassMessage, bool isSuperMessage, SourceLocation lbrac, SourceLocation rbrac, SourceRange RecRange, QualType &ReturnType, ExprValueKind &VK)
CheckMessageArgumentTypes - Check types in an Obj-C message send.
ObjCInterfaceDecl * NSStringDecl
The declaration of the Objective-C NSString class.
Definition: SemaObjC.h:619
StmtResult ActOnObjCAtFinallyStmt(SourceLocation AtLoc, Stmt *Body)
Definition: SemaObjC.cpp:218
void MatchAllMethodDeclarations(const SelectorSet &InsMap, const SelectorSet &ClsMap, SelectorSet &InsMapSeen, SelectorSet &ClsMapSeen, ObjCImplDecl *IMPDecl, ObjCContainerDecl *IDecl, bool &IncompleteImpl, bool ImmediateClass, bool WarnCategoryMethodImpl=false)
MatchAllMethodDeclarations - Check methods declaraed in interface or or protocol against those declar...
llvm::MapVector< Selector, SourceLocation > ReferencedSelectors
Method selectors used in a @selector expression.
Definition: SemaObjC.h:209
void DiagnoseOwningPropertyGetterSynthesis(const ObjCImplementationDecl *D)
ObjCMethodDecl * LookupFactoryMethodInGlobalPool(Selector Sel, SourceRange R, bool receiverIdOrClass=false)
LookupFactoryMethodInGlobalPool - Returns the method and warns if there are multiple signatures.
Definition: SemaObjC.h:873
void ActOnObjCContainerFinishDefinition()
Definition: SemaObjC.cpp:1283
ObjCMethodDecl * StringWithUTF8StringMethod
The declaration of the stringWithUTF8String: method.
Definition: SemaObjC.h:625
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:341
Decl * ActOnCompatibilityAlias(SourceLocation AtCompatibilityAliasLoc, IdentifierInfo *AliasName, SourceLocation AliasLocation, IdentifierInfo *ClassName, SourceLocation ClassLocation)
ActOnCompatibilityAlias - this action is called after complete parsing of a @compatibility_alias decl...
void DiagnoseDuplicateIvars(ObjCInterfaceDecl *ID, ObjCInterfaceDecl *SID)
DiagnoseDuplicateIvars - Check for duplicate ivars in the entire class at the start of @implementatio...
StmtResult BuildObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw)
Definition: SemaObjC.cpp:243
bool checkInitMethod(ObjCMethodDecl *method, QualType receiverTypeIfCall)
Check whether the given method, which must be in the 'init' family, is a valid member of that family.
void handleBridgeMutableAttr(Decl *D, const ParsedAttr &AL)
Definition: SemaObjC.cpp:2053
Sema::RetainOwnershipKind parsedAttrToRetainOwnershipKind(const ParsedAttr &AL)
Definition: SemaObjC.cpp:1774
void CheckConflictingOverridingMethod(ObjCMethodDecl *Method, ObjCMethodDecl *Overridden, bool IsProtocolMethodDecl)
QualType FindCompositeObjCPointerType(ExprResult &LHS, ExprResult &RHS, SourceLocation QuestionLoc)
FindCompositeObjCPointerType - Helper method to find composite type of two objective-c pointer types ...
void handleRequiresSuperAttr(Decl *D, const ParsedAttr &Attrs)
Definition: SemaObjC.cpp:1973
ExprResult BuildObjCStringLiteral(SourceLocation AtLoc, StringLiteral *S)
ObjCTypeParamList * actOnObjCTypeParamList(Scope *S, SourceLocation lAngleLoc, ArrayRef< Decl * > typeParams, SourceLocation rAngleLoc)
ObjCInterfaceDecl * NSDictionaryDecl
The declaration of the Objective-C NSDictionary class.
Definition: SemaObjC.h:637
ObjCMethodDecl * ArrayWithObjectsMethod
The declaration of the arrayWithObjects:count: method.
Definition: SemaObjC.h:634
ObjCCategoryDecl * ActOnStartCategoryInterface(SourceLocation AtInterfaceLoc, const IdentifierInfo *ClassName, SourceLocation ClassLoc, ObjCTypeParamList *typeParamList, const IdentifierInfo *CategoryName, SourceLocation CategoryLoc, Decl *const *ProtoRefs, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList)
ExprResult ParseObjCEncodeExpression(SourceLocation AtLoc, SourceLocation EncodeLoc, SourceLocation LParenLoc, ParsedType Ty, SourceLocation RParenLoc)
QualType QIDNSCopying
id<NSCopying> type.
Definition: SemaObjC.h:643
bool CheckObjCString(Expr *Arg)
CheckObjCString - Checks that the argument to the builtin CFString constructor is correct Note: It mi...
Definition: SemaObjC.cpp:1218
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:712
void actOnObjCTypeArgsOrProtocolQualifiers(Scope *S, ParsedType baseType, SourceLocation lAngleLoc, ArrayRef< IdentifierInfo * > identifiers, ArrayRef< SourceLocation > identifierLocs, SourceLocation rAngleLoc, SourceLocation &typeArgsLAngleLoc, SmallVectorImpl< ParsedType > &typeArgs, SourceLocation &typeArgsRAngleLoc, SourceLocation &protocolLAngleLoc, SmallVectorImpl< Decl * > &protocols, SourceLocation &protocolRAngleLoc, bool warnOnIncompleteProtocols)
Given a list of identifiers (and their locations), resolve the names to either Objective-C protocol q...
Decl * ActOnProperty(Scope *S, SourceLocation AtLoc, SourceLocation LParenLoc, FieldDeclarator &FD, ObjCDeclSpec &ODS, Selector GetterSel, Selector SetterSel, tok::ObjCKeywordKind MethodImplKind, DeclContext *lexicalDC=nullptr)
bool CheckForwardProtocolDeclarationForCircularDependency(IdentifierInfo *PName, SourceLocation &PLoc, SourceLocation PrevLoc, const ObjCList< ObjCProtocolDecl > &PList)
void DiagnoseUnimplementedProperties(Scope *S, ObjCImplDecl *IMPDecl, ObjCContainerDecl *CDecl, bool SynthesizeProperties)
DiagnoseUnimplementedProperties - This routine warns on those properties which must be implemented by...
void AtomicPropertySetterGetterRules(ObjCImplDecl *IMPDecl, ObjCInterfaceDecl *IDecl)
AtomicPropertySetterGetterRules - This routine enforces the rule (via warning) when atomic property h...
ExprResult ActOnClassMessage(Scope *S, ParsedType Receiver, Selector Sel, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args)
ExprResult ActOnObjCAtSynchronizedOperand(SourceLocation atLoc, Expr *operand)
Definition: SemaObjC.cpp:287
void DiagnoseClassExtensionDupMethods(ObjCCategoryDecl *CAT, ObjCInterfaceDecl *ID)
DiagnoseClassExtensionDupMethods - Check for duplicate declaration of a class method in its extension...
void CheckTollFreeBridgeCast(QualType castType, Expr *castExpr)
bool CheckConversionToObjCLiteral(QualType DstType, Expr *&SrcExpr, bool Diagnose=true)
ObjCCategoryImplDecl * ActOnStartCategoryImplementation(SourceLocation AtCatImplLoc, const IdentifierInfo *ClassName, SourceLocation ClassLoc, const IdentifierInfo *CatName, SourceLocation CatLoc, const ParsedAttributesView &AttrList)
ActOnStartCategoryImplementation - Perform semantic checks on the category implementation declaration...
ObjCMethodDecl * tryCaptureObjCSelf(SourceLocation Loc)
Try to capture an implicit reference to 'self'.
ExprResult ParseObjCStringLiteral(SourceLocation *AtLocs, ArrayRef< Expr * > Strings)
bool inferObjCARCLifetime(ValueDecl *decl)
void AddXConsumedAttr(Decl *D, const AttributeCommonInfo &CI, Sema::RetainOwnershipKind K, bool IsTemplateInstantiation)
Definition: SemaObjC.cpp:1740
void adornBoolConversionDiagWithTernaryFixit(Expr *SourceExpr, const Sema::SemaDiagnosticBuilder &Builder)
Definition: SemaObjC.cpp:2313
void CheckObjCMethodOverride(ObjCMethodDecl *NewMethod, const ObjCMethodDecl *Overridden)
Check whether the given new method is a valid override of the given overridden method,...
const DeclContext * getCurObjCLexicalContext() const
Definition: SemaObjC.cpp:1260
void handleDesignatedInitializer(Decl *D, const ParsedAttr &AL)
Definition: SemaObjC.cpp:2080
void handleBridgeRelatedAttr(Decl *D, const ParsedAttr &AL)
Definition: SemaObjC.cpp:2065
ExprResult ActOnObjCBoolLiteral(SourceLocation AtLoc, SourceLocation ValueLoc, bool Value)
Decl * ActOnPropertyImplDecl(Scope *S, SourceLocation AtLoc, SourceLocation PropertyLoc, bool ImplKind, IdentifierInfo *PropertyId, IdentifierInfo *PropertyIvar, SourceLocation PropertyIvarLoc, ObjCPropertyQueryKind QueryKind)
ActOnPropertyImplDecl - This routine performs semantic checks and builds the AST node for a property ...
void handleIBOutletCollection(Decl *D, const ParsedAttr &AL)
Definition: SemaObjC.cpp:1556
ObjCMethodDecl * DictionaryWithObjectsMethod
The declaration of the dictionaryWithObjects:forKeys:count: method.
Definition: SemaObjC.h:640
void ActOnTypedefedProtocols(SmallVectorImpl< Decl * > &ProtocolRefs, SmallVectorImpl< SourceLocation > &ProtocolLocs, IdentifierInfo *SuperName, SourceLocation SuperLoc)
ActOnTypedefedProtocols - this action finds protocol list as part of the typedef'ed use for a qualifi...
void DiagnoseMissingDesignatedInitOverrides(const ObjCImplementationDecl *ImplD, const ObjCInterfaceDecl *IFD)
void CollectIvarsToConstructOrDestruct(ObjCInterfaceDecl *OI, SmallVectorImpl< ObjCIvarDecl * > &Ivars)
CollectIvarsToConstructOrDestruct - Collect those ivars which require initialization.
QualType NSStringPointer
Pointer to NSString type (NSString *).
Definition: SemaObjC.h:622
ExprResult BuildObjCBridgedCast(SourceLocation LParenLoc, ObjCBridgeCastKind Kind, SourceLocation BridgeKeywordLoc, TypeSourceInfo *TSInfo, Expr *SubExpr)
DeclGroupPtrTy ActOnForwardProtocolDeclaration(SourceLocation AtProtoclLoc, ArrayRef< IdentifierLocPair > IdentList, const ParsedAttributesView &attrList)
ActOnForwardProtocolDeclaration - Handle @protocol foo;.
ObjCProtocolDecl * LookupProtocol(IdentifierInfo *II, SourceLocation IdLoc, RedeclarationKind Redecl=RedeclarationKind::NotForRedeclaration)
Find the protocol with the given name, if any.
Definition: SemaObjC.cpp:1301
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:2271
bool isCFStringType(QualType T)
Definition: SemaObjC.cpp:1509
QualType NSNumberPointer
Pointer to NSNumber type (NSNumber *).
Definition: SemaObjC.h:610
void CheckObjCPropertyAttributes(Decl *PropertyPtrTy, SourceLocation Loc, unsigned &Attributes, bool propertyInPrimaryClass)
Ensure attributes are consistent with type.
DeclResult LookupIvarInObjCMethod(LookupResult &Lookup, Scope *S, IdentifierInfo *II)
The parser has read a name in, and Sema has detected that we're currently inside an ObjC method.
ObjCMethodDecl * NSNumberLiteralMethods[NSAPI::NumNSNumberLiteralMethods]
The Objective-C NSNumber methods used to create NSNumber literals.
Definition: SemaObjC.h:616
void handleDirectAttr(Decl *D, const ParsedAttr &AL)
Definition: SemaObjC.cpp:1613
QualType AdjustParameterTypeForObjCAutoRefCount(QualType T, SourceLocation NameLoc, TypeSourceInfo *TSInfo)
GlobalMethodPool MethodPool
Method Pool - allows efficient lookup when typechecking messages to "id".
Definition: SemaObjC.h:234
StmtResult ActOnObjCAtThrowStmt(SourceLocation AtLoc, Expr *Throw, Scope *CurScope)
Definition: SemaObjC.cpp:270
ObjCProtocolDecl * ActOnStartProtocolInterface(SourceLocation AtProtoInterfaceLoc, IdentifierInfo *ProtocolName, SourceLocation ProtocolLoc, Decl *const *ProtoRefNames, unsigned NumProtoRefs, const SourceLocation *ProtoLocs, SourceLocation EndProtoLoc, const ParsedAttributesView &AttrList, SkipBodyInfo *SkipBody)
Decl * ActOnAtEnd(Scope *S, SourceRange AtEnd, ArrayRef< Decl * > allMethods=std::nullopt, ArrayRef< DeclGroupPtrTy > allTUVars=std::nullopt)
ResultTypeCompatibilityKind
Describes the compatibility of a result type with its method.
Definition: SemaObjC.h:391
void DiagnoseMultipleMethodInGlobalPool(SmallVectorImpl< ObjCMethodDecl * > &Methods, Selector Sel, SourceRange R, bool receiverIdOrClass)
QualType getMessageSendResultType(const Expr *Receiver, QualType ReceiverType, ObjCMethodDecl *Method, bool isClassMessage, bool isSuperMessage)
Determine the result of a message send expression based on the type of the receiver,...
ExprResult ParseObjCProtocolExpression(IdentifierInfo *ProtocolName, SourceLocation AtLoc, SourceLocation ProtoLoc, SourceLocation LParenLoc, SourceLocation ProtoIdLoc, SourceLocation RParenLoc)
ParseObjCProtocolExpression - Build protocol expression for @protocol.
DeclGroupPtrTy ActOnForwardClassDeclaration(SourceLocation Loc, IdentifierInfo **IdentList, SourceLocation *IdentLocs, ArrayRef< ObjCTypeParamList * > TypeParamLists, unsigned NumElts)
@ OSMK_NonRetainingInit
Definition: SemaObjC.h:204
ExprResult BuildInstanceMessageImplicit(Expr *Receiver, QualType ReceiverType, SourceLocation Loc, Selector Sel, ObjCMethodDecl *Method, MultiExprArg Args)
void checkRetainCycles(ObjCMessageExpr *msg)
checkRetainCycles - Check whether an Objective-C message send might create an obvious retain cycle.
Definition: SemaObjC.cpp:1161
StmtResult ActOnObjCAtCatchStmt(SourceLocation AtLoc, SourceLocation RParen, Decl *Parm, Stmt *Body)
Definition: SemaObjC.cpp:207
ObjCMessageKind
Describes the kind of message expression indicated by a message send that starts with an identifier.
Definition: SemaObjC.h:718
@ ObjCClassMessage
The message is a class message, and the identifier is a type name.
Definition: SemaObjC.h:725
@ ObjCInstanceMessage
The message is an instance message.
Definition: SemaObjC.h:722
@ ObjCSuperMessage
The message is sent to 'super'.
Definition: SemaObjC.h:720
ExprResult LookupInObjCMethod(LookupResult &LookUp, Scope *S, IdentifierInfo *II, bool AllowBuiltinCreation=false)
The parser has read a name in, and Sema has detected that we're currently inside an ObjC method.
QualType NSValuePointer
Pointer to NSValue type (NSValue *).
Definition: SemaObjC.h:613
bool isNSStringType(QualType T, bool AllowNSAttributedString=false)
Definition: SemaObjC.cpp:1490
bool isObjCMethodDecl(Decl *D)
Definition: SemaObjC.h:409
void EmitRelatedResultTypeNote(const Expr *E)
If the given expression involves a message send to a method with a related result type,...
OpaquePtr< DeclGroupRef > DeclGroupPtrTy
Definition: SemaObjC.h:317
ExprResult ActOnInstanceMessage(Scope *S, Expr *Receiver, Selector Sel, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args)
bool GetFormatNSStringIdx(const FormatAttr *Format, unsigned &Idx)
Definition: SemaObjC.cpp:2259
void ReadMethodPool(Selector Sel)
Read the contents of the method pool for a given selector from external storage.
void ActOnDefs(Scope *S, Decl *TagD, SourceLocation DeclStart, const IdentifierInfo *ClassName, SmallVectorImpl< Decl * > &Decls)
Called whenever @defs(ClassName) is encountered in the source.
ExprResult BuildIvarRefExpr(Scope *S, SourceLocation Loc, ObjCIvarDecl *IV)
void AddFactoryMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
AddFactoryMethodToGlobalPool - Same as above, but for factory methods.
Definition: SemaObjC.h:540
ExprResult ActOnSuperMessage(Scope *S, SourceLocation SuperLoc, Selector Sel, SourceLocation LBracLoc, ArrayRef< SourceLocation > SelectorLocs, SourceLocation RBracLoc, MultiExprArg Args)
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:1447
void DiagnoseTypeArgsAndProtocols(IdentifierInfo *ProtocolId, SourceLocation ProtocolLoc, IdentifierInfo *TypeArgId, SourceLocation TypeArgLoc, bool SelectProtocolFirst=false)
CastKind PrepareCastToObjCObjectPointer(ExprResult &E)
Prepare a conversion of the given expression to an ObjC object pointer type.
bool CollectMultipleMethodsInGlobalPool(Selector Sel, SmallVectorImpl< ObjCMethodDecl * > &Methods, bool InstanceFirst, bool CheckTheOther, const ObjCObjectType *TypeBound=nullptr)
We first select the type of the method: Instance or Factory, then collect all methods with that type.
void CheckObjCMethodDirectOverrides(ObjCMethodDecl *method, ObjCMethodDecl *overridden)
void DiagnoseUseOfUnimplementedSelectors()
bool checkObjCBridgeRelatedComponents(SourceLocation Loc, QualType DestType, QualType SrcType, ObjCInterfaceDecl *&RelatedClass, ObjCMethodDecl *&ClassMethod, ObjCMethodDecl *&InstanceMethod, TypedefNameDecl *&TDNDecl, bool CfToNs, bool Diagnose=true)
void checkDictionaryLiteral(QualType TargetType, ObjCDictionaryLiteral *DictionaryLiteral)
Check an Objective-C dictionary literal being converted to the given target type.
Definition: SemaObjC.cpp:2382
void DiagnosePropertyMismatch(ObjCPropertyDecl *Property, ObjCPropertyDecl *SuperProperty, const IdentifierInfo *Name, bool OverridingProtocolProperty)
DiagnosePropertyMismatch - Compares two properties for their attributes and types and warns on a vari...
void handleBoxable(Decl *D, const ParsedAttr &AL)
Definition: SemaObjC.cpp:2118
bool checkNSReturnsRetainedReturnType(SourceLocation loc, QualType type)
Definition: SemaObjC.cpp:1798
void EmitRelatedResultTypeNoteForReturn(QualType destType)
Given that we had incompatible pointer types in a return statement, check whether we're in a method w...
void diagnoseARCUnbridgedCast(Expr *e)
Given that we saw an expression with the ARCUnbridgedCastTy placeholder type, complain bitterly.
void CheckCategoryVsClassMethodMatches(ObjCCategoryImplDecl *CatIMP)
CheckCategoryVsClassMethodMatches - Checks that methods implemented in category matches with those im...
void ImplMethodsVsClassMethods(Scope *S, ObjCImplDecl *IMPDecl, ObjCContainerDecl *IDecl, bool IncompleteImpl=false)
ImplMethodsVsClassMethods - This is main routine to warn if any method remains unimplemented in the c...
void CheckObjCMethodOverrides(ObjCMethodDecl *ObjCMethod, ObjCInterfaceDecl *CurrentClass, ResultTypeCompatibilityKind RTC)
ObjCMethodDecl * LookupMethodInQualifiedType(Selector Sel, const ObjCObjectPointerType *OPT, bool IsInstance)
LookupMethodInQualifiedType - Lookups up a method in protocol qualifier list of a qualified objective...
bool CheckTollFreeBridgeStaticCast(QualType castType, Expr *castExpr, CastKind &Kind)
StmtResult ActOnObjCAutoreleasePoolStmt(SourceLocation AtLoc, Stmt *Body)
Definition: SemaObjC.cpp:334
void CheckImplementationIvars(ObjCImplementationDecl *ImpDecl, ObjCIvarDecl **Fields, unsigned nIvars, SourceLocation Loc)
CheckImplementationIvars - This routine checks if the instance variables listed in the implelementati...
bool CheckObjCARCUnavailableWeakConversion(QualType castType, QualType ExprType)
ObjCMethodDecl * LookupImplementedMethodInGlobalPool(Selector Sel)
LookupImplementedMethodInGlobalPool - Returns the method which has an implementation.
void handleDirectMembersAttr(Decl *D, const ParsedAttr &AL)
Definition: SemaObjC.cpp:1627
bool CheckObjCMethodCall(ObjCMethodDecl *Method, SourceLocation loc, ArrayRef< const Expr * > Args)
Definition: SemaObjC.cpp:1246
Expr * stripARCUnbridgedCast(Expr *e)
stripARCUnbridgedCast - Given an expression of ARCUnbridgedCast type, remove the placeholder cast.
ExprResult BuildObjCSubscriptExpression(SourceLocation RB, Expr *BaseExpr, Expr *IndexExpr, ObjCMethodDecl *getterMethod, ObjCMethodDecl *setterMethod)
Build an ObjC subscript pseudo-object expression, given that that's supported by the runtime.
void AddInstanceMethodToGlobalPool(ObjCMethodDecl *Method, bool impl=false)
AddInstanceMethodToGlobalPool - All instance methods in a translation unit are added to a global pool...
Definition: SemaObjC.h:534
void handleBridgeAttr(Decl *D, const ParsedAttr &AL)
Definition: SemaObjC.cpp:2026
void AddAnyMethodToGlobalPool(Decl *D)
AddAnyMethodToGlobalPool - Add any method, instance or factory to global pool.
@ OCK_CategoryImplementation
Definition: SemaObjC.h:247
bool isSelfExpr(Expr *RExpr)
Private Helper predicate to check for 'self'.
void handlePreciseLifetimeAttr(Decl *D, const ParsedAttr &AL)
Definition: SemaObjC.cpp:2149
ExprResult ActOnObjCAvailabilityCheckExpr(llvm::ArrayRef< AvailabilitySpec > AvailSpecs, SourceLocation AtLoc, SourceLocation RParen)
bool isKnownName(StringRef name)
std::unique_ptr< NSAPI > NSAPIObj
Caches identifiers/selectors for NSFoundation APIs.
Definition: SemaObjC.h:601
void ActOnObjCContainerStartDefinition(ObjCContainerDecl *IDecl)
Definition: SemaObjC.cpp:1276
void FindProtocolDeclaration(bool WarnOnDeclarations, bool ForObjCContainer, ArrayRef< IdentifierLocPair > ProtocolId, SmallVectorImpl< Decl * > &Protocols)
FindProtocolDeclaration - This routine looks up protocols and issues an error if they are not declare...
Sema - This implements semantic analysis and AST building for C.
Definition: Sema.h:493
RetainOwnershipKind
Definition: Sema.h:4620
Encodes a location in the source.
A trivial tuple used to represent a source range.
Stmt - This represents one statement.
Definition: Stmt.h:84
StringLiteral - This represents a string literal expression, e.g.
Definition: Expr.h:1778
A container of type source information.
Definition: Type.h:7726
The base class of the type hierarchy.
Definition: Type.h:1829
Base class for declarations which introduce a typedef-name.
Definition: Decl.h:3409
Simple class containing the result of Sema::CorrectTypo.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
Definition: Decl.h:667
Represents a variable declaration or definition.
Definition: Decl.h:879
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
const internal::VariadicAllOfMatcher< Decl > decl
Matches declarations.
const internal::VariadicDynCastAllOfMatcher< Stmt, CastExpr > castExpr
Matches any cast nodes of Clang's AST.
ObjCKeywordKind
Provides a namespace for Objective-C keywords which start with an '@'.
Definition: TokenKinds.h:41
TokenKind
Provides a simple uniform namespace for tokens from all C languages.
Definition: TokenKinds.h:25
The JSON file list parser is used to communicate input to InstallAPI.
ObjCPropertyQueryKind
Definition: DeclObjC.h:718
BinaryOperatorKind
@ Property
The type of a property.
ObjCBridgeCastKind
The kind of bridging performed by the Objective-C bridge cast.
CastKind
CastKind - The kind of operation required for a conversion.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
Definition: Specifiers.h:132
const FunctionProtoType * T
ObjCTypeParamVariance
Describes the variance of a given generic parameter.
Definition: DeclObjC.h:553
CheckedConversionKind
The kind of conversion being performed.
Definition: Sema.h:414
ParamInfo - An array of paraminfo objects is allocated whenever a function declarator is parsed.
Definition: DeclSpec.h:1333
This little struct is used to capture information about structure field declarators,...
Definition: DeclSpec.h:2773
a linked list of methods with the same selector name but different signatures.
ParsedAttributesView ArgAttrs
ArgAttrs - Attribute list for this argument.
Definition: SemaObjC.h:365
IdentifierInfo * Name
Definition: SemaObjC.h:357
SourceLocation NameLoc
Definition: SemaObjC.h:358