19 #include "llvm/ADT/SmallVector.h" 20 #include "llvm/Support/ErrorHandling.h" 25 using namespace clang;
31 NumElements(Elements.size()), Range(SR), ArrayWithObjectsMethod(Method) {
32 Expr **SaveElements = getElements();
33 for (
unsigned I = 0, N = Elements.size(); I != N; ++I) {
37 ExprBits.InstantiationDependent =
true;
39 ExprBits.ContainsUnexpandedParameterPack =
true;
41 SaveElements[I] = Elements[I];
49 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(Elements.size()));
54 unsigned NumElements) {
55 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(NumElements));
65 NumElements(VK.size()), HasPackExpansions(HasPackExpansions), Range(SR),
66 DictWithObjectsMethod(method) {
67 KeyValuePair *KeyValues = getTrailingObjects<KeyValuePair>();
68 ExpansionData *Expansions =
69 HasPackExpansions ? getTrailingObjects<ExpansionData>() :
nullptr;
70 for (
unsigned I = 0; I < NumElements; I++) {
71 if (VK[I].Key->isTypeDependent() || VK[I].Key->isValueDependent() ||
72 VK[I].Value->isTypeDependent() || VK[I].Value->isValueDependent())
74 if (VK[I].Key->isInstantiationDependent() ||
75 VK[I].Value->isInstantiationDependent())
76 ExprBits.InstantiationDependent =
true;
77 if (VK[I].EllipsisLoc.isInvalid() &&
78 (VK[I].Key->containsUnexpandedParameterPack() ||
79 VK[I].Value->containsUnexpandedParameterPack()))
80 ExprBits.ContainsUnexpandedParameterPack =
true;
82 KeyValues[I].Key = VK[I].Key;
83 KeyValues[I].Value = VK[I].Value;
85 Expansions[I].EllipsisLoc = VK[I].EllipsisLoc;
86 if (VK[I].NumExpansions)
87 Expansions[I].NumExpansionsPlusOne = *VK[I].NumExpansions + 1;
89 Expansions[I].NumExpansionsPlusOne = 0;
99 void *Mem = C.
Allocate(totalSizeToAlloc<KeyValuePair, ExpansionData>(
100 VK.size(), HasPackExpansions ? VK.size() : 0));
106 bool HasPackExpansions) {
107 void *Mem = C.
Allocate(totalSizeToAlloc<KeyValuePair, ExpansionData>(
108 NumElements, HasPackExpansions ? NumElements : 0));
114 if (isClassReceiver())
117 if (isSuperReceiver())
118 return getSuperReceiverType();
120 return getBase()->getType();
136 reinterpret_cast<uintptr_t>(Method ? Method : Sel.
getAsOpaquePtr())),
137 Kind(IsInstanceSuper ? SuperInstance : SuperClass),
138 HasMethod(Method !=
nullptr), IsDelegateInitCall(
false),
139 IsImplicit(isImplicit), SuperLoc(SuperLoc), LBracLoc(LBracLoc),
141 initArgsAndSelLocs(Args, SelLocs, SelLocsK);
156 reinterpret_cast<uintptr_t>(Method ? Method : Sel.
getAsOpaquePtr())),
157 Kind(Class), HasMethod(Method !=
nullptr), IsDelegateInitCall(
false),
158 IsImplicit(isImplicit), LBracLoc(LBracLoc), RBracLoc(RBracLoc) {
159 initArgsAndSelLocs(Args, SelLocs, SelLocsK);
160 setReceiverPointer(Receiver);
174 reinterpret_cast<uintptr_t>(Method ? Method : Sel.
getAsOpaquePtr())),
175 Kind(Instance), HasMethod(Method !=
nullptr), IsDelegateInitCall(
false),
176 IsImplicit(isImplicit), LBracLoc(LBracLoc), RBracLoc(RBracLoc) {
177 initArgsAndSelLocs(Args, SelLocs, SelLocsK);
178 setReceiverPointer(Receiver);
184 setNumArgs(Args.size());
186 for (
unsigned I = 0; I != Args.size(); ++I) {
192 ExprBits.InstantiationDependent =
true;
194 ExprBits.ContainsUnexpandedParameterPack =
true;
199 SelLocsKind = SelLocsK;
202 std::copy(SelLocs.begin(), SelLocs.end(), getStoredSelLocs());
213 assert((!SelLocs.empty() || isImplicit) &&
214 "No selector locs for non-implicit message");
218 Mem = alloc(Context, Args.size(), 0);
220 Mem = alloc(Context, Args, RBracLoc, SelLocs, Sel, SelLocsK);
221 return new (Mem)
ObjCMessageExpr(T, VK, LBracLoc, SuperLoc, IsInstanceSuper,
222 SuperType, Sel, SelLocs, SelLocsK, Method,
223 Args, RBracLoc, isImplicit);
232 assert((!SelLocs.empty() || isImplicit) &&
233 "No selector locs for non-implicit message");
237 Mem = alloc(Context, Args.size(), 0);
239 Mem = alloc(Context, Args, RBracLoc, SelLocs, Sel, SelLocsK);
241 ObjCMessageExpr(T, VK, LBracLoc, Receiver, Sel, SelLocs, SelLocsK, Method,
242 Args, RBracLoc, isImplicit);
251 assert((!SelLocs.empty() || isImplicit) &&
252 "No selector locs for non-implicit message");
256 Mem = alloc(Context, Args.size(), 0);
258 Mem = alloc(Context, Args, RBracLoc, SelLocs, Sel, SelLocsK);
260 ObjCMessageExpr(T, VK, LBracLoc, Receiver, Sel, SelLocs, SelLocsK, Method,
261 Args, RBracLoc, isImplicit);
266 unsigned NumStoredSelLocs) {
278 unsigned NumStoredSelLocs =
280 return alloc(C, Args.size(), NumStoredSelLocs);
284 unsigned NumStoredSelLocs) {
286 totalSizeToAlloc<void *, SourceLocation>(NumArgs + 1, NumStoredSelLocs),
292 for (
unsigned i = 0, e = getNumSelectorLocs(); i != e; ++i)
293 SelLocs.push_back(getSelectorLoc(i));
297 switch (getReceiverKind()) {
299 return getInstanceReceiver()->getSourceRange();
302 return getClassReceiverTypeInfo()->getTypeLoc().getSourceRange();
306 return getSuperLoc();
309 llvm_unreachable(
"Invalid ReceiverKind!");
320 switch (getReceiverKind()) {
322 return getInstanceReceiver()->getType();
324 return getClassReceiver();
327 return getSuperType();
330 llvm_unreachable(
"unexpected receiver kind");
337 return Ptr->getInterfaceDecl();
340 return Ty->getInterface();
347 if (getReceiverKind() == Instance)
348 begin =
reinterpret_cast<Stmt **
>(getTrailingObjects<void *>());
356 switch (getBridgeKind()) {
360 return "__bridge_transfer";
362 return "__bridge_retained";
365 llvm_unreachable(
"Invalid BridgeKind!");
Defines the clang::ASTContext interface.
static ObjCArrayLiteral * Create(const ASTContext &C, ArrayRef< Expr *> Elements, QualType T, ObjCMethodDecl *Method, SourceRange SR)
Smart pointer class that efficiently represents Objective-C method names.
if(T->getSizeExpr()) TRY_TO(TraverseStmt(T -> getSizeExpr()))
A (possibly-)qualified type.
void * getAsOpaquePtr() const
Selector getSelector() const
Expr(StmtClass SC, QualType T, ExprValueKind VK, ExprObjectKind OK, bool TD, bool VD, bool ID, bool ContainsUnexpandedParameterPack)
Stmt - This represents one statement.
Bridging via __bridge, which does nothing but reinterpret the bits.
C Language Family Type Representation.
ObjCInterfaceDecl * getReceiverInterface() const
Retrieve the Objective-C interface to which this message is being directed, if known.
llvm::iterator_range< child_iterator > child_range
A container of type source information.
static ObjCDictionaryLiteral * CreateEmpty(const ASTContext &C, unsigned NumElements, bool HasPackExpansions)
const T * getAs() const
Member-template getAs<specific type>'.
unsigned getNumArgs() const
Determine the number of arguments to this type trait.
ObjCMethodDecl - Represents an instance or class method declaration.
Represents a class type in Objective C.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
static ObjCMessageExpr * CreateEmpty(const ASTContext &Context, unsigned NumArgs, unsigned NumStoredSelLocs)
Create an empty Objective-C message expression, to be filled in by subsequent calls.
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.
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp, [NSNumber numberWithInt:42]];.
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
SelectorLocationsKind
Whether all locations of the selector identifiers are in a "standard" position.
bool containsUnexpandedParameterPack() const
Whether this type is or contains an unexpanded parameter pack, used to support C++0x variadic templat...
bool isTypeDependent() const
isTypeDependent - Determines whether this expression is type-dependent (C++ [temp.dep.expr]), which means that its type could change from one template instantiation to the next.
void * getAsOpaquePtr() const
An ordinary object is located at an address in memory.
Represents an ObjC class declaration.
Bridging via __bridge_transfer, which transfers ownership of an Objective-C pointer into ARC...
ArrayRef< TypeSourceInfo * > getArgs() const
Retrieve the argument types.
Expr - This represents one expression.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
const FunctionProtoType * T
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)
Defines the clang::TypeLoc interface and its subclasses.
An expression that sends a message to the given Objective-C object or class.
QualType getObjCInterfaceType(const ObjCInterfaceDecl *Decl, ObjCInterfaceDecl *PrevDecl=nullptr) const
getObjCInterfaceType - Return the unique reference to the type for the specified ObjC interface decl...
StringRef getBridgeKindName() const
Retrieve the kind of bridge being performed as a string.
bool isInstantiationDependent() const
Whether this expression is instantiation-dependent, meaning that it depends in some way on a template...
Encodes a location in the source.
bool isValueDependent() const
isValueDependent - Determines whether this expression is value-dependent (C++ [temp.dep.constexpr]).
QualType getReceiverType() const
Retrieve the receiver type to which this message is being directed.
bool isInstantiationDependentType() const
Determine whether this type is an instantiation-dependent type, meaning that the type involves a temp...
A placeholder type used to construct an empty shell of a type, that will be filled in later (e...
void * Allocate(size_t Size, unsigned Align=8) const
Dataflow Directional Tag Classes.
Bridging via __bridge_retain, which makes an ARC object available as a +1 C pointer.
SourceRange getReceiverRange() const
Source range of the receiver.
Represents a pointer to an Objective C object.
QualType getReceiverType(const ASTContext &ctx) const
Determine the type of the base, regardless of the kind of receiver.
bool containsUnexpandedParameterPack() const
Whether this expression contains an unexpanded parameter pack (for C++11 variadic templates)...
bool isDependentType() const
Whether this type is a dependent type, meaning that its definition somehow depends on a template para...
static ObjCArrayLiteral * CreateEmpty(const ASTContext &C, unsigned NumElements)
A trivial tuple used to represent a source range.
void getSelectorLocs(SmallVectorImpl< SourceLocation > &SelLocs) const
SelectorLocationsKind hasStandardSelectorLocs(Selector Sel, ArrayRef< SourceLocation > SelLocs, ArrayRef< Expr *> Args, SourceLocation EndLoc)
Returns true if all SelLocs are in a "standard" location.