20#include "llvm/ADT/SmallVector.h"
21#include "llvm/Support/ErrorHandling.h"
31 NumElements(Elements.size()),
Range(SR), ArrayWithObjectsMethod(Method) {
32 Expr **SaveElements = getElements();
33 for (
unsigned I = 0, N = Elements.size(); I != N; ++I)
34 SaveElements[I] = Elements[I];
43 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(Elements.size()));
48 unsigned NumElements) {
49 void *Mem =
C.Allocate(totalSizeToAlloc<Expr *>(NumElements));
58 NumElements(VK.size()), HasPackExpansions(HasPackExpansions),
Range(SR),
59 DictWithObjectsMethod(method) {
60 KeyValuePair *KeyValues = getTrailingObjects<KeyValuePair>();
61 ExpansionData *Expansions =
62 HasPackExpansions ? getTrailingObjects<ExpansionData>() : nullptr;
63 for (
unsigned I = 0; I < NumElements; I++) {
64 KeyValues[I].Key = VK[I].Key;
65 KeyValues[I].Value = VK[I].Value;
67 Expansions[I].EllipsisLoc = VK[I].EllipsisLoc;
68 if (VK[I].NumExpansions)
69 Expansions[I].NumExpansionsPlusOne = *VK[I].NumExpansions + 1;
71 Expansions[I].NumExpansionsPlusOne = 0;
82 void *Mem =
C.Allocate(totalSizeToAlloc<KeyValuePair, ExpansionData>(
83 VK.size(), HasPackExpansions ? VK.size() : 0));
89 bool HasPackExpansions) {
90 void *Mem =
C.Allocate(totalSizeToAlloc<KeyValuePair, ExpansionData>(
91 NumElements, HasPackExpansions ? NumElements : 0));
116 reinterpret_cast<
uintptr_t>(Method ? Method : Sel.getAsOpaquePtr())),
117 Kind(IsInstanceSuper ? SuperInstance : SuperClass),
118 HasMethod(Method != nullptr), IsDelegateInitCall(
false),
119 IsImplicit(isImplicit), SuperLoc(SuperLoc), LBracLoc(LBracLoc),
121 initArgsAndSelLocs(Args, SelLocs, SelLocsK);
135 reinterpret_cast<
uintptr_t>(Method ? Method : Sel.getAsOpaquePtr())),
136 Kind(
Class), HasMethod(Method != nullptr), IsDelegateInitCall(
false),
137 IsImplicit(isImplicit), LBracLoc(LBracLoc), RBracLoc(RBracLoc) {
138 initArgsAndSelLocs(Args, SelLocs, SelLocsK);
139 setReceiverPointer(Receiver);
151 reinterpret_cast<
uintptr_t>(Method ? Method : Sel.getAsOpaquePtr())),
152 Kind(Instance), HasMethod(Method != nullptr), IsDelegateInitCall(
false),
153 IsImplicit(isImplicit), LBracLoc(LBracLoc), RBracLoc(RBracLoc) {
154 initArgsAndSelLocs(Args, SelLocs, SelLocsK);
155 setReceiverPointer(Receiver);
162 setNumArgs(Args.size());
164 for (
unsigned I = 0; I != Args.size(); ++I)
167 SelLocsKind = SelLocsK;
170 std::copy(SelLocs.begin(), SelLocs.end(), getStoredSelLocs());
182 "No selector locs for non-implicit message");
186 Mem = alloc(Context, Args.size(), 0);
188 Mem = alloc(Context, Args, RBracLoc, SelLocs, Sel, SelLocsK);
189 return new (Mem)
ObjCMessageExpr(
T, VK, LBracLoc, SuperLoc, IsInstanceSuper,
190 SuperType, Sel, SelLocs, SelLocsK, Method,
201 "No selector locs for non-implicit message");
205 Mem = alloc(Context, Args.size(), 0);
207 Mem = alloc(Context, Args, RBracLoc, SelLocs, Sel, SelLocsK);
220 "No selector locs for non-implicit message");
224 Mem = alloc(Context, Args.size(), 0);
226 Mem = alloc(Context, Args, RBracLoc, SelLocs, Sel, SelLocsK);
234 unsigned NumStoredSelLocs) {
246 unsigned NumStoredSelLocs =
248 return alloc(
C, Args.size(), NumStoredSelLocs);
252 unsigned NumStoredSelLocs) {
254 totalSizeToAlloc<void *, SourceLocation>(NumArgs + 1, NumStoredSelLocs),
290 llvm_unreachable(
"Invalid ReceiverKind!");
311 llvm_unreachable(
"unexpected receiver kind");
318 return Ptr->getInterfaceDecl();
321 return Ty->getInterface();
329 begin =
reinterpret_cast<Stmt **
>(getTrailingObjects<void *>());
346 return "__bridge_transfer";
348 return "__bridge_retained";
351 llvm_unreachable(
"Invalid BridgeKind!");
Defines the clang::ASTContext interface.
Defines the clang::TypeLoc interface and its subclasses.
C Language Family Type Representation.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl.
QualType getReferenceQualifiedType(const Expr *e) const
getReferenceQualifiedType - Given an expr, will return the type for that expression,...
QualType getObjCInstanceType()
Retrieve the Objective-C "instancetype" type, if already known; otherwise, returns a NULL type;.
This represents one expression.
void setDependence(ExprDependence Deps)
Each concrete expr subclass is expected to compute its dependence and call this in the constructor.
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp,...
static ObjCArrayLiteral * CreateEmpty(const ASTContext &C, unsigned NumElements)
static ObjCArrayLiteral * Create(const ASTContext &C, ArrayRef< Expr * > Elements, QualType T, ObjCMethodDecl *Method, SourceRange SR)
StringRef getBridgeKindName() const
Retrieve the kind of bridge being performed as a string.
ObjCBridgeCastKind getBridgeKind() const
Determine which kind of bridge is being performed via this cast.
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
static ObjCDictionaryLiteral * Create(const ASTContext &C, ArrayRef< ObjCDictionaryElement > VK, bool HasPackExpansions, QualType T, ObjCMethodDecl *method, SourceRange SR)
static ObjCDictionaryLiteral * CreateEmpty(const ASTContext &C, unsigned NumElements, bool HasPackExpansions)
Represents an ObjC class declaration.
An expression that sends a message to the given Objective-C object or class.
static ObjCMessageExpr * Create(const ASTContext &Context, QualType T, ExprValueKind VK, SourceLocation LBracLoc, SourceLocation SuperLoc, bool IsInstanceSuper, QualType SuperType, Selector Sel, ArrayRef< SourceLocation > SelLocs, ObjCMethodDecl *Method, ArrayRef< Expr * > Args, SourceLocation RBracLoc, bool isImplicit)
Create a message send to super.
void getSelectorLocs(SmallVectorImpl< SourceLocation > &SelLocs) const
bool isImplicit() const
Indicates whether the message send was implicitly generated by the implementation.
static ObjCMessageExpr * CreateEmpty(const ASTContext &Context, unsigned NumArgs, unsigned NumStoredSelLocs)
Create an empty Objective-C message expression, to be filled in by subsequent calls.
Expr ** getArgs()
Retrieve the arguments to this message, not including the receiver.
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
QualType getCallReturnType(ASTContext &Ctx) const
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.
@ SuperClass
The receiver is a superclass.
@ Class
The receiver is a class.
TypeSourceInfo * getClassReceiverTypeInfo() const
Returns a type-source information of a class message send, or nullptr if the message is not a class m...
QualType getClassReceiver() const
Returns the type of a class message send, or NULL if the message is not a class message.
ObjCInterfaceDecl * getReceiverInterface() const
Retrieve the Objective-C interface to which this message is being directed, if known.
QualType getSuperType() const
Retrieve the type referred to by 'super'.
const ObjCMethodDecl * getMethodDecl() const
SourceRange getReceiverRange() const
Source range of the receiver.
unsigned getNumSelectorLocs() const
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
QualType getReceiverType() const
Retrieve the receiver type to which this message is being directed.
SourceLocation getSelectorLoc(unsigned Index) const
unsigned getNumArgs() const
Return the number of actual arguments in this message, not counting the receiver.
ObjCMethodDecl - Represents an instance or class method declaration.
Represents a pointer to an Objective C object.
Represents a class type in Objective C.
const Expr * getBase() const
QualType getSuperReceiverType() const
ObjCInterfaceDecl * getClassReceiver() const
QualType getReceiverType(const ASTContext &ctx) const
Determine the type of the base, regardless of the kind of receiver.
bool isClassReceiver() const
bool isSuperReceiver() const
A (possibly-)qualified type.
void * getAsOpaquePtr() const
Smart pointer class that efficiently represents Objective-C method names.
Encodes a location in the source.
A trivial tuple used to represent a source range.
Stmt - This represents one statement.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
llvm::iterator_range< child_iterator > child_range
llvm::iterator_range< const_child_iterator > const_child_range
SourceRange getSourceRange() const LLVM_READONLY
Get the full source range.
A container of type source information.
TypeLoc getTypeLoc() const
Return the TypeLoc wrapper for the type source info.
const T * getAs() const
Member-template getAs<specific type>'.
The JSON file list parser is used to communicate input to InstallAPI.
SelectorLocationsKind
Whether all locations of the selector identifiers are in a "standard" position.
@ SelLoc_NonStandard
Non-standard.
@ OK_Ordinary
An ordinary object is located at an address in memory.
ExprDependence computeDependence(FullExpr *E)
SelectorLocationsKind hasStandardSelectorLocs(Selector Sel, ArrayRef< SourceLocation > SelLocs, ArrayRef< Expr * > Args, SourceLocation EndLoc)
Returns true if all SelLocs are in a "standard" location.
@ OBC_Bridge
Bridging via __bridge, which does nothing but reinterpret the bits.
@ OBC_BridgeTransfer
Bridging via __bridge_transfer, which transfers ownership of an Objective-C pointer into ARC.
@ OBC_BridgeRetained
Bridging via __bridge_retain, which makes an ARC object available as a +1 C pointer.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
@ VK_PRValue
A pr-value expression (in the C++11 taxonomy) produces a temporary value.
const FunctionProtoType * T
@ Class
The "class" keyword introduces the elaborated-type-specifier.
__UINTPTR_TYPE__ uintptr_t
An unsigned integer type with the property that any valid pointer to void can be converted to this ty...
A placeholder type used to construct an empty shell of a type, that will be filled in later (e....