24 #include "llvm/ADT/STLExtras.h"
25 #include "llvm/IR/CallSite.h"
26 #include "llvm/IR/DataLayout.h"
27 #include "llvm/IR/InlineAsm.h"
28 using namespace clang;
29 using namespace CodeGen;
42 return llvm::ConstantPointerNull::get(cast<llvm::PointerType>(type));
65 assert(BoxingMethod &&
"BoxingMethod is null");
66 assert(BoxingMethod->
isClassMethod() &&
"BoxingMethod must be a class method");
83 if (ValueType->isObjCBoxableRecordType()) {
108 Args, ClassDecl, BoxingMethod);
119 DLE = cast<ObjCDictionaryLiteral>(
E);
122 uint64_t NumElements =
140 bool TrackNeededObjects =
145 for (uint64_t i = 0; i < NumElements; i++) {
155 if (TrackNeededObjects) {
156 NeededObjects.push_back(value);
174 if (TrackNeededObjects) {
175 NeededObjects.push_back(keyValue);
176 NeededObjects.push_back(valueValue);
211 Receiver, Args, Class, MethodWithObjects);
217 if (TrackNeededObjects) {
278 if (
auto opaque = dyn_cast<OpaqueValueExpr>(receiver)) {
279 if (opaque->getSourceExpr())
288 if (
auto opaque = dyn_cast<OpaqueValueExpr>(receiver)) {
289 if (opaque->getSourceExpr())
298 if (isa<MemberExpr>(receiver) || isa<ObjCIvarRefExpr>(receiver))
303 if (!declRef)
return true;
305 if (!var)
return true;
310 !var->
hasAttr<ObjCPreciseLifetimeAttr>());
323 llvm_unreachable(
"invalid receiver kind");
331 if (
auto CE = dyn_cast<CastExpr>(E)) {
334 return CE->getSubExpr();
370 method->
hasAttr<NSConsumesSelfAttr>());
373 bool isSuperMessage =
false;
374 bool isClassMessage =
false;
385 Receiver = ter.getPointer();
386 if (ter.getInt()) retainSelf =
false;
394 assert(ObjTy &&
"Invalid Objective-C class message send");
396 assert(OID &&
"Invalid Objective-C class message send");
397 Receiver = Runtime.
GetClass(*
this, OID);
398 isClassMessage =
true;
405 isSuperMessage =
true;
411 isSuperMessage =
true;
412 isClassMessage =
true;
423 method->
hasAttr<ObjCReturnsInnerPointerAttr>() &&
439 if (isDelegateInit) {
441 "delegate init calls should only be marked in ARC");
450 if (isSuperMessage) {
453 bool isCategoryImpl = isa<ObjCCategoryImplDecl>(OMD->
getDeclContext());
471 if (isDelegateInit) {
494 if (!iface->getSuperClass())
return;
496 bool isCategory = isa<ObjCCategoryImplDecl>(impl);
523 if (OMD->
hasAttr<NoDebugAttr>())
548 if (ident->
isStr(
"dealloc"))
561 assert(isa<CompoundStmt>(OMD->
getBody()));
570 bool isAtomic,
bool hasStrong) {
611 llvm::Triple::ArchType arch) {
621 class PropertyImplStrategy {
633 SetPropertyAndExpressionGet,
643 StrategyKind
getKind()
const {
return StrategyKind(
Kind); }
645 bool hasStrongMember()
const {
return HasStrong; }
646 bool isAtomic()
const {
return IsAtomic; }
647 bool isCopy()
const {
return IsCopy; }
649 CharUnits getIvarSize()
const {
return IvarSize; }
650 CharUnits getIvarAlignment()
const {
return IvarAlignment; }
657 unsigned IsAtomic : 1;
659 unsigned HasStrong : 1;
667 PropertyImplStrategy::PropertyImplStrategy(
CodeGenModule &CGM,
679 std::tie(IvarSize, IvarAlignment) =
685 Kind = GetSetProperty;
698 }
else if (CGM.
getLangOpts().ObjCAutoRefCount && !IsAtomic) {
708 Kind = SetPropertyAndExpressionGet;
714 }
else if (!IsAtomic) {
715 Kind = SetPropertyAndExpressionGet;
720 Kind = GetSetProperty;
751 HasStrong = recordType->getDecl()->hasObjectMember();
766 if (!IvarSize.isPowerOfTwo()) {
771 llvm::Triple::ArchType arch =
799 llvm::Constant *AtomicHelperFn =
803 assert(OMD &&
"Invalid call to generate getter (empty method)");
813 if (!getter)
return true;
826 return (
construct->getConstructor()->isTrivial());
830 assert(isa<ExprWithCleanups>(getter));
837 llvm::Value *returnAddr,
839 llvm::Constant *AtomicHelperFn) {
848 llvm::Value *ivarAddr =
857 llvm::Value *copyCppAtomicObjectFn =
870 llvm::Constant *AtomicHelperFn) {
873 if (!AtomicHelperFn) {
881 ivar, AtomicHelperFn);
893 PropertyImplStrategy strategy(CGM, propImpl);
894 switch (strategy.getKind()) {
895 case PropertyImplStrategy::Native: {
897 if (strategy.getIvarSize().isZero())
907 bitcastType = bitcastType->getPointerTo();
913 load->setAtomic(llvm::Unordered);
925 case PropertyImplStrategy::GetSetProperty: {
926 llvm::Value *getPropertyFn =
928 if (!getPropertyFn) {
939 llvm::Value *ivarOffset =
951 llvm::Instruction *CallInstruction;
957 if (llvm::CallInst *call = dyn_cast<llvm::CallInst>(CallInstruction))
967 EmitReturnOfRValue(RV, propType);
975 case PropertyImplStrategy::CopyStruct:
977 strategy.hasStrongMember());
980 case PropertyImplStrategy::Expression:
981 case PropertyImplStrategy::SetPropertyAndExpressionGet: {
1027 llvm_unreachable(
"bad evaluation kind");
1031 llvm_unreachable(
"bad @property implementation strategy!");
1083 llvm::Constant *AtomicHelperFn) {
1089 llvm::Value *ivarAddr =
1106 llvm::Value *copyCppAtomicObjectFn =
1118 if (!setter)
return true;
1128 if (
CallExpr *call = dyn_cast<CallExpr>(setter)) {
1130 = dyn_cast_or_null<FunctionDecl>(call->getCalleeDecl()))
1131 if (callee->isTrivial())
1136 assert(isa<ExprWithCleanups>(setter));
1149 llvm::Constant *AtomicHelperFn) {
1157 if (!AtomicHelperFn)
1167 PropertyImplStrategy strategy(CGM, propImpl);
1168 switch (strategy.getKind()) {
1169 case PropertyImplStrategy::Native: {
1171 if (strategy.getIvarSize().isZero())
1178 Address ivarAddr = ivarLValue.getAddress();
1184 getContext().toBits(strategy.getIvarSize()));
1195 store->setAtomic(llvm::Unordered);
1199 case PropertyImplStrategy::GetSetProperty:
1200 case PropertyImplStrategy::SetPropertyAndExpressionGet: {
1202 llvm::Value *setOptimizedPropertyFn =
nullptr;
1203 llvm::Value *setPropertyFn =
nullptr;
1206 setOptimizedPropertyFn =
1210 if (!setOptimizedPropertyFn) {
1217 if (!setPropertyFn) {
1229 llvm::Value *ivarOffset =
1238 if (setOptimizedPropertyFn) {
1263 case PropertyImplStrategy::CopyStruct:
1267 case PropertyImplStrategy::Expression:
1280 &selfLoad,
true,
true);
1283 QualType argType = argDecl->getType().getNonReferenceType();
1293 if (ivarRef.getType()->isObjCObjectPointerType()) {
1294 if (argLoad.getType()->isObjCObjectPointerType())
1296 else if (argLoad.getType()->isBlockPointerType())
1300 }
else if (ivarRef.getType()->isBlockPointerType()) {
1301 if (argLoad.getType()->isBlockPointerType())
1305 }
else if (ivarRef.getType()->isPointerType()) {
1309 ivarRef.getType(), argCK, &argLoad,
1311 Expr *finalArg = &argLoad;
1314 finalArg = &argCast;
1329 llvm::Constant *AtomicHelperFn =
1333 assert(OMD &&
"Invalid call to generate setter (empty method)");
1347 bool useEHCleanupForArray;
1349 DestroyIvar(llvm::Value *addr,
const ObjCIvarDecl *ivar,
1351 bool useEHCleanupForArray)
1352 : addr(addr), ivar(ivar), destroyer(destroyer),
1353 useEHCleanupForArray(useEHCleanupForArray) {}
1359 flags.isForNormalCleanup() && useEHCleanupForArray);
1385 if (!dtorKind)
continue;
1401 CGF.
EHStack.pushCleanup<DestroyIvar>(cleanupKind,
self, ivar, destroyer,
1419 for (
const auto *IvarInit : IMP->
inits()) {
1420 FieldDecl *Field = IvarInit->getAnyMember();
1432 llvm::Value *SelfAsId =
1459 llvm::Constant *EnumerationMutationFn =
1462 if (!EnumerationMutationFn) {
1484 static const unsigned NumItems = 16;
1497 llvm::APInt(32, NumItems),
1502 llvm::Value *Collection;
1533 llvm::Constant *
Count = llvm::ConstantInt::get(UnsignedLongLTy, NumItems);
1544 llvm::Value *initialBufferLimit = CountRV.
getScalarVal();
1549 llvm::Value *zero = llvm::Constant::getNullValue(UnsignedLongLTy);
1556 Builder.CreateICmpEQ(initialBufferLimit, zero,
"iszero"), EmptyBB,
1568 llvm::Value *StateMutationsPtr
1571 llvm::Value *initialMutations =
1573 "forcoll.initial-mutations");
1581 llvm::PHINode *index =
Builder.CreatePHI(UnsignedLongLTy, 3,
"forcoll.index");
1582 index->addIncoming(zero, LoopInitBB);
1585 llvm::PHINode *count =
Builder.CreatePHI(UnsignedLongLTy, 3,
"forcoll.count");
1586 count->addIncoming(initialBufferLimit, LoopInitBB);
1594 llvm::Value *currentMutations
1599 llvm::BasicBlock *WasNotMutatedBB =
createBasicBlock(
"forcoll.notmutated");
1601 Builder.CreateCondBr(
Builder.CreateICmpEQ(currentMutations, initialMutations),
1602 WasNotMutatedBB, WasMutatedBB);
1623 bool elementIsVariable;
1630 const VarDecl* D = cast<VarDecl>(SD->getSingleDecl());
1635 elementIsVariable =
true;
1640 elementLValue =
LValue();
1641 elementType = cast<Expr>(S.
getElement())->getType();
1642 elementIsVariable =
false;
1651 llvm::Value *EnumStateItems =
1655 llvm::Value *CurrentItemPtr =
1656 Builder.CreateGEP(EnumStateItems, index,
"currentitem.ptr");
1657 llvm::Value *CurrentItem =
1666 if (!elementIsVariable) {
1675 if (elementIsVariable)
1679 BreakContinueStack.push_back(BreakContinue(LoopEnd, AfterBody));
1684 BreakContinueStack.pop_back();
1695 llvm::Value *indexPlusOne
1696 =
Builder.CreateAdd(index, llvm::ConstantInt::get(UnsignedLongLTy, 1));
1703 Builder.CreateICmpULT(indexPlusOne, count), LoopBodyBB, FetchMoreBB,
1706 index->addIncoming(indexPlusOne, AfterBody.
getBlock());
1707 count->addIncoming(count, AfterBody.
getBlock());
1722 index->addIncoming(zero,
Builder.GetInsertBlock());
1723 count->addIncoming(refetchCount,
Builder.GetInsertBlock());
1726 EmptyBB, LoopBodyBB);
1731 if (!elementIsVariable) {
1734 llvm::Value *null = llvm::Constant::getNullValue(convertedElementType);
1764 CallObjCRelease(llvm::Value *
object) : object(object) {}
1765 llvm::Value *object;
1777 llvm::Value *
object) {
1785 llvm::Value *value) {
1794 llvm::FunctionType *fnType =
1795 llvm::FunctionType::get(CGM.
VoidTy,
None,
true);
1806 llvm::FunctionType *
type,
1810 if (llvm::Function *f = dyn_cast<llvm::Function>(fn)) {
1815 f->setLinkage(llvm::Function::ExternalWeakLinkage);
1816 }
else if (fnName ==
"objc_retain" || fnName ==
"objc_release") {
1819 f->addFnAttr(llvm::Attribute::NonLazyBind);
1831 llvm::Constant *&fn,
1833 bool isTailCall =
false) {
1834 if (isa<llvm::ConstantPointerNull>(value))
return value;
1837 llvm::FunctionType *fnType =
1849 call->setTailCall();
1859 llvm::Constant *&fn,
1862 llvm::FunctionType *fnType =
1886 llvm::Constant *&fn,
1894 llvm::FunctionType *fnType
1895 = llvm::FunctionType::get(CGF.
Int8PtrTy, argTypes,
false);
1901 llvm::Value *args[] = {
1907 if (ignored)
return nullptr;
1917 llvm::Constant *&fn,
1924 llvm::FunctionType *fnType
1925 = llvm::FunctionType::get(CGF.
Builder.getVoidTy(), argTypes,
false);
1929 llvm::Value *args[] = {
1965 "objc_retainBlock");
1971 if (!mandatory && isa<llvm::Instruction>(result)) {
1972 llvm::CallInst *call
1973 = cast<llvm::CallInst>(result->stripPointerCasts());
1976 call->setMetadata(
"clang.arc.copy_on_escape",
1992 llvm::InlineAsm *&marker
2000 if (assembly.empty()) {
2005 llvm::FunctionType *
type =
2006 llvm::FunctionType::get(
VoidTy,
false);
2008 marker = llvm::InlineAsm::get(type, assembly,
"",
true);
2014 llvm::NamedMDNode *metadata =
2015 CGM.
getModule().getOrInsertNamedMetadata(
2016 "clang.arc.retainAutoreleasedReturnValueMarker");
2017 assert(metadata->getNumOperands() <= 1);
2018 if (metadata->getNumOperands() == 0) {
2019 metadata->addOperand(llvm::MDNode::get(
2031 "objc_retainAutoreleasedReturnValue");
2038 if (isa<llvm::ConstantPointerNull>(value))
return;
2042 llvm::FunctionType *fnType =
2054 call->setMetadata(
"clang.imprecise_release",
2090 llvm::FunctionType *fnType
2091 = llvm::FunctionType::get(
Builder.getVoidTy(), argTypes,
false);
2095 llvm::Value *args[] = {
2101 if (ignored)
return nullptr;
2109 llvm::Value *newValue,
2146 "objc_autorelease");
2155 "objc_autoreleaseReturnValue",
2165 "objc_retainAutoreleaseReturnValue",
2175 llvm::Value *value) {
2179 if (isa<llvm::ConstantPointerNull>(value))
return value;
2194 "objc_retainAutorelease");
2209 "objc_loadWeakRetained");
2219 "objc_storeWeak", ignored);
2231 if (isa<llvm::ConstantPointerNull>(value) &&
2239 "objc_initWeak",
true);
2247 llvm::FunctionType *fnType =
2281 llvm::FunctionType *fnType =
2282 llvm::FunctionType::get(
Int8PtrTy,
false);
2296 llvm::FunctionType *fnType =
2323 AllocSel, Receiver, Args);
2332 InitSel, Receiver, Args);
2368 CallObjCAutoreleasePoolObject(llvm::Value *token) :
Token(token) {}
2377 CallObjCMRRAutoreleasePoolObject(llvm::Value *token) :
Token(token) {}
2409 llvm_unreachable(
"impossible lifetime!");
2442 isa<BinaryOperator>(e) &&
2443 cast<BinaryOperator>(e)->getOpcode() ==
BO_Assign)
2450 llvm::Value *value);
2460 llvm::Value *value) {
2461 if (llvm::CallInst *call = dyn_cast<llvm::CallInst>(value)) {
2462 CGBuilderTy::InsertPoint ip = CGF.
Builder.saveIP();
2465 CGF.
Builder.SetInsertPoint(call->getParent(),
2471 }
else if (llvm::InvokeInst *invoke = dyn_cast<llvm::InvokeInst>(value)) {
2472 CGBuilderTy::InsertPoint ip = CGF.
Builder.saveIP();
2475 llvm::BasicBlock *BB = invoke->getNormalDest();
2476 CGF.
Builder.SetInsertPoint(BB, BB->begin());
2484 }
else if (llvm::BitCastInst *bitcast = dyn_cast<llvm::BitCastInst>(value)) {
2485 llvm::Value *operand = bitcast->getOperand(0);
2487 bitcast->setOperand(0, operand);
2507 if (isa<BlockExpr>(e))
2511 switch (
cast->getCastKind()) {
2548 const Expr *semantic = *i;
2552 if (
const OpaqueValueExpr *ov = dyn_cast<OpaqueValueExpr>(semantic)) {
2558 if (ov == resultExpr) {
2559 assert(!OVMA::shouldBindAsLValue(ov));
2561 opaqueData = OVMA::bind(CGF, ov,
RValue::get(result.getPointer()));
2565 opaqueData = OVMA::bind(CGF, ov, ov->getSourceExpr());
2567 opaques.push_back(opaqueData);
2571 }
else if (semantic == resultExpr) {
2581 for (
unsigned i = 0, e = opaques.size(); i != e; ++i)
2582 opaques[i].unbind(CGF);
2592 assert(!isa<ExprWithCleanups>(e));
2603 if (
const CastExpr *ce = dyn_cast<CastExpr>(e)) {
2604 switch (ce->getCastKind()) {
2607 e = ce->getSubExpr();
2614 llvm::Value *value = loadResult.getPointer();
2616 loadResult.setPointer(value);
2630 e = ce->getSubExpr();
2646 llvm::Value *result;
2657 result = subresult.getPointer();
2661 if (subresult.getInt()) {
2689 }
else if (
const UnaryOperator *op = dyn_cast<UnaryOperator>(e)) {
2691 e = op->getSubExpr();
2699 }
else if (isa<CallExpr>(e) ||
2700 (isa<ObjCMessageExpr>(e) &&
2701 !cast<ObjCMessageExpr>(e)->isDelegateInitCall())) {
2707 }
else if (
const PseudoObjectExpr *pseudo = dyn_cast<PseudoObjectExpr>(e)) {
2711 llvm::Value *value = result.getPointer();
2713 result.setPointer(value);
2733 llvm::Value *value = result.getPointer();
2734 if (!result.getInt())
2752 llvm::Value *value = result.getPointer();
2753 if (!result.getInt())
2768 llvm::Value *value = result.getPointer();
2769 if (result.getInt())
2777 llvm::Value *result;
2785 result = subresult.getPointer();
2786 doRetain = !subresult.getInt();
2810 std::pair<LValue,llvm::Value*>
2815 llvm::Value *value = result.getPointer();
2817 bool hasImmediateRetain = result.getInt();
2824 hasImmediateRetain =
true;
2830 if (hasImmediateRetain) {
2838 return std::pair<LValue,llvm::Value*>(lvalue, value);
2841 std::pair<LValue,llvm::Value*>
2848 return std::pair<LValue,llvm::Value*>(lvalue, value);
2870 for (
const auto *
I : S.
body())
2881 llvm::FunctionType *extenderType
2883 llvm::Value *extender
2884 = llvm::InlineAsm::get(extenderType,
2909 llvm::Constant *HelperFn =
nullptr;
2934 args.push_back(&dstDecl);
2936 args.push_back(&srcDecl);
2943 llvm::Function *Fn =
2945 "__assign_helper_atomic_property_",
2962 Expr *Args[2] = { &DST, &SRC };
2965 Args, DestTy->getPointeeType(),
2971 HelperFn = llvm::ConstantExpr::getBitCast(Fn,
VoidPtrTy);
2988 llvm::Constant *HelperFn =
nullptr;
3015 args.push_back(&dstDecl);
3017 args.push_back(&srcDecl);
3024 llvm::Function *Fn =
3026 "__copy_helper_atomic_property_", &CGM.
getModule());
3042 ConstructorArgs.push_back(&SRC);
3043 ConstructorArgs.append(std::next(CXXConstExpr->arg_begin()),
3044 CXXConstExpr->arg_end());
3048 CXXConstExpr->getConstructor(),
3049 CXXConstExpr->isElidable(),
3051 CXXConstExpr->hadMultipleCandidates(),
3052 CXXConstExpr->isListInitialization(),
3053 CXXConstExpr->isStdInitListInitialization(),
3054 CXXConstExpr->requiresZeroInitialization(),
3055 CXXConstExpr->getConstructionKind(),
3072 HelperFn = llvm::ConstantExpr::getBitCast(Fn,
VoidPtrTy);
3089 llvm::Value *Val = Block;
3096 Ty, AutoreleaseSelector,
llvm::PointerType * Int8PtrPtrTy
A call to an overloaded operator written using operator syntax.
The receiver is the instance of the superclass object.
param_const_iterator param_begin() const
ReturnValueSlot - Contains the address where the return value of a function can be stored...
static bool UseOptimizedSetter(CodeGenModule &CGM)
Defines the clang::ASTContext interface.
bool isAtomic() const
isAtomic - Return true if the property is atomic.
CastKind getCastKind() const
FunctionDecl - An instance of this class is created to represent a function declaration or definition...
llvm::Value * EmitARCStoreStrong(LValue lvalue, llvm::Value *value, bool resultIgnored)
Store into a strong object.
CK_LValueToRValue - A conversion which causes the extraction of an r-value from the operand gl-value...
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
The receiver is an object instance.
void EmitCallArgs(CallArgList &Args, const T *CallArgTypeInfo, llvm::iterator_range< CallExpr::const_arg_iterator > ArgRange, const FunctionDecl *CalleeDecl=nullptr, unsigned ParamsToSkip=0)
EmitCallArgs - Emit call arguments for a function.
Smart pointer class that efficiently represents Objective-C method names.
llvm::Value * EmitARCRetainAutoreleaseScalarExpr(const Expr *expr)
static bool hasTrivialGetExpr(const ObjCPropertyImplDecl *propImpl)
ObjCEntrypoints & getObjCEntrypoints() const
Destroyer * getDestroyer(QualType::DestructionKind destructionKind)
A (possibly-)qualified type.
static bool hasUnalignedAtomics(llvm::Triple::ArchType arch)
Determine whether the given architecture supports unaligned atomic accesses.
void EmitExtendGCLifetime(llvm::Value *object)
EmitExtendGCLifetime - Given a pointer to an Objective-C object, make sure it survives garbage collec...
llvm::Value * getPointer() const
CodeGenTypes & getTypes()
llvm::Value * EmitARCExtendBlockObject(const Expr *expr)
ObjCInterfaceDecl * getClassInterface()
bool isBitField() const
Determines whether this field is a bitfield.
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after...
virtual llvm::Function * GenerateMethod(const ObjCMethodDecl *OMD, const ObjCContainerDecl *CD)=0
Generate a function preamble for a method with the specified types.
llvm::Module & getModule() const
QualType getClassReceiver() const
Returns the type of a class message send, or NULL if the message is not a class message.
bool isDelegateInitCall() const
isDelegateInitCall - Answers whether this message send has been tagged as a "delegate init call"...
static AggValueSlot forLValue(const LValue &LV, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, IsZeroed_t isZeroed=IsNotZeroed)
void EmitARCDestroyWeak(Address addr)
void @objc_destroyWeak(i8** addr) Essentially objc_storeWeak(addr, nil).
static CXXConstructExpr * Create(const ASTContext &C, QualType T, SourceLocation Loc, CXXConstructorDecl *D, bool Elidable, ArrayRef< Expr * > Args, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization, ConstructionKind ConstructKind, SourceRange ParenOrBraceRange)
virtual CodeGen::RValue GenerateMessageSend(CodeGen::CodeGenFunction &CGF, ReturnValueSlot ReturnSlot, QualType ResultType, Selector Sel, llvm::Value *Receiver, const CallArgList &CallArgs, const ObjCInterfaceDecl *Class=nullptr, const ObjCMethodDecl *Method=nullptr)=0
Generate an Objective-C message send operation.
void EmitLexicalBlockEnd(CGBuilderTy &Builder, SourceLocation Loc)
Emit metadata to indicate the end of a new lexical block and pop the current block.
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
Implements runtime-specific code generation functions.
void addConst()
Add the const type qualifier to this QualType.
static RValue AdjustObjCObjectType(CodeGenFunction &CGF, QualType ET, RValue Result)
Adjust the type of an Objective-C object that doesn't match up due to type erasure at various points...
bool isRecordType() const
llvm::Constant * objc_autoreleaseReturnValue
id objc_autoreleaseReturnValue(id);
Address getAddress() const
const Decl * CurCodeDecl
CurCodeDecl - This is the inner-most code context, which includes blocks.
static Destroyer destroyARCStrongPrecise
Represents Objective-C's @throw statement.
void EmitStoreThroughLValue(RValue Src, LValue Dst, bool isInit=false)
EmitStoreThroughLValue - Store the specified rvalue into the specified lvalue, where both are guarant...
void GenerateObjCSetter(ObjCImplementationDecl *IMP, const ObjCPropertyImplDecl *PID)
GenerateObjCSetter - Synthesize an Objective-C property setter function for the given property...
const ObjCObjectType * getObjectType() const
Gets the type pointed to by this ObjC pointer.
Represents a call to a C++ constructor.
llvm::Constant * objc_loadWeakRetained
id objc_loadWeakRetained(id*);
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
void EmitARCCopyWeak(Address dst, Address src)
void @objc_copyWeak(i8** dest, i8** src) Disregards the current value in dest.
llvm::Value * EmitObjCMRRAutoreleasePoolPush()
Produce the code to do an MRR version objc_autoreleasepool_push.
llvm::Constant * GenerateObjCAtomicSetterCopyHelperFunction(const ObjCPropertyImplDecl *PID)
GenerateObjCAtomicSetterCopyHelperFunction - Given a c++ object type with non-trivial copy assignment...
const LangOptions & getLangOpts() const
bool isBlockPointerType() const
llvm::Value * EmitARCRetainNonBlock(llvm::Value *value)
Retain the given object, with normal retain semantics.
static llvm::Value * emitARCRetainLoadOfScalar(CodeGenFunction &CGF, LValue lvalue, QualType type)
[ARC] Consumes a retainable object pointer that has just been produced, e.g.
const CGFunctionInfo & arrangeFreeFunctionDeclaration(QualType ResTy, const FunctionArgList &Args, const FunctionType::ExtInfo &Info, bool isVariadic)
void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID)
createImplicitParams - Used to lazily create the self and cmd implict parameters. ...
static Destroyer destroyARCWeak
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
Address GetAddrOfLocalVar(const VarDecl *VD)
GetAddrOfLocalVar - Return the address of a local variable.
VarDecl - An instance of this class is created to represent a variable declaration or definition...
llvm::Type * getElementType() const
Return the type of the values stored in this address.
Expr * getSetterCXXAssignment() const
const Expr * getCallee() const
ObjCLifetime getObjCLifetime() const
SourceLocation getLocStart() const LLVM_READONLY
uint64_t getProfileCount(const Stmt *S)
Get the profiler's count for the given statement.
llvm::Value * EmitObjCAutoreleasePoolPush()
Produce the code to do a objc_autoreleasepool_push.
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
This class gathers all debug information during compilation and is responsible for emitting to llvm g...
ObjCMethodDecl - Represents an instance or class method declaration.
llvm::Value * EmitBlockCopyAndAutorelease(llvm::Value *Block, QualType Ty)
bool shouldUseFusedARCCalls()
llvm::Constant * getAtomicSetterHelperFnMap(QualType Ty)
Defines the Objective-C statement AST node classes.
Represents an expression – generally a full-expression – that introduces cleanups to be run at the en...
ParmVarDecl - Represents a parameter to a function.
bool isObjCRetainableType() const
llvm::Value * EmitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E)
The collection of all-type qualifiers we support.
virtual llvm::Constant * GetOptimizedPropertySetFunction(bool atomic, bool copy)=0
Return the runtime function for optimized setting properties.
A jump destination is an abstract label, branching to which may require a jump out through normal cle...
llvm::Constant * getPointer() const
llvm::Value * EmitObjCThrowOperand(const Expr *expr)
llvm::Constant * objc_autorelease
id objc_autorelease(id);
llvm::Constant * objc_copyWeak
void objc_copyWeak(id *dest, id *src);
llvm::Constant * getAtomicGetterHelperFnMap(QualType Ty)
One of these records is kept for each identifier that is lexed.
void emitDestroy(Address addr, QualType type, Destroyer *destroyer, bool useEHCleanupForArray)
emitDestroy - Immediately perform the destruction of the given object.
ObjCProtocolDecl * getProtocol() const
static void emitStructGetterCall(CodeGenFunction &CGF, ObjCIvarDecl *ivar, bool isAtomic, bool hasStrong)
emitStructGetterCall - Call the runtime function to load a property into the return value slot...
Represents a class type in Objective C.
CGDebugInfo * getDebugInfo()
llvm::Constant * objc_loadWeak
id objc_loadWeak(id*);
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
llvm::Type * ConvertType(QualType T)
ConvertType - Convert type T into a llvm::Type.
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
std::pair< LValue, llvm::Value * > EmitARCStoreAutoreleasing(const BinaryOperator *e)
llvm::Constant * objc_retainAutoreleasedReturnValue
id objc_retainAutoreleasedReturnValue(id);
llvm::Value * EmitObjCExtendObjectLifetime(QualType T, llvm::Value *Ptr)
bool isReferenceType() const
llvm::Value * EmitARCRetainAutoreleaseReturnValue(llvm::Value *value)
Do a fused retain/autorelease of the given object.
FieldDecl - An instance of this class is created by Sema::ActOnField to represent a member of a struc...
ImplicitParamDecl * getCmdDecl() const
StringLiteral * getString()
Denotes a cleanup that should run when a scope is exited using exceptional control flow (a throw stat...
[ARC] Causes a value of block type to be copied to the heap, if it is not already there...
Token - This structure provides full information about a lexed token.
llvm::Value * EmitARCAutoreleaseReturnValue(llvm::Value *value)
Autorelease the given object.
void GenerateObjCCtorDtorMethod(ObjCImplementationDecl *IMP, ObjCMethodDecl *MD, bool ctor)
SourceLocation getLBracLoc() const
RValue EmitCall(const CGFunctionInfo &FnInfo, llvm::Value *Callee, ReturnValueSlot ReturnValue, const CallArgList &Args, CGCalleeInfo CalleeInfo=CGCalleeInfo(), llvm::Instruction **callOrInvoke=nullptr)
EmitCall - Generate a call of the given function, expecting the given result type, and using the given argument list which specifies both the LLVM arguments and the types they were derived from.
virtual llvm::Constant * GetPropertySetFunction()=0
Return the runtime function for setting properties.
CleanupKind getCleanupKind(QualType::DestructionKind kind)
i32 captured_struct **param SharedsTy A type which contains references the shared variables *param Shareds Context with the list of shared variables from the p *TaskFunction *param IfCond Not a nullptr if if clause was nullptr *otherwise *param PrivateVars List of references to private variables for the task *directive *param PrivateCopies List of private copies for each private variable in *p PrivateVars *param FirstprivateVars List of references to private variables for the *task directive *param FirstprivateCopies List of private copies for each private variable *in p FirstprivateVars *param FirstprivateInits List of references to auto generated variables *used for initialization of a single array element Used if firstprivate *variable is of array type *param Dependences List of dependences for the task construct
ObjCArrayLiteral - used for objective-c array containers; as in: @["Hello", NSApp, [NSNumber numberWithInt:42]];.
llvm::Value * EmitObjCBoxedExpr(const ObjCBoxedExpr *E)
EmitObjCBoxedExpr - This routine generates code to call the appropriate expression boxing method...
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
ComplexPairTy EmitLoadOfComplex(LValue src, SourceLocation loc)
EmitLoadOfComplex - Load a complex number from the specified l-value.
const Expr *const * const_semantics_iterator
virtual CodeGen::RValue GenerateMessageSendSuper(CodeGen::CodeGenFunction &CGF, ReturnValueSlot ReturnSlot, QualType ResultType, Selector Sel, const ObjCInterfaceDecl *Class, bool isCategoryImpl, llvm::Value *Self, bool IsClassMessage, const CallArgList &CallArgs, const ObjCMethodDecl *Method=nullptr)=0
Generate an Objective-C message send operation to the super class initiated in a method for Class and...
RValue EmitAnyExpr(const Expr *E, AggValueSlot aggSlot=AggValueSlot::ignored(), bool ignoreResult=false)
EmitAnyExpr - Emit code to compute the specified expression which can have any type.
llvm::Value * EmitARCStoreStrongCall(Address addr, llvm::Value *value, bool resultIgnored)
Store into a strong object.
llvm::Constant * objc_initWeak
id objc_initWeak(id*, id);
bool hasOptimizedSetter() const
Does this runtime supports optimized setter entrypoints?
llvm::Value * EmitObjCStringLiteral(const ObjCStringLiteral *E)
Emits an instance of NSConstantString representing the object.
Selector getNullarySelector(IdentifierInfo *ID)
ObjCMethodDecl * getBoxingMethod() const
CharUnits getAlignment() const
ObjCContainerDecl - Represents a container for method declarations.
Address CreateElementBitCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name="")
Cast the element type of the given address to a different type, preserving information like the align...
CharUnits - This is an opaque type for sizes expressed in character units.
void EmitARCDestroyStrong(Address addr, ARCPreciseLifetime_t precise)
Destroy a __strong variable.
const Qualifiers & getQuals() const
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
bool hasNativeARC() const
Does this runtime natively provide the ARC entrypoints?
QualType getSuperType() const
Retrieve the type referred to by 'super'.
llvm::PointerType * VoidPtrTy
semantics_iterator semantics_end()
llvm::Constant * objc_release
void objc_release(id);
A builtin binary operation expression such as "x + y" or "x <= y".
Selector getSelector() const
Expr * getGetterCXXConstructor() const
CharUnits getPointerSize() const
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface...
void setAtomicGetterHelperFnMap(QualType Ty, llvm::Constant *Fn)
llvm::Value * EmitARCLoadWeak(Address addr)
i8* @objc_loadWeak(i8** addr) Essentially objc_autorelease(objc_loadWeakRetained(addr)).
ObjCStringLiteral, used for Objective-C string literals i.e.
Scope - A scope is a transient data structure that is used while parsing the program.
void incrementProfileCounter(const Stmt *S)
Increment the profiler's counter for the given statement.
void EmitStmt(const Stmt *S)
EmitStmt - Emit the code for the statement.
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
llvm::Value * EmitARCRetainScalarExpr(const Expr *expr)
EmitARCRetainScalarExpr - Semantically equivalent to EmitARCRetainObject(e->getType(), EmitScalarExpr(e)), but making a best-effort attempt to peephole expressions that naturally produce retained objects.
void EmitIgnoredExpr(const Expr *E)
EmitIgnoredExpr - Emit an expression in a context which ignores the result.
static bool shouldEmitSeparateBlockRetain(const Expr *e)
Determine whether it might be important to emit a separate objc_retain_block on the result of the giv...
Denotes a cleanup that should run when a scope is exited using normal control flow (falling off the e...
void assignRegionCounters(GlobalDecl GD, llvm::Function *Fn)
Assign counters to regions and configure them for PGO of a given function.
static llvm::Value * emitARCRetainAfterCall(CodeGenFunction &CGF, llvm::Value *value)
static TryEmitResult tryEmitARCRetainPseudoObject(CodeGenFunction &CGF, const PseudoObjectExpr *E)
Try to emit a PseudoObjectExpr at +1.
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
bool requiresCleanups() const
Determine whether this scope requires any cleanups.
Expr * Key
The key for the dictionary element.
virtual llvm::Constant * GetGetStructFunction()=0
GlobalDecl CurGD
CurGD - The GlobalDecl for the current function being compiled.
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
An ordinary object is located at an address in memory.
uint64_t getCurrentProfileCount()
Get the profiler's current count.
Represents an ObjC class declaration.
SourceLocation getLocEnd() const LLVM_READONLY
detail::InMemoryDirectory::const_iterator I
PropertyAttributeKind getPropertyAttributes() const
static TryEmitResult tryEmitARCRetainScalarExpr(CodeGenFunction &CGF, const Expr *e)
std::pair< CharUnits, CharUnits > getTypeInfoInChars(const Type *T) const
llvm::Value * EmitARCRetainAutoreleasedReturnValue(llvm::Value *value)
Retain the given object which is the result of a function call.
static FunctionDecl * Create(ASTContext &C, DeclContext *DC, SourceLocation StartLoc, SourceLocation NLoc, DeclarationName N, QualType T, TypeSourceInfo *TInfo, StorageClass SC, bool isInlineSpecified=false, bool hasWrittenPrototype=true, bool isConstexprSpecified=false)
llvm::Value * EmitARCRetainAutoreleaseNonBlock(llvm::Value *value)
Do a fused retain/autorelease of the given object.
This object can be modified without requiring retains or releases.
virtual StringRef getARCRetainAutoreleasedReturnValueMarker() const
Retrieve the address of a function to call immediately before calling objc_retainAutoreleasedReturnVa...
CK_AnyPointerToBlockPointerCast - Casting any non-block pointer to a block pointer.
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
llvm::CallSite EmitRuntimeCallOrInvoke(llvm::Value *callee, ArrayRef< llvm::Value * > args, const Twine &name="")
Emits a call or invoke instruction to the given runtime function.
LValue MakeAddrLValue(Address Addr, QualType T, AlignmentSource AlignSource=AlignmentSource::Type)
RValue EmitObjCMessageExpr(const ObjCMessageExpr *E, ReturnValueSlot Return=ReturnValueSlot())
const ParmVarDecl *const * param_const_iterator
CompoundStmt - This represents a group of statements like { stmt stmt }.
AutoVarEmission EmitAutoVarAlloca(const VarDecl &var)
EmitAutoVarAlloca - Emit the alloca and debug information for a local variable.
std::pair< llvm::Value *, llvm::Value * > ComplexPairTy
llvm::CallInst * EmitNounwindRuntimeCall(llvm::Value *callee, const Twine &name="")
const TargetCodeGenInfo & getTargetCodeGenInfo()
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
void EmitAnyExprToMem(const Expr *E, Address Location, Qualifiers Quals, bool IsInitializer)
EmitAnyExprToMem - Emits the code necessary to evaluate an arbitrary expression into the given memory...
llvm::Constant * objc_storeStrong
id objc_storeStrong(id*, id);
const TargetInfo & getTarget() const
CastKind
CastKind - The kind of operation required for a conversion.
RValue - This trivial value class is used to represent the result of an expression that is evaluated...
void getObjCEncodingForType(QualType T, std::string &S, const FieldDecl *Field=nullptr, QualType *NotEncodedT=nullptr) const
Emit the Objective-CC type encoding for the given type T into S.
CleanupKind getARCCleanupKind()
Retrieves the default cleanup kind for an ARC cleanup.
static AutoVarEmission invalid()
SourceLocation getBodyRBrace() const
getBodyRBrace - Gets the right brace of the body, if a body exists.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
bool isUnarySelector() const
llvm::Value * EmitARCStoreWeak(Address addr, llvm::Value *value, bool ignored)
i8* @objc_storeWeak(i8** addr, i8* value) Returns value.
const ObjCMethodDecl * getMethodDecl() const
static TypeEvaluationKind getEvaluationKind(QualType T)
hasAggregateLLVMType - Return true if the specified AST type will map into an aggregate LLVM type or ...
CGObjCRuntime & getObjCRuntime()
Return a reference to the configured Objective-C runtime.
static bool shouldExtendReceiverForInnerPointerMessage(const ObjCMessageExpr *message)
Decide whether to extend the lifetime of the receiver of a returns-inner-pointer message.
llvm::Value * getPointer() const
ValueDecl - Represent the declaration of a variable (in which case it is an lvalue) a function (in wh...
Expr - This represents one expression.
llvm::Constant * objc_autoreleasePoolPop
void objc_autoreleasePoolPop(void*);
void EmitARCMoveWeak(Address dst, Address src)
void @objc_moveWeak(i8** dest, i8** src) Disregards the current value in dest.
virtual llvm::Constant * GetSetStructFunction()=0
void EmitAutoVarInit(const AutoVarEmission &emission)
CK_BitCast - A conversion which causes a bit pattern of one type to be reinterpreted as a bit pattern...
Enters a new scope for capturing cleanups, all of which will be executed once the scope is exited...
SetterKind getSetterKind() const
getSetterKind - Return the method used for doing assignment in the property setter.
void EmitStoreOfScalar(llvm::Value *Value, Address Addr, bool Volatile, QualType Ty, AlignmentSource AlignSource=AlignmentSource::Type, llvm::MDNode *TBAAInfo=nullptr, bool isInit=false, QualType TBAABaseTy=QualType(), uint64_t TBAAOffset=0, bool isNontemporal=false)
EmitStoreOfScalar - Store a scalar value to an address, taking care to appropriately convert from the...
void GenerateObjCMethod(const ObjCMethodDecl *OMD)
Generate an Objective-C method.
ObjCIvarDecl * getPropertyIvarDecl() const
static void emitStructSetterCall(CodeGenFunction &CGF, ObjCMethodDecl *OMD, ObjCIvarDecl *ivar)
emitStructSetterCall - Call the runtime function to store the value from the first formal parameter i...
void SetInternalFunctionAttributes(const Decl *D, llvm::Function *F, const CGFunctionInfo &FI)
Set the attributes on the LLVM function for the given decl and function info.
virtual void EmitThrowStmt(CodeGen::CodeGenFunction &CGF, const ObjCAtThrowStmt &S, bool ClearInsertionPoint=true)=0
TranslationUnitDecl * getTranslationUnitDecl() const
llvm::Constant * objc_retain
id objc_retain(id);
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
DeclContext * getDeclContext()
ASTContext & getContext() const
llvm::BasicBlock * getBlock() const
Represents Objective-C's @synchronized statement.
ObjCSelectorExpr used for @selector in Objective-C.
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
void generateObjCSetterBody(const ObjCImplementationDecl *classImpl, const ObjCPropertyImplDecl *propImpl, llvm::Constant *AtomicHelperFn)
ImplicitParamDecl * getSelfDecl() const
void add(RValue rvalue, QualType type, bool needscopy=false)
virtual void EmitTryStmt(CodeGen::CodeGenFunction &CGF, const ObjCAtTryStmt &S)=0
llvm::Value * EmitARCAutorelease(llvm::Value *value)
Autorelease the given object.
Selector getSelector() const
llvm::LLVMContext & getLLVMContext()
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c array literal.
virtual llvm::Value * GetSelector(CodeGenFunction &CGF, Selector Sel)=0
Get a selector for the specified name and type values.
Expr * getElement(unsigned Index)
getExpr - Return the Expr at the specified index.
bool isInstanceMethod() const
clang::ObjCRuntime ObjCRuntime
virtual llvm::Constant * GetPropertyGetFunction()=0
Return the runtime function for getting properties.
QualType getObjCIdType() const
Represents the Objective-CC id type.
ReturnStmt - This represents a return, optionally of an expression: return; return 4;...
An expression that sends a message to the given Objective-C object or class.
static OMPLinearClause * Create(const ASTContext &C, SourceLocation StartLoc, SourceLocation LParenLoc, OpenMPLinearClauseKind Modifier, SourceLocation ModifierLoc, SourceLocation ColonLoc, SourceLocation EndLoc, ArrayRef< Expr * > VL, ArrayRef< Expr * > PL, ArrayRef< Expr * > IL, Expr *Step, Expr *CalcStep)
Creates clause with a list of variables VL and a linear step Step.
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
The result type of a method or function.
ARCPreciseLifetime_t isARCPreciseLifetime() const
static AggValueSlot forAddr(Address addr, Qualifiers quals, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, IsZeroed_t isZeroed=IsNotZeroed)
forAddr - Make a slot for an aggregate value.
GlobalDecl - represents a global declaration.
static llvm::Value * emitARCStoreOperation(CodeGenFunction &CGF, Address addr, llvm::Value *value, llvm::Constant *&fn, StringRef fnName, bool ignored)
Perform an operation having the following signature: i8* (i8**, i8*)
param_const_iterator param_end() const
virtual void EmitSynchronizedStmt(CodeGen::CodeGenFunction &CGF, const ObjCAtSynchronizedStmt &S)=0
The l-value was considered opaque, so the alignment was determined from a type.
bool isClassMethod() const
ArrayRef< ParmVarDecl * > parameters() const
CK_CPointerToObjCPointerCast - Casting a C pointer kind to an Objective-C pointer.
llvm::Constant * objc_retainBlock
id objc_retainBlock(id);
There is no lifetime qualification on this type.
OpaqueValueExpr - An expression referring to an opaque object of a fixed type and value class...
Address CreateBitCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name="")
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
SelectorTable & Selectors
llvm::Constant * CreateRuntimeFunction(llvm::FunctionType *Ty, StringRef Name, llvm::AttributeSet ExtraAttrs=llvm::AttributeSet())
Create a new runtime function with the specified type and name.
Assigning into this object requires the old value to be released and the new value to be retained...
llvm::Constant * objc_storeWeak
id objc_storeWeak(id*, id);
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
ASTContext & getContext() const
Encodes a location in the source.
CharUnits getPointerAlign() const
llvm::Value * EmitObjCArrayLiteral(const ObjCArrayLiteral *E)
void EmitARCIntrinsicUse(ArrayRef< llvm::Value * > values)
Given a number of pointers, inform the optimizer that they're being intrinsically used up until this ...
IdentifierInfo & get(StringRef Name)
Return the identifier token info for the specified named identifier.
static void emitCPPObjectAtomicGetterCall(CodeGenFunction &CGF, llvm::Value *returnAddr, ObjCIvarDecl *ivar, llvm::Constant *AtomicHelperFn)
emitCPPObjectAtomicGetterCall - Call the runtime function to copy the ivar into the resturn slot...
void EmitARCRelease(llvm::Value *value, ARCPreciseLifetime_t precise)
Release the given object.
LValue EmitDeclRefLValue(const DeclRefExpr *E)
const TemplateArgument * iterator
virtual ConstantAddress GenerateConstantString(const StringLiteral *)=0
Generate a constant string object.
llvm::Value * EmitLoadOfScalar(Address Addr, bool Volatile, QualType Ty, SourceLocation Loc, AlignmentSource AlignSource=AlignmentSource::Type, llvm::MDNode *TBAAInfo=nullptr, QualType TBAABaseTy=QualType(), uint64_t TBAAOffset=0, bool isNontemporal=false)
EmitLoadOfScalar - Load a scalar value from an address, taking care to appropriately convert from the...
void EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S)
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
QualType withConst() const
llvm::Constant * objc_autoreleasePoolPush
void *objc_autoreleasePoolPush(void);
static TryEmitResult tryEmitARCRetainLoadOfScalar(CodeGenFunction &CGF, LValue lvalue, QualType type)
const CGFunctionInfo & arrangeObjCMethodDeclaration(const ObjCMethodDecl *MD)
Arrange the argument and result information for the declaration or definition of an Objective-C metho...
virtual llvm::Value * EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF)
const ObjCInterfaceDecl * getClassInterface() const
ObjCProtocolExpr used for protocol expression in Objective-C.
virtual llvm::Value * GenerateProtocolRef(CodeGenFunction &CGF, const ObjCProtocolDecl *OPD)=0
Emit the code to return the named protocol as an object, as in a @protocol expression.
llvm::InlineAsm * retainAutoreleasedReturnValueMarker
A void(void) inline asm to use to mark that the return value of a call will be immediately retain...
static llvm::Constant * createARCRuntimeFunction(CodeGenModule &CGM, llvm::FunctionType *type, StringRef fnName)
const CodeGenOptions & getCodeGenOpts() const
void StartFunction(GlobalDecl GD, QualType RetTy, llvm::Function *Fn, const CGFunctionInfo &FnInfo, const FunctionArgList &Args, SourceLocation Loc=SourceLocation(), SourceLocation StartLoc=SourceLocation())
Emit code for the start of a function.
const LangOptions & getLangOpts() const
Represents one property declaration in an Objective-C interface.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
QualType getReturnType() const
JumpDest getJumpDestInCurrentScope(llvm::BasicBlock *Target)
The given basic block lies in the current EH scope, but may be a target of a potentially scope-crossi...
static void destroyARCStrongWithStore(CodeGenFunction &CGF, Address addr, QualType type)
Like CodeGenFunction::destroyARCStrong, but do it with a call.
Assigning into this object requires a lifetime extension.
ObjCBoxedExpr - used for generalized expression boxing.
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
virtual llvm::Constant * GetCppAtomicObjectGetFunction()=0
API for atomic copying of qualified aggregates with non-trivial copy assignment (c++) in getter...
llvm::Value * EmitARCRetain(QualType type, llvm::Value *value)
Produce the code to do a retain.
void enterFullExpression(const ExprWithCleanups *E)
static Destroyer destroyARCStrongImprecise
void FinishFunction(SourceLocation EndLoc=SourceLocation())
FinishFunction - Complete IR generation of the current function.
Expr * Value
The value of the dictionary element.
ConstantAddress GetAddrOfConstantCString(const std::string &Str, const char *GlobalName=nullptr)
Returns a pointer to a character array containing the literal and a terminating '\0' character...
void EmitObjCMRRAutoreleasePoolPop(llvm::Value *Ptr)
Produce the code to do a primitive release.
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
EmitScalarExpr - Emit the computation of the specified expression of LLVM scalar type, returning the result.
Expr * getInstanceReceiver()
Returns the object expression (receiver) for an instance message, or null for a message that is not a...
FunctionArgList - Type for representing both the decl and type of parameters to a function...
ObjCIvarDecl * getNextIvar()
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Expr * getResultExpr()
Return the result-bearing expression, or null if there is none.
void EmitObjCAtSynchronizedStmt(const ObjCAtSynchronizedStmt &S)
void ErrorUnsupported(const Stmt *S, const char *Type)
Print out an error that codegen doesn't support the specified stmt yet.
CGFunctionInfo - Class to encapsulate the information about a function definition.
This class organizes the cross-function state that is used while generating LLVM code.
static llvm::Value * emitARCValueOperation(CodeGenFunction &CGF, llvm::Value *value, llvm::Constant *&fn, StringRef fnName, bool isTailCall=false)
Perform an operation having the signature i8* (i8*) where a null input causes a no-op and returns nul...
void GenerateObjCGetter(ObjCImplementationDecl *IMP, const ObjCPropertyImplDecl *PID)
GenerateObjCGetter - Synthesize an Objective-C property getter function.
bool isZero() const
isZero - Test whether the quantity equals zero.
unsigned char PointerAlignInBytes
void EmitObjCAutoreleasePoolPop(llvm::Value *Ptr)
Produce the code to do a primitive release.
Address CreateMemTemp(QualType T, const Twine &Name="tmp")
CreateMemTemp - Create a temporary memory object of the given type, with appropriate alignment...
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
The basic abstraction for the target Objective-C runtime.
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
llvm::Value * EmitARCLoadWeakRetained(Address addr)
i8* @objc_loadWeakRetained(i8** addr)
Address CreateStructGEP(Address Addr, unsigned Index, CharUnits Offset, const llvm::Twine &Name="")
llvm::LoadInst * CreateAlignedLoad(llvm::Value *Addr, CharUnits Align, const llvm::Twine &Name="")
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
llvm::Constant * objc_destroyWeak
void objc_destroyWeak(id*);
U cast(CodeGen::Address addr)
llvm::Constant * clang_arc_use
void clang.arc.use(...);
QualType TypeOfSelfObject()
TypeOfSelfObject - Return type of object that this self represents.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
Selector getSelector() const
ObjCMethodDecl * getArrayWithObjectsMethod() const
CK_BlockPointerToObjCPointerCast - Casting a block pointer to an ObjC pointer.
detail::InMemoryDirectory::const_iterator E
void EmitAggregateCopy(Address DestPtr, Address SrcPtr, QualType EltTy, bool isVolatile=false, bool isAssignment=false)
EmitAggregateCopy - Emit an aggregate copy.
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
semantics_iterator semantics_begin()
llvm::Constant * GenerateObjCAtomicGetterCopyHelperFunction(const ObjCPropertyImplDecl *PID)
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
static bool hasTrivialSetExpr(const ObjCPropertyImplDecl *PID)
void EmitObjCAtThrowStmt(const ObjCAtThrowStmt &S)
static CharUnits getMaxAtomicAccessSize(CodeGenModule &CGM, llvm::Triple::ArchType arch)
Return the maximum size that permits atomic accesses for the given architecture.
void EmitAggExpr(const Expr *E, AggValueSlot AS)
EmitAggExpr - Emit the computation of the specified expression of aggregate type. ...
ObjCMethodDecl * getDictWithObjectsMethod() const
[ARC] Reclaim a retainable object pointer object that may have been produced and autoreleased as part...
Defines the Diagnostic-related interfaces.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
Represents a pointer to an Objective C object.
void EmitAutoVarCleanups(const AutoVarEmission &emission)
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
ObjCMethodDecl * getGetterMethodDecl() const
llvm::PointerType * getType() const
Return the type of the pointer value.
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
virtual llvm::Constant * EnumerationMutationFunction()=0
EnumerationMutationFunction - Return the function that's called by the compiler when a mutation is de...
const T * getAs() const
Member-template getAs<specific type>'.
QualType getCanonicalType() const
const Stmt * getSubStmt() const
Represents Objective-C's collection statement.
Address CreateConstArrayGEP(Address Addr, uint64_t Index, CharUnits EltSize, const llvm::Twine &Name="")
Given addr = [n x T]* ...
void EmitStoreOfComplex(ComplexPairTy V, LValue dest, bool isInit)
EmitStoreOfComplex - Store a complex number into the specified l-value.
static void emitARCCopyOperation(CodeGenFunction &CGF, Address dst, Address src, llvm::Constant *&fn, StringRef fnName)
Perform an operation having the following signature: void (i8**, i8**)
ObjCMethodDecl * getSetterMethodDecl() const
Selector getSelector(unsigned NumArgs, IdentifierInfo **IIV)
Can create any sort of selector.
[ARC] Produces a retainable object pointer so that it may be consumed, e.g.
This class organizes the cross-module state that is used while lowering AST types to LLVM types...
llvm::PointerType * Int8PtrTy
LValue EmitLValueForIvar(QualType ObjectTy, llvm::Value *Base, const ObjCIvarDecl *Ivar, unsigned CVRQualifiers)
llvm::Constant * objc_retainAutorelease
id objc_retainAutorelease(id);
void EmitScalarInit(const Expr *init, const ValueDecl *D, LValue lvalue, bool capturedByInit)
llvm::Value * EmitIvarOffset(const ObjCInterfaceDecl *Interface, const ObjCIvarDecl *Ivar)
llvm::Value * EmitARCRetainAutorelease(QualType type, llvm::Value *value)
Do a fused retain/autorelease of the given object.
Internal linkage, which indicates that the entity can be referred to from within the translation unit...
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
EmitBlock - Emit the given block.
void setAtomicSetterHelperFnMap(QualType Ty, llvm::Constant *Fn)
void EmitARCInitWeak(Address addr, llvm::Value *value)
i8* @objc_initWeak(i8** addr, i8* value) Returns value.
ARCPreciseLifetime_t
Does an ARC strong l-value have precise lifetime?
ObjCIvarRefExpr - A reference to an ObjC instance variable.
llvm::Constant * objc_moveWeak
void objc_moveWeak(id *dest, id *src);
llvm::ConstantInt * getSize(CharUnits numChars)
Emit the given number of characters as a value of type size_t.
const Decl * CurFuncDecl
CurFuncDecl - Holds the Decl for the current outermost non-closure context.
virtual llvm::Value * GetClass(CodeGenFunction &CGF, const ObjCInterfaceDecl *OID)=0
GetClass - Return a reference to the class for the given interface decl.
bool hasNonTrivialObjCLifetime() const
ObjCPropertyDecl * getPropertyDecl() const
Reading or writing from this object requires a barrier call.
bool hasAtomicCopyHelper() const
void EmitLexicalBlockStart(CGBuilderTy &Builder, SourceLocation Loc)
Emit metadata to indicate the beginning of a new lexical block and push the block onto the stack...
llvm::iterator_range< arg_iterator > arguments()
A non-RAII class containing all the information about a bound opaque value.
bool isARCPseudoStrong() const
Determine whether this variable is an ARC pseudo-__strong variable.
QualType getUnqualifiedType() const
Retrieve the unqualified variant of the given type, removing as little sugar as possible.
llvm::Value * EmitObjCCollectionLiteral(const Expr *E, const ObjCMethodDecl *MethodWithObjects)
void EmitReturnStmt(const ReturnStmt &S)
EmitReturnStmt - Note that due to GCC extensions, this can have an operand if the function returns vo...
llvm::Type * ConvertType(QualType T)
ObjCIvarDecl - Represents an ObjC instance variable.
static llvm::Constant * getNullForVariable(Address addr)
Given the address of a variable of pointer type, find the correct null to store into it...
LValue EmitLValue(const Expr *E)
EmitLValue - Emit code to compute a designator that specifies the location of the expression...
Address ReturnValue
ReturnValue - The temporary alloca to hold the return value.
Represents Objective-C's @try ... @catch ... @finally statement.
bool AutoreleaseResult
In ARC, whether we should autorelease the return value.
RValue EmitLoadOfLValue(LValue V, SourceLocation Loc)
EmitLoadOfLValue - Given an expression that represents a value lvalue, this method emits the address ...
llvm::Value * EmitARCRetainBlock(llvm::Value *value, bool mandatory)
Retain the given block, with _Block_copy semantics.
void generateObjCGetterBody(const ObjCImplementationDecl *classImpl, const ObjCPropertyImplDecl *propImpl, const ObjCMethodDecl *GetterMothodDecl, llvm::Constant *AtomicHelperFn)
void ForceCleanup()
Force the emission of cleanups now, instead of waiting until this object is destroyed.
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
void StartObjCMethod(const ObjCMethodDecl *MD, const ObjCContainerDecl *CD)
StartObjCMethod - Begin emission of an ObjCMethod.
SourceLocation getRBracLoc() const
static Decl::Kind getKind(const Decl *D)
virtual llvm::Constant * GetCppAtomicObjectSetFunction()=0
API for atomic copying of qualified aggregates with non-trivial copy assignment (c++) in setter...
QualType getObjCFastEnumerationStateType()
Retrieve the record type that describes the state of an Objective-C fast enumeration loop (for...
void EmitObjCAutoreleasePoolCleanup(llvm::Value *Ptr)
CK_NoOp - A conversion which does not affect the type other than (possibly) adding qualifiers...
A reference to a declared variable, function, enum, etc.
static RValue get(llvm::Value *V)
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
static llvm::Value * emitARCRetainCall(CodeGenFunction &CGF, const Expr *e)
Given that the given expression is some sort of call (which does not return retained), emit a retain following it.
static const Expr * findWeakLValue(const Expr *E)
Given an expression of ObjC pointer type, check whether it was immediately loaded from an ARC __weak ...
const CGFunctionInfo & arrangeFreeFunctionCall(const CallArgList &Args, const FunctionType *Ty, bool ChainCall)
Figure out the rules for calling a function with the given formal type using the given arguments...
Address EmitCompoundStmtWithoutScope(const CompoundStmt &S, bool GetLast=false, AggValueSlot AVS=AggValueSlot::ignored())
llvm::Value * LoadObjCSelf()
LoadObjCSelf - Load the value of self.
Qualifiers::GC getObjCGCAttrKind(QualType Ty) const
Return one of the GCNone, Weak or Strong Objective-C garbage collection attributes.
An l-value expression is a reference to an object with independent storage.
CodeGenTypes & getTypes() const
A trivial tuple used to represent a source range.
SourceLocation getLocation() const
void EmitObjCAtTryStmt(const ObjCAtTryStmt &S)
LValue - This represents an lvalue references.
Information for lazily generating a cleanup.
ObjCIvarDecl * all_declared_ivar_begin()
all_declared_ivar_begin - return first ivar declared in this class, its extensions and its implementa...
llvm::Value * EmitObjCConsumeObject(QualType T, llvm::Value *Ptr)
Produce the code for a CK_ARCConsumeObject.
static llvm::Value * emitARCLoadOperation(CodeGenFunction &CGF, Address addr, llvm::Constant *&fn, StringRef fnName)
Perform an operation having the following signature: i8* (i8**)
llvm::PointerIntPair< llvm::Value *, 1, bool > TryEmitResult
bool isConstQualified() const
Determine whether this type is const-qualified.
The receiver is a superclass.
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
llvm::Constant * objc_retainAutoreleaseReturnValue
id objc_retainAutoreleaseReturnValue(id);
void EmitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt &S)
CallArgList - Type for representing both the value and type of arguments in a call.
void PopCleanupBlock(bool FallThroughIsBranchThrough=false)
PopCleanupBlock - Will pop the cleanup entry on the stack and process all branch fixups.
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
Represents Objective-C's @autoreleasepool Statement.
CGCalleeInfo - Class to encapsulate the information about a callee to be used during the generation o...
A class which abstracts out some details necessary for making a call.
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
bool hasPointerRepresentation() const
Whether this type is represented natively as a pointer.
void EmitNullInitialization(Address DestPtr, QualType Ty)
EmitNullInitialization - Generate code to set a value of the given type to null, If the type contains...
bool hasLocalStorage() const
hasLocalStorage - Returns true if a variable with function scope is a non-static local variable...
Expr * IgnoreParens() LLVM_READONLY
IgnoreParens - Ignore parentheses.
static void emitCPPObjectAtomicSetterCall(CodeGenFunction &CGF, ObjCMethodDecl *OMD, ObjCIvarDecl *ivar, llvm::Constant *AtomicHelperFn)
emitCPPObjectAtomicSetterCall - Call the runtime function to store the value from the first formal pa...
llvm::Value * EmitObjCSelectorExpr(const ObjCSelectorExpr *E)
Emit a selector.
void Destroyer(CodeGenFunction &CGF, Address addr, QualType ty)
static void emitCXXDestructMethod(CodeGenFunction &CGF, ObjCImplementationDecl *impl)
unsigned char PointerSizeInBytes
llvm::Value * EmitObjCProtocolExpr(const ObjCProtocolExpr *E)
llvm::FunctionType * GetFunctionType(const CGFunctionInfo &Info)
GetFunctionType - Get the LLVM function type for.