18 #include "llvm/ADT/SmallVector.h" 19 #include "llvm/Support/ErrorHandling.h" 24 using namespace clang;
30 NumElements(Elements.size()), Range(SR), ArrayWithObjectsMethod(Method) {
31 Expr **SaveElements = getElements();
32 for (
unsigned I = 0, N = Elements.size(); I != N; ++I) {
36 ExprBits.InstantiationDependent =
true;
38 ExprBits.ContainsUnexpandedParameterPack =
true;
40 SaveElements[I] = Elements[I];
48 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(Elements.size()));
53 unsigned NumElements) {
54 void *Mem = C.
Allocate(totalSizeToAlloc<Expr *>(NumElements));
64 NumElements(VK.size()), HasPackExpansions(HasPackExpansions), Range(SR),
65 DictWithObjectsMethod(method) {
66 KeyValuePair *KeyValues = getTrailingObjects<KeyValuePair>();
67 ExpansionData *Expansions =
68 HasPackExpansions ? getTrailingObjects<ExpansionData>() :
nullptr;
69 for (
unsigned I = 0; I < NumElements; I++) {
70 if (VK[I].Key->isTypeDependent() || VK[I].Key->isValueDependent() ||
71 VK[I].Value->isTypeDependent() || VK[I].Value->isValueDependent())
73 if (VK[I].Key->isInstantiationDependent() ||
74 VK[I].Value->isInstantiationDependent())
75 ExprBits.InstantiationDependent =
true;
76 if (VK[I].EllipsisLoc.isInvalid() &&
77 (VK[I].Key->containsUnexpandedParameterPack() ||
78 VK[I].Value->containsUnexpandedParameterPack()))
79 ExprBits.ContainsUnexpandedParameterPack =
true;
81 KeyValues[I].Key = VK[I].Key;
82 KeyValues[I].Value = VK[I].Value;
84 Expansions[I].EllipsisLoc = VK[I].EllipsisLoc;
85 if (VK[I].NumExpansions)
86 Expansions[I].NumExpansionsPlusOne = *VK[I].NumExpansions + 1;
88 Expansions[I].NumExpansionsPlusOne = 0;
98 void *Mem = C.
Allocate(totalSizeToAlloc<KeyValuePair, ExpansionData>(
99 VK.size(), HasPackExpansions ? VK.size() : 0));
105 bool HasPackExpansions) {
106 void *Mem = C.
Allocate(totalSizeToAlloc<KeyValuePair, ExpansionData>(
107 NumElements, HasPackExpansions ? NumElements : 0));
113 if (isClassReceiver())
116 if (isSuperReceiver())
117 return getSuperReceiverType();
119 return getBase()->getType();
135 reinterpret_cast<uintptr_t>(Method ? Method : Sel.
getAsOpaquePtr())),
136 Kind(IsInstanceSuper ? SuperInstance : SuperClass),
137 HasMethod(Method !=
nullptr), IsDelegateInitCall(
false),
138 IsImplicit(isImplicit), SuperLoc(SuperLoc), LBracLoc(LBracLoc),
140 initArgsAndSelLocs(Args, SelLocs, SelLocsK);
155 reinterpret_cast<uintptr_t>(Method ? Method : Sel.
getAsOpaquePtr())),
156 Kind(Class), HasMethod(Method !=
nullptr), IsDelegateInitCall(
false),
157 IsImplicit(isImplicit), LBracLoc(LBracLoc), RBracLoc(RBracLoc) {
158 initArgsAndSelLocs(Args, SelLocs, SelLocsK);
159 setReceiverPointer(Receiver);
173 reinterpret_cast<uintptr_t>(Method ? Method : Sel.
getAsOpaquePtr())),
174 Kind(Instance), HasMethod(Method !=
nullptr), IsDelegateInitCall(
false),
175 IsImplicit(isImplicit), LBracLoc(LBracLoc), RBracLoc(RBracLoc) {
176 initArgsAndSelLocs(Args, SelLocs, SelLocsK);
177 setReceiverPointer(Receiver);
183 setNumArgs(Args.size());
185 for (
unsigned I = 0; I != Args.size(); ++I) {
191 ExprBits.InstantiationDependent =
true;
193 ExprBits.ContainsUnexpandedParameterPack =
true;
198 SelLocsKind = SelLocsK;
201 std::copy(SelLocs.begin(), SelLocs.end(), getStoredSelLocs());
212 assert((!SelLocs.empty() || isImplicit) &&
213 "No selector locs for non-implicit message");
217 Mem = alloc(Context, Args.size(), 0);
219 Mem = alloc(Context, Args, RBracLoc, SelLocs, Sel, SelLocsK);
220 return new (Mem)
ObjCMessageExpr(T, VK, LBracLoc, SuperLoc, IsInstanceSuper,
221 SuperType, Sel, SelLocs, SelLocsK, Method,
222 Args, RBracLoc, isImplicit);
231 assert((!SelLocs.empty() || isImplicit) &&
232 "No selector locs for non-implicit message");
236 Mem = alloc(Context, Args.size(), 0);
238 Mem = alloc(Context, Args, RBracLoc, SelLocs, Sel, SelLocsK);
240 ObjCMessageExpr(T, VK, LBracLoc, Receiver, Sel, SelLocs, SelLocsK, Method,
241 Args, RBracLoc, isImplicit);
250 assert((!SelLocs.empty() || isImplicit) &&
251 "No selector locs for non-implicit message");
255 Mem = alloc(Context, Args.size(), 0);
257 Mem = alloc(Context, Args, RBracLoc, SelLocs, Sel, SelLocsK);
259 ObjCMessageExpr(T, VK, LBracLoc, Receiver, Sel, SelLocs, SelLocsK, Method,
260 Args, RBracLoc, isImplicit);
265 unsigned NumStoredSelLocs) {
277 unsigned NumStoredSelLocs =
279 return alloc(C, Args.size(), NumStoredSelLocs);
283 unsigned NumStoredSelLocs) {
285 totalSizeToAlloc<void *, SourceLocation>(NumArgs + 1, NumStoredSelLocs),
291 for (
unsigned i = 0, e = getNumSelectorLocs();
i != e; ++
i)
292 SelLocs.push_back(getSelectorLoc(
i));
318 llvm_unreachable(
"Unsupported ExprValueKind");
322 switch (getReceiverKind()) {
324 return getInstanceReceiver()->getSourceRange();
327 return getClassReceiverTypeInfo()->getTypeLoc().getSourceRange();
331 return getSuperLoc();
334 llvm_unreachable(
"Invalid ReceiverKind!");
345 switch (getReceiverKind()) {
347 return getInstanceReceiver()->getType();
349 return getClassReceiver();
352 return getSuperType();
355 llvm_unreachable(
"unexpected receiver kind");
362 return Ptr->getInterfaceDecl();
365 return Ty->getInterface();
372 if (getReceiverKind() == Instance)
373 begin =
reinterpret_cast<Stmt **
>(getTrailingObjects<void *>());
386 switch (getBridgeKind()) {
390 return "__bridge_transfer";
392 return "__bridge_retained";
395 llvm_unreachable(
"Invalid BridgeKind!");
Defines the clang::ASTContext interface.
Expr ** getArgs()
Retrieve the call arguments.
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
Stmt - This represents one statement.
unsigned getNumArgs() const
getNumArgs - Return the number of actual arguments to this call.
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.
QualType getLValueReferenceType(QualType T, bool SpelledAsLValue=true) const
Return the uniqued reference to the type for an lvalue reference to the specified type...
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>'.
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.
An x-value expression is a reference to an object with independent storage but which can be "moved"...
ExprValueKind getValueKind() const
getValueKind - The value kind that this expression produces.
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...
llvm::iterator_range< const_child_iterator > const_child_range
This represents one expression.
ExprValueKind
The categorization of expression values, currently following the C++11 scheme.
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...
QualType getCallReturnType(ASTContext &Ctx) const
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...
QualType getObjCInstanceType()
Retrieve the Objective-C "instancetype" type, if already known; otherwise, returns a NULL type;...
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 getRValueReferenceType(QualType T) const
Return the uniqued reference to the type for an rvalue reference to the specified type...
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)
An l-value expression is a reference to an object with independent storage.
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.