25 #include "llvm/ADT/STLExtras.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));
71 assert(BoxingMethod->
isClassMethod() &&
"BoxingMethod must be a class method");
88 if (ValueType->isObjCBoxableRecordType()) {
113 Args, ClassDecl, BoxingMethod);
124 DLE = cast<ObjCDictionaryLiteral>(E);
127 uint64_t NumElements =
130 StringRef ConstantName = ALE ?
"__NSArray0__" :
"__NSDictionary0__";
132 llvm::Constant *Constant =
136 cast<llvm::LoadInst>(Ptr)->setMetadata(
159 bool TrackNeededObjects =
164 for (uint64_t i = 0; i < NumElements; i++) {
173 if (TrackNeededObjects) {
174 NeededObjects.push_back(value);
190 if (TrackNeededObjects) {
191 NeededObjects.push_back(keyValue);
192 NeededObjects.push_back(valueValue);
227 Receiver, Args, Class, MethodWithObjects);
233 if (TrackNeededObjects) {
294 if (
auto opaque = dyn_cast<OpaqueValueExpr>(receiver)) {
295 if (opaque->getSourceExpr())
300 if (!ice || ice->
getCastKind() != CK_LValueToRValue)
return true;
304 if (
auto opaque = dyn_cast<OpaqueValueExpr>(receiver)) {
305 if (opaque->getSourceExpr())
314 if (isa<MemberExpr>(receiver) || isa<ObjCIvarRefExpr>(receiver))
319 if (!declRef)
return true;
321 if (!var)
return true;
326 !var->
hasAttr<ObjCPreciseLifetimeAttr>());
339 llvm_unreachable(
"invalid receiver kind");
347 if (
auto CE = dyn_cast<CastExpr>(E)) {
348 if (CE->getCastKind() == CK_LValueToRValue) {
350 return CE->getSubExpr();
376 bool isClassMessage) {
384 if (isClassMessage &&
385 Runtime.shouldUseRuntimeFunctionsForAlloc() &&
394 Args.size() == 1 && Args.front().getType()->isPointerType() &&
396 const llvm::Value* arg = Args.front().getKnownRValue().getScalarVal();
397 if (isa<llvm::ConstantPointerNull>(arg))
408 Runtime.shouldUseARCFunctionsForRetainRelease())
415 Runtime.shouldUseARCFunctionsForRetainRelease())
422 Runtime.shouldUseARCFunctionsForRetainRelease()) {
438 bool isClassMessage) {
441 Sel, Method, isClassMessage)) {
444 return GenerateMessageSend(CGF, Return, ResultType, Sel, Receiver, Args, OID,
454 if (!Runtime.shouldUseRuntimeFunctionForCombinedAllocInit())
470 Selector SubSel = SubOME->getSelector();
472 if (!SubOME->getType()->isObjCObjectPointerType() ||
477 switch (SubOME->getReceiverKind()) {
479 if (!SubOME->getInstanceReceiver()->getType()->isObjCClassType())
485 QualType ReceiverType = SubOME->getClassReceiver();
488 assert(ID &&
"null interface should be impossible here");
532 method->
hasAttr<NSConsumesSelfAttr>());
535 bool isSuperMessage =
false;
536 bool isClassMessage =
false;
548 Receiver = ter.getPointer();
549 if (ter.getInt()) retainSelf =
false;
557 assert(OID &&
"Invalid Objective-C class message send");
558 Receiver = Runtime.
GetClass(*
this, OID);
559 isClassMessage =
true;
566 isSuperMessage =
true;
572 isSuperMessage =
true;
573 isClassMessage =
true;
584 method->
hasAttr<ObjCReturnsInnerPointerAttr>() &&
600 if (isDelegateInit) {
602 "delegate init calls should only be marked in ARC");
611 if (isSuperMessage) {
614 bool isCategoryImpl = isa<ObjCCategoryImplDecl>(OMD->
getDeclContext());
626 *
this, Return, ResultType, E->
getSelector(), Receiver, Args, OID,
627 method, isClassMessage);
632 if (isDelegateInit) {
655 if (!iface->getSuperClass())
return;
657 bool isCategory = isa<ObjCCategoryImplDecl>(impl);
684 if (OMD->
hasAttr<NoDebugAttr>())
723 if (ident->
isStr(
"dealloc"))
736 assert(isa<CompoundStmt>(OMD->
getBody()));
745 bool isAtomic,
bool hasStrong) {
785 llvm::Triple::ArchType arch) {
795 class PropertyImplStrategy {
807 SetPropertyAndExpressionGet,
817 StrategyKind
getKind()
const {
return StrategyKind(
Kind); }
819 bool hasStrongMember()
const {
return HasStrong; }
820 bool isAtomic()
const {
return IsAtomic; }
821 bool isCopy()
const {
return IsCopy; }
823 CharUnits getIvarSize()
const {
return IvarSize; }
824 CharUnits getIvarAlignment()
const {
return IvarAlignment; }
831 unsigned IsAtomic : 1;
833 unsigned HasStrong : 1;
853 std::tie(IvarSize, IvarAlignment) =
859 Kind = GetSetProperty;
872 }
else if (CGM.
getLangOpts().ObjCAutoRefCount && !IsAtomic) {
882 Kind = SetPropertyAndExpressionGet;
888 }
else if (!IsAtomic) {
889 Kind = SetPropertyAndExpressionGet;
894 Kind = GetSetProperty;
925 HasStrong =
recordType->getDecl()->hasObjectMember();
940 if (!IvarSize.isPowerOfTwo()) {
945 llvm::Triple::ArchType arch =
973 llvm::Constant *AtomicHelperFn =
976 assert(OMD &&
"Invalid call to generate getter (empty method)");
986 if (!getter)
return true;
999 return (construct->getConstructor()->isTrivial());
1003 assert(isa<ExprWithCleanups>(getter));
1012 llvm::Constant *AtomicHelperFn) {
1030 llvm::FunctionCallee copyCppAtomicObjectFn =
1042 llvm::Constant *AtomicHelperFn) {
1045 if (!AtomicHelperFn) {
1054 ivar, AtomicHelperFn);
1066 PropertyImplStrategy strategy(CGM, propImpl);
1067 switch (strategy.getKind()) {
1068 case PropertyImplStrategy::Native: {
1070 if (strategy.getIvarSize().isZero())
1079 bitcastType = bitcastType->getPointerTo();
1085 load->setAtomic(llvm::AtomicOrdering::Unordered);
1091 uint64_t retTySize = CGM.
getDataLayout().getTypeSizeInBits(retTy);
1093 if (ivarSize > retTySize) {
1095 ivarVal =
Builder.CreateTrunc(load, newTy);
1096 bitcastType = newTy->getPointerTo();
1106 case PropertyImplStrategy::GetSetProperty: {
1107 llvm::FunctionCallee getPropertyFn =
1109 if (!getPropertyFn) {
1133 llvm::CallBase *CallInstruction;
1137 if (llvm::CallInst *call = dyn_cast<llvm::CallInst>(CallInstruction))
1138 call->setTailCall();
1147 EmitReturnOfRValue(RV, propType);
1155 case PropertyImplStrategy::CopyStruct:
1157 strategy.hasStrongMember());
1160 case PropertyImplStrategy::Expression:
1161 case PropertyImplStrategy::SetPropertyAndExpressionGet: {
1208 llvm_unreachable(
"bad evaluation kind");
1212 llvm_unreachable(
"bad @property implementation strategy!");
1264 llvm::Constant *AtomicHelperFn) {
1288 llvm::FunctionCallee fn =
1299 if (!setter)
return true;
1309 if (
CallExpr *call = dyn_cast<CallExpr>(setter)) {
1311 = dyn_cast_or_null<FunctionDecl>(call->getCalleeDecl()))
1312 if (callee->isTrivial())
1317 assert(isa<ExprWithCleanups>(setter));
1330 llvm::Constant *AtomicHelperFn) {
1337 if (!AtomicHelperFn)
1347 PropertyImplStrategy strategy(CGM, propImpl);
1348 switch (strategy.getKind()) {
1349 case PropertyImplStrategy::Native: {
1351 if (strategy.getIvarSize().isZero())
1358 Address ivarAddr = ivarLValue.getAddress(*
this);
1364 getContext().toBits(strategy.getIvarSize()));
1375 store->setAtomic(llvm::AtomicOrdering::Unordered);
1379 case PropertyImplStrategy::GetSetProperty:
1380 case PropertyImplStrategy::SetPropertyAndExpressionGet: {
1382 llvm::FunctionCallee setOptimizedPropertyFn =
nullptr;
1383 llvm::FunctionCallee setPropertyFn =
nullptr;
1386 setOptimizedPropertyFn =
1388 strategy.isAtomic(), strategy.isCopy());
1389 if (!setOptimizedPropertyFn) {
1396 if (!setPropertyFn) {
1417 if (setOptimizedPropertyFn) {
1440 case PropertyImplStrategy::CopyStruct:
1444 case PropertyImplStrategy::Expression:
1453 selfDecl->
getType(), CK_LValueToRValue, &
self,
1457 &selfLoad,
true,
true);
1460 QualType argType = argDecl->getType().getNonReferenceType();
1471 if (ivarRef.getType()->isObjCObjectPointerType()) {
1472 if (argLoad.getType()->isObjCObjectPointerType())
1474 else if (argLoad.getType()->isBlockPointerType())
1475 argCK = CK_BlockPointerToObjCPointerCast;
1477 argCK = CK_CPointerToObjCPointerCast;
1478 }
else if (ivarRef.getType()->isBlockPointerType()) {
1479 if (argLoad.getType()->isBlockPointerType())
1482 argCK = CK_AnyPointerToBlockPointerCast;
1483 }
else if (ivarRef.getType()->isPointerType()) {
1487 ivarRef.getType(), argCK, &argLoad,
1489 Expr *finalArg = &argLoad;
1492 finalArg = &argCast;
1507 llvm::Constant *AtomicHelperFn =
1510 assert(OMD &&
"Invalid call to generate setter (empty method)");
1524 bool useEHCleanupForArray;
1528 bool useEHCleanupForArray)
1529 : addr(addr), ivar(ivar), destroyer(destroyer),
1530 useEHCleanupForArray(useEHCleanupForArray) {}
1536 flags.isForNormalCleanup() && useEHCleanupForArray);
1562 if (!dtorKind)
continue;
1578 CGF.
EHStack.pushCleanup<DestroyIvar>(cleanupKind,
self, ivar, destroyer,
1596 for (
const auto *IvarInit : IMP->
inits()) {
1597 FieldDecl *Field = IvarInit->getAnyMember();
1638 llvm::FunctionCallee EnumerationMutationFnPtr =
1640 if (!EnumerationMutationFnPtr) {
1666 static const unsigned NumItems = 16;
1715 llvm::Constant *Count = llvm::ConstantInt::get(NSUIntegerTy, NumItems);
1722 FastEnumSel, Collection, Args);
1730 llvm::Value *zero = llvm::Constant::getNullValue(NSUIntegerTy);
1737 Builder.CreateICmpEQ(initialBufferLimit, zero,
"iszero"), EmptyBB,
1747 Address StateMutationsPtrPtr =
1754 "forcoll.initial-mutations");
1762 llvm::PHINode *index =
Builder.CreatePHI(NSUIntegerTy, 3,
"forcoll.index");
1763 index->addIncoming(zero, LoopInitBB);
1766 llvm::PHINode *count =
Builder.CreatePHI(NSUIntegerTy, 3,
"forcoll.count");
1767 count->addIncoming(initialBufferLimit, LoopInitBB);
1780 llvm::BasicBlock *WasNotMutatedBB =
createBasicBlock(
"forcoll.notmutated");
1782 Builder.CreateCondBr(
Builder.CreateICmpEQ(currentMutations, initialMutations),
1783 WasNotMutatedBB, WasMutatedBB);
1803 bool elementIsVariable;
1810 const VarDecl *D = cast<VarDecl>(SD->getSingleDecl());
1815 elementIsVariable =
true;
1820 elementLValue =
LValue();
1821 elementType = cast<Expr>(S.
getElement())->getType();
1822 elementIsVariable =
false;
1836 Builder.CreateGEP(EnumStateItems, index,
"currentitem.ptr");
1846 if (!elementIsVariable) {
1856 if (elementIsVariable)
1860 BreakContinueStack.push_back(BreakContinue(LoopEnd, AfterBody));
1865 BreakContinueStack.pop_back();
1877 Builder.CreateAdd(index, llvm::ConstantInt::get(NSUIntegerTy, 1));
1884 Builder.CreateICmpULT(indexPlusOne, count), LoopBodyBB, FetchMoreBB,
1887 index->addIncoming(indexPlusOne, AfterBody.getBlock());
1888 count->addIncoming(count, AfterBody.getBlock());
1896 FastEnumSel, Collection, Args);
1902 index->addIncoming(zero,
Builder.GetInsertBlock());
1903 count->addIncoming(refetchCount,
Builder.GetInsertBlock());
1906 EmptyBB, LoopBodyBB);
1911 if (!elementIsVariable) {
1914 llvm::Value *null = llvm::Constant::getNullValue(convertedElementType);
1941 CallObjCRelease(
llvm::Value *
object) : object(
object) {}
1971 fn = CGM.
getIntrinsic(llvm::Intrinsic::objc_clang_arc_use);
1979 if (
auto *F = dyn_cast<llvm::Function>(RTF)) {
1985 F->setLinkage(llvm::Function::ExternalWeakLinkage);
1991 llvm::FunctionCallee RTF) {
2001 llvm::CallInst::TailCallKind tailKind = llvm::CallInst::TCK_None) {
2002 if (isa<llvm::ConstantPointerNull>(value))
2011 llvm::Type *origType = returnType ? returnType : value->getType();
2016 call->setTailCallKind(tailKind);
2025 llvm::Function *&fn,
2050 llvm::Function *&fn,
2068 if (ignored)
return nullptr;
2076 llvm::Function *&fn,
2098 llvm::FunctionCallee &fn,
2100 if (isa<llvm::ConstantPointerNull>(value))
2104 llvm::FunctionType *fnType =
2109 if (llvm::Function *f = dyn_cast<llvm::Function>(fn.getCallee()))
2110 if (fnName ==
"objc_retain")
2111 f->addFnAttr(llvm::Attribute::NonLazyBind);
2115 llvm::Type *origType = returnType ? returnType : value->getType();
2140 llvm::Intrinsic::objc_retain);
2154 llvm::Intrinsic::objc_retainBlock);
2160 if (!mandatory && isa<llvm::Instruction>(result)) {
2161 llvm::CallInst *call
2162 = cast<llvm::CallInst>(result->stripPointerCasts());
2165 call->setMetadata(
"clang.arc.copy_on_escape",
2166 llvm::MDNode::get(
Builder.getContext(), None));
2175 llvm::InlineAsm *&marker
2183 if (assembly.empty()) {
2188 llvm::FunctionType *type =
2189 llvm::FunctionType::get(CGF.
VoidTy,
false);
2191 marker = llvm::InlineAsm::get(type, assembly,
"",
true);
2197 const char *markerKey =
"clang.arc.retainAutoreleasedReturnValueMarker";
2218 llvm::CallInst::TailCallKind tailKind =
2221 ? llvm::CallInst::TCK_NoTail
2222 : llvm::CallInst::TCK_None;
2224 *
this, value,
nullptr,
2226 llvm::Intrinsic::objc_retainAutoreleasedReturnValue, tailKind);
2241 llvm::Intrinsic::objc_unsafeClaimAutoreleasedReturnValue);
2248 if (isa<llvm::ConstantPointerNull>(value))
return;
2263 call->setMetadata(
"clang.imprecise_release",
2264 llvm::MDNode::get(
Builder.getContext(), None));
2298 fn = CGM.
getIntrinsic(llvm::Intrinsic::objc_storeStrong);
2308 if (ignored)
return nullptr;
2353 llvm::Intrinsic::objc_autorelease);
2362 llvm::Intrinsic::objc_autoreleaseReturnValue,
2363 llvm::CallInst::TCK_Tail);
2372 llvm::Intrinsic::objc_retainAutoreleaseReturnValue,
2373 llvm::CallInst::TCK_Tail);
2386 if (isa<llvm::ConstantPointerNull>(value))
return value;
2401 llvm::Intrinsic::objc_retainAutorelease);
2409 llvm::Intrinsic::objc_loadWeak);
2416 llvm::Intrinsic::objc_loadWeakRetained);
2426 llvm::Intrinsic::objc_storeWeak, ignored);
2438 if (isa<llvm::ConstantPointerNull>(value) &&
2446 llvm::Intrinsic::objc_initWeak,
true);
2454 fn = CGM.
getIntrinsic(llvm::Intrinsic::objc_destroyWeak);
2470 llvm::Intrinsic::objc_moveWeak);
2479 llvm::Intrinsic::objc_copyWeak);
2502 fn = CGM.
getIntrinsic(llvm::Intrinsic::objc_autoreleasePoolPush);
2516 llvm::FunctionCallee &fn =
2519 llvm::FunctionType *fnType =
2530 fn = CGM.
getIntrinsic(llvm::Intrinsic::objc_autoreleasePoolPop);
2553 AllocSel, Receiver, Args);
2562 InitSel, Receiver, Args);
2581 "objc_allocWithZone");
2630 *
this, value, returnType,
2632 "objc_autorelease");
2640 *
this, value, returnType,
2648 if (isa<llvm::ConstantPointerNull>(value))
return;
2650 llvm::FunctionCallee &fn =
2653 llvm::FunctionType *fnType =
2658 if (llvm::Function *f = dyn_cast<llvm::Function>(fn.getCallee()))
2659 f->addFnAttr(llvm::Attribute::NonLazyBind);
2669 call->setMetadata(
"clang.imprecise_release",
2670 llvm::MDNode::get(
Builder.getContext(), None));
2678 CallObjCAutoreleasePoolObject(
llvm::Value *token) : Token(token) {}
2687 CallObjCMRRAutoreleasePoolObject(
llvm::Value *token) : Token(token) {}
2714 llvm_unreachable(
"impossible lifetime!");
2761 isa<BinaryOperator>(e) &&
2762 cast<BinaryOperator>(e)->getOpcode() == BO_Assign)
2768 if (
const auto *decl_expr = dyn_cast<DeclRefExpr>(e)) {
2787 if (llvm::CallInst *call = dyn_cast<llvm::CallInst>(value)) {
2788 CGBuilderTy::InsertPoint ip = CGF.
Builder.saveIP();
2791 CGF.
Builder.SetInsertPoint(call->getParent(),
2792 ++llvm::BasicBlock::iterator(call));
2793 value = doAfterCall(CGF, value);
2797 }
else if (llvm::InvokeInst *invoke = dyn_cast<llvm::InvokeInst>(value)) {
2798 CGBuilderTy::InsertPoint ip = CGF.
Builder.saveIP();
2801 llvm::BasicBlock *BB = invoke->getNormalDest();
2802 CGF.
Builder.SetInsertPoint(BB, BB->begin());
2803 value = doAfterCall(CGF, value);
2810 }
else if (llvm::BitCastInst *bitcast = dyn_cast<llvm::BitCastInst>(value)) {
2813 bitcast->setOperand(0, operand);
2820 return doFallback(CGF, value);
2853 bool allowUnsafeClaim) {
2854 if (allowUnsafeClaim &&
2872 if (isa<BlockExpr>(e))
2876 switch (
cast->getCastKind()) {
2878 case CK_LValueToRValue:
2879 case CK_ARCReclaimReturnedObject:
2880 case CK_ARCConsumeObject:
2881 case CK_ARCProduceObject:
2890 case CK_AnyPointerToBlockPointerCast:
2902 template <
typename Impl,
typename Result>
class ARCExprEmitter {
2905 Impl &asImpl() {
return *
static_cast<Impl*
>(
this); }
2910 Result visit(
const Expr *e);
2911 Result visitCastExpr(
const CastExpr *e);
2913 Result visitBlockExpr(
const BlockExpr *e);
2937 template <
typename Impl,
typename Result>
2939 ARCExprEmitter<Impl,Result>::visitPseudoObjectExpr(
const PseudoObjectExpr *E) {
2949 const Expr *semantic = *i;
2953 if (
const OpaqueValueExpr *ov = dyn_cast<OpaqueValueExpr>(semantic)) {
2959 if (ov == resultExpr) {
2960 assert(!OVMA::shouldBindAsLValue(ov));
2961 result = asImpl().visit(ov->getSourceExpr());
2962 opaqueData = OVMA::bind(CGF, ov,
2967 opaqueData = OVMA::bind(CGF, ov, ov->getSourceExpr());
2969 opaques.push_back(opaqueData);
2973 }
else if (semantic == resultExpr) {
2974 result = asImpl().visit(semantic);
2983 for (
unsigned i = 0, e = opaques.size(); i != e; ++i)
2984 opaques[i].unbind(CGF);
2989 template <
typename Impl,
typename Result>
2990 Result ARCExprEmitter<Impl, Result>::visitBlockExpr(
const BlockExpr *e) {
2992 return asImpl().visitExpr(e);
2995 template <
typename Impl,
typename Result>
2996 Result ARCExprEmitter<Impl,Result>::visitCastExpr(
const CastExpr *e) {
3004 case CK_CPointerToObjCPointerCast:
3005 case CK_BlockPointerToObjCPointerCast:
3006 case CK_AnyPointerToBlockPointerCast:
3010 Result result = asImpl().visit(e->
getSubExpr());
3011 return asImpl().emitBitCast(result, resultType);
3015 case CK_LValueToRValue:
3016 return asImpl().visitLValueToRValue(e->
getSubExpr());
3017 case CK_ARCConsumeObject:
3018 return asImpl().visitConsumeObject(e->
getSubExpr());
3019 case CK_ARCExtendBlockObject:
3020 return asImpl().visitExtendBlockObject(e->
getSubExpr());
3021 case CK_ARCReclaimReturnedObject:
3022 return asImpl().visitReclaimReturnedObject(e->
getSubExpr());
3026 return asImpl().visitExpr(e);
3030 template <
typename Impl,
typename Result>
3032 ARCExprEmitter<Impl,Result>::visitBinaryOperator(
const BinaryOperator *e) {
3037 return asImpl().visit(e->
getRHS());
3040 return asImpl().visitBinAssign(e);
3043 return asImpl().visitExpr(e);
3047 template <
typename Impl,
typename Result>
3048 Result ARCExprEmitter<Impl,Result>::visitBinAssign(
const BinaryOperator *e) {
3051 return asImpl().visitBinAssignUnsafeUnretained(e);
3054 return asImpl().visitBinAssignWeak(e);
3057 return asImpl().visitBinAssignAutoreleasing(e);
3060 return asImpl().visitBinAssignStrong(e);
3063 return asImpl().visitExpr(e);
3065 llvm_unreachable(
"bad ObjC ownership qualifier");
3070 template <
typename Impl,
typename Result>
3071 Result ARCExprEmitter<Impl,Result>::
3075 Result result = asImpl().visit(e->
getRHS());
3086 template <
typename Impl,
typename Result>
3088 ARCExprEmitter<Impl,Result>::visitBinAssignAutoreleasing(
const BinaryOperator *e) {
3089 return asImpl().visitExpr(e);
3092 template <
typename Impl,
typename Result>
3094 ARCExprEmitter<Impl,Result>::visitBinAssignWeak(
const BinaryOperator *e) {
3095 return asImpl().visitExpr(e);
3098 template <
typename Impl,
typename Result>
3100 ARCExprEmitter<Impl,Result>::visitBinAssignStrong(
const BinaryOperator *e) {
3101 return asImpl().visitExpr(e);
3105 template <
typename Impl,
typename Result>
3106 Result ARCExprEmitter<Impl,Result>::visit(
const Expr *e) {
3111 assert(!isa<ExprWithCleanups>(e));
3117 if (
const CastExpr *ce = dyn_cast<CastExpr>(e)) {
3118 return asImpl().visitCastExpr(ce);
3121 }
else if (
auto op = dyn_cast<BinaryOperator>(e)) {
3122 return asImpl().visitBinaryOperator(op);
3130 }
else if (isa<CallExpr>(e) ||
3131 (isa<ObjCMessageExpr>(e) &&
3132 !cast<ObjCMessageExpr>(e)->isDelegateInitCall())) {
3133 return asImpl().visitCall(e);
3136 }
else if (
const PseudoObjectExpr *pseudo = dyn_cast<PseudoObjectExpr>(e)) {
3137 return asImpl().visitPseudoObjectExpr(pseudo);
3138 }
else if (
auto *be = dyn_cast<BlockExpr>(e))
3139 return asImpl().visitBlockExpr(be);
3141 return asImpl().visitExpr(e);
3147 struct ARCRetainExprEmitter :
3148 public ARCExprEmitter<ARCRetainExprEmitter, TryEmitResult> {
3153 return result.getPointer();
3159 result.setPointer(value);
3179 result.setInt(
true);
3199 if (subresult.getInt()) {
3204 result = subresult.getPointer();
3238 return ARCRetainExprEmitter(CGF).visit(e);
3246 if (!result.getInt())
3265 if (!result.getInt())
3281 if (result.getInt())
3297 result = subresult.getPointer();
3298 doRetain = !subresult.getInt();
3325 struct ARCUnsafeUnretainedExprEmitter :
3326 public ARCExprEmitter<ARCUnsafeUnretainedExprEmitter, llvm::Value*> {
3328 ARCUnsafeUnretainedExprEmitter(
CodeGenFunction &CGF) : ARCExprEmitter(CGF) {}
3375 return ARCUnsafeUnretainedExprEmitter(CGF).visit(e);
3393 std::pair<LValue,llvm::Value*>
3409 return std::pair<LValue,llvm::Value*>(std::move(lvalue), value);
3412 std::pair<LValue,llvm::Value*>
3419 bool hasImmediateRetain = result.getInt();
3426 hasImmediateRetain =
true;
3432 if (hasImmediateRetain) {
3440 return std::pair<LValue,llvm::Value*>(lvalue, value);
3443 std::pair<LValue,llvm::Value*>
3450 return std::pair<LValue,llvm::Value*>(lvalue, value);
3472 for (
const auto *I : S.
body())
3483 llvm::FunctionType *extenderType
3485 llvm::InlineAsm *extender = llvm::InlineAsm::get(extenderType,
3510 llvm::Constant *HelperFn =
nullptr;
3528 ArgTys.push_back(DestTy);
3529 ArgTys.push_back(SrcTy);
3534 FunctionTy,
nullptr,
SC_Static,
false,
false);
3539 args.push_back(&DstDecl);
3542 args.push_back(&SrcDecl);
3549 llvm::Function *Fn =
3551 "__assign_helper_atomic_property_",
3568 Expr *Args[2] = { &DST, &SRC };
3577 HelperFn = llvm::ConstantExpr::getBitCast(Fn,
VoidPtrTy);
3594 llvm::Constant *HelperFn =
nullptr;
3612 ArgTys.push_back(DestTy);
3613 ArgTys.push_back(SrcTy);
3618 FunctionTy,
nullptr,
SC_Static,
false,
false);
3623 args.push_back(&DstDecl);
3626 args.push_back(&SrcDecl);
3651 ConstructorArgs.push_back(&SRC);
3652 ConstructorArgs.append(std::next(CXXConstExpr->arg_begin()),
3653 CXXConstExpr->arg_end());
3657 CXXConstExpr->getConstructor(),
3658 CXXConstExpr->isElidable(),
3660 CXXConstExpr->hadMultipleCandidates(),
3661 CXXConstExpr->isListInitialization(),
3662 CXXConstExpr->isStdInitListInitialization(),
3663 CXXConstExpr->requiresZeroInitialization(),
3664 CXXConstExpr->getConstructionKind(),
3682 HelperFn = llvm::ConstantExpr::getBitCast(Fn,
VoidPtrTy);
3706 Ty, AutoreleaseSelector,
3714 assert(Args.size() == 3 &&
"Expected 3 argument here!");
3717 llvm::FunctionType *FTy =
3726 return Builder.CreateICmpNE(CallRes, llvm::Constant::getNullValue(
Int32Ty));
3729 void CodeGenModule::emitAtAvailableLinkGuard() {
3730 if (!IsOSVersionAtLeastFn)
3740 llvm::Metadata *Args[2] = {llvm::MDString::get(Context,
"-framework"),
3741 llvm::MDString::get(Context,
"CoreFoundation")};
3742 LinkerOptionsMetadata.push_back(llvm::MDNode::get(Context, Args));
3745 llvm::FunctionType *FTy =
3747 llvm::FunctionCallee CFFunc =
3748 CreateRuntimeFunction(FTy,
"CFBundleGetVersionNumber");
3750 llvm::FunctionType *CheckFTy = llvm::FunctionType::get(
VoidTy, {},
false);
3751 llvm::FunctionCallee CFLinkCheckFuncRef = CreateRuntimeFunction(
3752 CheckFTy,
"__clang_at_available_requires_core_foundation_framework",
3753 llvm::AttributeList(),
true);
3754 llvm::Function *CFLinkCheckFunc =
3755 cast<llvm::Function>(CFLinkCheckFuncRef.getCallee()->stripPointerCasts());
3756 if (CFLinkCheckFunc->empty()) {
3757 CFLinkCheckFunc->setLinkage(llvm::GlobalValue::LinkOnceAnyLinkage);
3762 llvm::Constant::getNullValue(
VoidPtrTy));
3763 CGF.
Builder.CreateUnreachable();
3764 addCompilerUsedGlobal(CFLinkCheckFunc);
const CGFunctionInfo & arrangeBuiltinFunctionDeclaration(QualType resultType, const FunctionArgList &args)
A builtin function is a freestanding function using the default C conventions.
llvm::PointerType * Int8PtrPtrTy
const llvm::DataLayout & getDataLayout() const
static Optional< llvm::Value * > tryGenerateSpecializedMessageSend(CodeGenFunction &CGF, QualType ResultType, llvm::Value *Receiver, const CallArgList &Args, Selector Sel, const ObjCMethodDecl *method, bool isClassMessage)
The ObjC runtime may provide entrypoints that are likely to be faster than an ordinary message send o...
A call to an overloaded operator written using operator syntax.
The receiver is the instance of the superclass object.
ReturnValueSlot - Contains the address where the return value of a function can be stored...
const internal::VariadicAllOfMatcher< Type > type
Matches Types in the clang AST.
static bool UseOptimizedSetter(CodeGenModule &CGM)
Address CreateStructGEP(Address Addr, unsigned Index, const llvm::Twine &Name="")
SourceLocation getRBracLoc() const
Defines the clang::ASTContext interface.
const BlockDecl * getBlockDecl() const
llvm::Function * objc_retainAutoreleaseReturnValue
id objc_retainAutoreleaseReturnValue(id);
bool isClassMethod() const
llvm::FunctionCallee objc_releaseRuntimeFunction
void objc_release(id); Note this is the runtime method not the intrinsic.
Represents a function declaration or definition.
llvm::Value * EmitARCStoreStrong(LValue lvalue, llvm::Value *value, bool resultIgnored)
Store into a strong object.
void EmitObjCRelease(llvm::Value *value, ARCPreciseLifetime_t precise)
Release the given object.
The receiver is an object instance.
llvm::Value * EmitARCReclaimReturnedObject(const Expr *e, bool allowUnsafeClaim)
bool Cast(InterpState &S, CodePtr OpPC)
Other implicit parameter.
static llvm::Value * emitARCRetainCallResult(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.
ObjCDictionaryElement getKeyValueElement(unsigned Index) const
Smart pointer class that efficiently represents Objective-C method names.
llvm::Function * objc_copyWeak
void objc_copyWeak(id *dest, id *src);
QualType getObjCIdType() const
Represents the Objective-CC id type.
void SetLLVMFunctionAttributes(GlobalDecl GD, const CGFunctionInfo &Info, llvm::Function *F)
Set the LLVM function attributes (sext, zext, etc).
llvm::Value * EmitARCRetainAutoreleaseScalarExpr(const Expr *expr)
static bool hasTrivialGetExpr(const ObjCPropertyImplDecl *propImpl)
Destroyer * getDestroyer(QualType::DestructionKind destructionKind)
A (possibly-)qualified type.
bool isBlockPointerType() const
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...
CodeGenTypes & getTypes()
const CodeGenOptions & getCodeGenOpts() const
Selector getSelector() const
llvm::Value * EmitARCExtendBlockObject(const Expr *expr)
ObjCInterfaceDecl * getClassInterface()
virtual llvm::Function * GenerateMethod(const ObjCMethodDecl *OMD, const ObjCContainerDecl *CD)=0
Generate a function preamble for a method with the specified types.
Address CreateMemTemp(QualType T, const Twine &Name="tmp", Address *Alloca=nullptr)
CreateMemTemp - Create a temporary memory object of the given type, with appropriate alignmen and cas...
void enterFullExpression(const FullExpr *E)
ObjCIvarDecl * getPropertyIvarDecl() const
void EmitARCDestroyWeak(Address addr)
void @objc_destroyWeak(i8** addr) Essentially objc_storeWeak(addr, nil).
ObjCProtocolDecl * getProtocol() const
Stmt - This represents one statement.
static llvm::Value * emitARCLoadOperation(CodeGenFunction &CGF, Address addr, llvm::Function *&fn, llvm::Intrinsic::ID IntID)
Perform an operation having the following signature: i8* (i8**)
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.
QualType getPointeeType() const
If this is a pointer, ObjC object pointer, or block pointer, this returns the respective pointee...
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
bool requiresCleanups() const
Determine whether this scope requires any cleanups.
Implements runtime-specific code generation functions.
void addConst()
Add the const type qualifier to this QualType.
static void setARCRuntimeFunctionLinkage(CodeGenModule &CGM, llvm::Value *RTF)
bool isRecordType() const
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...
virtual llvm::FunctionCallee GetGetStructFunction()=0
const Decl * CurCodeDecl
CurCodeDecl - This is the inner-most code context, which includes blocks.
QualType getNonReferenceType() const
If Type is a reference type (e.g., const int&), returns the type that the reference refers to ("const...
Expr * getSetterCXXAssignment() const
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...
Represents a call to a C++ constructor.
const ObjCObjectPointerType * getAsObjCInterfacePointerType() const
bool isZero() const
isZero - Test whether the quantity equals zero.
static llvm::Value * emitARCStoreOperation(CodeGenFunction &CGF, Address addr, llvm::Value *value, llvm::Function *&fn, llvm::Intrinsic::ID IntID, bool ignored)
Perform an operation having the following signature: i8* (i8**, i8*)
QualType withConst() const
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.
Floating point control options.
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, ConstexprSpecKind ConstexprKind=CSK_unspecified, Expr *TrailingRequiresClause=nullptr)
llvm::Constant * GenerateObjCAtomicSetterCopyHelperFunction(const ObjCPropertyImplDecl *PID)
GenerateObjCAtomicSetterCopyHelperFunction - Given a c++ object type with non-trivial copy assignment...
llvm::Value * EmitARCRetainNonBlock(llvm::Value *value)
Retain the given object, with normal retain semantics.
static llvm::Value * emitARCRetainLoadOfScalar(CodeGenFunction &CGF, LValue lvalue, QualType type)
param_const_iterator param_end() const
void createImplicitParams(ASTContext &Context, const ObjCInterfaceDecl *ID)
createImplicitParams - Used to lazily create the self and cmd implict parameters. ...
static llvm::Value * emitObjCValueOperation(CodeGenFunction &CGF, llvm::Value *value, llvm::Type *returnType, llvm::FunctionCallee &fn, StringRef fnName)
Perform an operation having the signature i8* (i8*) where a null input causes a no-op and returns nul...
llvm::function_ref< llvm::Value *(CodeGenFunction &CGF, llvm::Value *value)> ValueTransform
static CXXOperatorCallExpr * Create(const ASTContext &Ctx, OverloadedOperatorKind OpKind, Expr *Fn, ArrayRef< Expr *> Args, QualType Ty, ExprValueKind VK, SourceLocation OperatorLoc, FPOptions FPFeatures, ADLCallKind UsesADL=NotADL)
static Destroyer destroyARCWeak
Address GetAddrOfLocalVar(const VarDecl *VD)
GetAddrOfLocalVar - Return the address of a local variable.
static CXXConstructExpr * Create(const ASTContext &Ctx, QualType Ty, SourceLocation Loc, CXXConstructorDecl *Ctor, bool Elidable, ArrayRef< Expr *> Args, bool HadMultipleCandidates, bool ListInitialization, bool StdInitListInitialization, bool ZeroInitialization, ConstructionKind ConstructKind, SourceRange ParenOrBraceRange)
Create a C++ construction expression.
Represents a variable declaration or definition.
Objects with "hidden" visibility are not seen by the dynamic linker.
const internal::VariadicDynCastAllOfMatcher< Stmt, Expr > expr
Matches expressions.
const T * getAs() const
Member-template getAs<specific type>'.
bool hasPointerRepresentation() const
Whether this type is represented natively as a pointer.
virtual StringRef getARCRetainAutoreleasedReturnValueMarker() const
Retrieve the address of a function to call immediately before calling objc_retainAutoreleasedReturnVa...
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.
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)
llvm::Value * getPointer() const
bool shouldUseFusedARCCalls()
llvm::Constant * getAtomicSetterHelperFnMap(QualType Ty)
Defines the Objective-C statement AST node classes.
static bool shouldRetainObjCLifetime(Qualifiers::ObjCLifetime lifetime)
Represents an expression – generally a full-expression – that introduces cleanups to be run at the ...
Represents a parameter to a function.
llvm::Value * EmitObjCDictionaryLiteral(const ObjCDictionaryLiteral *E)
The collection of all-type qualifiers we support.
void add(RValue rvalue, QualType type)
A jump destination is an abstract label, branching to which may require a jump out through normal cle...
bool isARCPseudoStrong() const
Determine whether this variable is an ARC pseudo-__strong variable.
llvm::Value * EmitObjCThrowOperand(const Expr *expr)
const Stmt * getSubStmt() const
llvm::Function * objc_retainAutorelease
id objc_retainAutorelease(id);
const AstTypeMatcher< RecordType > recordType
Matches record types (e.g.
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.
bool isStr(const char(&Str)[StrLen]) const
Return true if this is the identifier for the specified string.
Expr * getGetterCXXConstructor() 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()
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.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
const ParmVarDecl *const * param_const_iterator
std::pair< LValue, llvm::Value * > EmitARCStoreAutoreleasing(const BinaryOperator *e)
llvm::Value * EmitObjCExtendObjectLifetime(QualType T, llvm::Value *Ptr)
bool hasOptimizedSetter() const
Does this runtime supports optimized setter entrypoints?
llvm::Function * objc_initWeak
id objc_initWeak(id*, id);
SourceLocation getBeginLoc() const LLVM_READONLY
SetterKind getSetterKind() const
getSetterKind - Return the method used for doing assignment in the property setter.
llvm::Value * EmitARCRetainAutoreleaseReturnValue(llvm::Value *value)
Do a fused retain/autorelease of the given object.
Represents a member of a struct/union/class.
CharUnits getAlignment() const
ObjCMethodDecl * getSetterMethodDecl() const
llvm::FunctionCallee objc_autoreleaseRuntimeFunction
id objc_autorelease(id); Note this is the runtime method not the intrinsic.
StringLiteral * getString()
bool isReferenceType() const
Denotes a cleanup that should run when a scope is exited using exceptional control flow (a throw stat...
Token - This structure provides full information about a lexed token.
llvm::Value * EmitARCAutoreleaseReturnValue(llvm::Value *value)
Autorelease the given object.
static AggValueSlot forAddr(Address addr, Qualifiers quals, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed, IsSanitizerChecked_t isChecked=IsNotSanitizerChecked)
forAddr - Make a slot for an aggregate value.
void GenerateObjCCtorDtorMethod(ObjCImplementationDecl *IMP, ObjCMethodDecl *MD, bool ctor)
CleanupKind getCleanupKind(QualType::DestructionKind kind)
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...
An r-value expression (a pr-value in the C++11 taxonomy) produces a temporary value.
Selector getSelector() const
void EmitStoreOfScalar(llvm::Value *Value, Address Addr, bool Volatile, QualType Ty, AlignmentSource Source=AlignmentSource::Type, bool isInit=false, bool isNontemporal=false)
EmitStoreOfScalar - Store a scalar value to an address, taking care to appropriately convert from the...
ComplexPairTy EmitLoadOfComplex(LValue src, SourceLocation loc)
EmitLoadOfComplex - Load a complex number from the specified l-value.
const Expr *const * const_semantics_iterator
bool isUnarySelector() const
llvm::FunctionCallee objc_alloc_init
void objc_alloc_init(id);
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.
ObjCMethodFamily getMethodFamily() const
Determines the family of this method.
llvm::Value * EmitARCStoreStrongCall(Address addr, llvm::Value *value, bool resultIgnored)
Store into a strong object.
ARCPreciseLifetime_t isARCPreciseLifetime() const
llvm::Function * objc_release
void objc_release(id);
bool isDirectMethod() const
True if the method is tagged as objc_direct.
llvm::Value * EmitObjCAutorelease(llvm::Value *value, llvm::Type *returnType)
Autorelease the given object.
llvm::Value * EmitObjCStringLiteral(const ObjCStringLiteral *E)
Emits an instance of NSConstantString representing the object.
bool isBitField() const
Determines whether this field is a bitfield.
Selector getNullarySelector(IdentifierInfo *ID)
ObjCMethodDecl * getGetterMethodDecl() 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.
static llvm::Value * emitARCUnsafeClaimCallResult(CodeGenFunction &CGF, const Expr *e)
Given that the given expression is some sort of call (which does not return retained), perform an unsafeClaim following it.
static void emitARCCopyOperation(CodeGenFunction &CGF, Address dst, Address src, llvm::Function *&fn, llvm::Intrinsic::ID IntID)
Perform an operation having the following signature: void (i8**, i8**)
Qualifiers::GC getObjCGCAttrKind(QualType Ty) const
Return one of the GCNone, Weak or Strong Objective-C garbage collection attributes.
llvm::CallInst * EmitRuntimeCall(llvm::FunctionCallee callee, const Twine &name="")
static Optional< llvm::Value * > tryEmitSpecializedAllocInit(CodeGenFunction &CGF, const ObjCMessageExpr *OME)
Instead of '[[MyClass alloc] init]', try to generate 'objc_alloc_init(MyClass)'.
SourceLocation getLBracLoc() const
PropertyAttributeKind getPropertyAttributes() const
llvm::PointerType * VoidPtrTy
semantics_iterator semantics_end()
A builtin binary operation expression such as "x + y" or "x <= y".
bool isVolatileQualified() const
Determine whether this type is volatile-qualified.
llvm::Value * EmitARCUnsafeUnretainedScalarExpr(const Expr *expr)
EmitARCUnsafeUnretainedScalarExpr - Semantically equivalent to immediately releasing the resut of Emi...
void setAtomicGetterHelperFnMap(QualType Ty, llvm::Constant *Fn)
Defines the Diagnostic-related interfaces.
virtual bool shouldSuppressTailCallsOfRetainAutoreleasedReturnValue() const
Determine whether a call to objc_retainAutoreleasedReturnValue should be marked as 'notail'...
llvm::Value * EmitARCLoadWeak(Address addr)
i8* @objc_loadWeak(i8** addr) Essentially objc_autorelease(objc_loadWeakRetained(addr)).
Expr * IgnoreParenCasts() LLVM_READONLY
Skip past any parentheses and casts which might surround this expression until reaching a fixed point...
ObjCStringLiteral, used for Objective-C string literals i.e.
Scope - A scope is a transient data structure that is used while parsing the program.
llvm::Value * EmitObjCAllocInit(llvm::Value *value, llvm::Type *resultType)
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...
CastExpr - Base class for type casts, including both implicit casts (ImplicitCastExpr) and explicit c...
void ForceCleanup(std::initializer_list< llvm::Value **> ValuesToReload={})
Force the emission of cleanups now, instead of waiting until this object is destroyed.
llvm::Constant * CreateRuntimeVariable(llvm::Type *Ty, StringRef Name)
Create a new runtime global variable with the specified type and name.
Expr * Key
The key for the dictionary element.
ObjCMethodDecl * getArrayWithObjectsMethod() const
GlobalDecl CurGD
CurGD - The GlobalDecl for the current function being compiled.
CharUnits getPointerAlign() const
An ordinary object is located at an address in memory.
void incrementProfileCounter(const Stmt *S, llvm::Value *StepV=nullptr)
Increment the profiler's counter for the given statement by StepV.
uint64_t getCurrentProfileCount()
Get the profiler's current count.
llvm::Value * EmitObjCRetainNonBlock(llvm::Value *value, llvm::Type *returnType)
Retain the given object, with normal retain semantics.
llvm::Function * objc_moveWeak
void objc_moveWeak(id *dest, id *src);
Represents an ObjC class declaration.
QualType getReturnType() const
ObjCInterfaceDecl * getInterface() const
Gets the interface declaration for this object type, if the base type really is an interface...
static TryEmitResult tryEmitARCRetainScalarExpr(CodeGenFunction &CGF, const Expr *e)
bool isAtomic() const
isAtomic - Return true if the property is atomic.
llvm::Value * EmitARCRetainAutoreleasedReturnValue(llvm::Value *value)
Retain the given object which is the result of a function call.
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.
ObjCMethodDecl * getDictWithObjectsMethod() const
llvm::Value * EmitLoadOfScalar(Address Addr, bool Volatile, QualType Ty, SourceLocation Loc, AlignmentSource Source=AlignmentSource::Type, bool isNontemporal=false)
EmitLoadOfScalar - Load a scalar value from an address, taking care to appropriately convert from the...
ObjCPropertyImplDecl - Represents implementation declaration of a property in a class or category imp...
RValue EmitObjCMessageExpr(const ObjCMessageExpr *E, ReturnValueSlot Return=ReturnValueSlot())
static llvm::Value * emitARCValueOperation(CodeGenFunction &CGF, llvm::Value *value, llvm::Type *returnType, llvm::Function *&fn, llvm::Intrinsic::ID IntID, llvm::CallInst::TailCallKind tailKind=llvm::CallInst::TCK_None)
Perform an operation having the signature i8* (i8*) where a null input causes a no-op and returns nul...
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
ASTContext & getContext() const
llvm::Function * objc_unsafeClaimAutoreleasedReturnValue
id objc_unsafeClaimAutoreleasedReturnValue(id);
const TargetCodeGenInfo & getTargetCodeGenInfo()
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::Function * objc_retainAutoreleasedReturnValue
id objc_retainAutoreleasedReturnValue(id);
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...
AggValueSlot::Overlap_t getOverlapForReturnValue()
Determine whether a return value slot may overlap some other object.
CleanupKind getARCCleanupKind()
Retrieves the default cleanup kind for an ARC cleanup.
static AutoVarEmission invalid()
SourceLocation getEndLoc() const LLVM_READONLY
bool canAvoidCopyToHeap() const
llvm::Value * emitScalarConstant(const ConstantEmission &Constant, Expr *E)
llvm::Value * EmitARCStoreWeak(Address addr, llvm::Value *value, bool ignored)
i8* @objc_storeWeak(i8** addr, i8* value) Returns value.
static TypeEvaluationKind getEvaluationKind(QualType T)
getEvaluationKind - Return the TypeEvaluationKind of QualType T.
CGObjCRuntime & getObjCRuntime()
Return a reference to the configured Objective-C runtime.
ObjCMethodDecl * getBoxingMethod() const
static bool shouldExtendReceiverForInnerPointerMessage(const ObjCMessageExpr *message)
Decide whether to extend the lifetime of the receiver of a returns-inner-pointer message.
virtual llvm::FunctionCallee GetPropertyGetFunction()=0
Return the runtime function for getting properties.
virtual void GenerateDirectMethodPrologue(CodeGenFunction &CGF, llvm::Function *Fn, const ObjCMethodDecl *OMD, const ObjCContainerDecl *CD)=0
Generates prologue for direct Objective-C Methods.
Represent the declaration of a variable (in which case it is an lvalue) a function (in which case it ...
This represents one expression.
static AggValueSlot forLValue(const LValue &LV, CodeGenFunction &CGF, IsDestructed_t isDestructed, NeedsGCBarriers_t needsGC, IsAliased_t isAliased, Overlap_t mayOverlap, IsZeroed_t isZeroed=IsNotZeroed, IsSanitizerChecked_t isChecked=IsNotSanitizerChecked)
bool hasAtomicCopyHelper() const
void EmitARCMoveWeak(Address dst, Address src)
void @objc_moveWeak(i8** dest, i8** src) Disregards the current value in dest.
void EmitAutoVarInit(const AutoVarEmission &emission)
Address getAddress(CodeGenFunction &CGF) const
bool hasLocalStorage() const
Returns true if a variable with function scope is a non-static local variable.
Enters a new scope for capturing cleanups, all of which will be executed once the scope is exited...
virtual llvm::FunctionCallee GetCppAtomicObjectGetFunction()=0
API for atomic copying of qualified aggregates with non-trivial copy assignment (c++) in getter...
void GenerateObjCMethod(const ObjCMethodDecl *OMD)
Generate an Objective-C method.
void EmitCallArgs(CallArgList &Args, const T *CallArgTypeInfo, llvm::iterator_range< CallExpr::const_arg_iterator > ArgRange, AbstractCallee AC=AbstractCallee(), unsigned ParamsToSkip=0, EvaluationOrder Order=EvaluationOrder::Default)
EmitCallArgs - Emit call arguments for a function.
static void emitStructSetterCall(CodeGenFunction &CGF, ObjCMethodDecl *OMD, ObjCIvarDecl *ivar)
emitStructSetterCall - Call the runtime function to store the value from the first formal parameter i...
const T * castAs() const
Member-template castAs<specific type>.
llvm::BasicBlock * getBlock() const
static CGCallee forDirect(llvm::Constant *functionPtr, const CGCalleeInfo &abstractInfo=CGCalleeInfo())
bool isObjCRetainableType() const
virtual void EmitThrowStmt(CodeGen::CodeGenFunction &CGF, const ObjCAtThrowStmt &S, bool ClearInsertionPoint=true)=0
BlockExpr - Adaptor class for mixing a BlockDecl with expressions.
llvm::FunctionCallee objc_alloc
void objc_alloc(id);
llvm::PointerType * getType() const
Return the type of the pointer value.
ObjCLifetime getObjCLifetime() const
CharUnits getTypeAlignInChars(QualType T) const
Return the ABI-specified alignment of a (complete) type T, in characters.
StringRef getNameForSlot(unsigned argIndex) const
Retrieve the name at a given position in the selector.
bool isObjCClassType() const
ObjCDictionaryLiteral - AST node to represent objective-c dictionary literals; as in:"name" : NSUserN...
DeclContext * getDeclContext()
virtual llvm::FunctionCallee GetPropertySetFunction()=0
Return the runtime function for setting properties.
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)
virtual void EmitTryStmt(CodeGen::CodeGenFunction &CGF, const ObjCAtTryStmt &S)=0
llvm::Value * EmitARCAutorelease(llvm::Value *value)
Autorelease the given object.
llvm::LLVMContext & getLLVMContext()
SmallVector< llvm::OperandBundleDef, 1 > getBundlesForFunclet(llvm::Value *Callee)
const CGFunctionInfo & arrangeBuiltinFunctionCall(QualType resultType, const CallArgList &args)
llvm::IntegerType * Int32Ty
virtual llvm::Value * GetSelector(CodeGenFunction &CGF, Selector Sel)=0
Get a selector for the specified name and type values.
Expr * getElement(unsigned Index)
getElement - Return the Element at the specified index.
clang::ObjCRuntime ObjCRuntime
LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T)
An expression that sends a message to the given Objective-C object or class.
SourceLocation getEnd() const
UnaryOperator - This represents the unary-expression's (except sizeof and alignof), the postinc/postdec operators from postfix-expression, and various extensions.
bool isInstanceMethod() const
QualType getFunctionType(QualType ResultTy, ArrayRef< QualType > Args, const FunctionProtoType::ExtProtoInfo &EPI) const
Return a normal function type with a typed argument list.
ReceiverKind getReceiverKind() const
Determine the kind of receiver that this message is being sent to.
ConstantEmission tryEmitAsConstant(DeclRefExpr *refExpr)
Try to emit a reference to the given value without producing it as an l-value.
unsigned getNumArgs() const
const TargetInfo & getTarget() const
const Qualifiers & getQuals() const
Selector getSelector() const
const LangOptions & getLangOpts() const
ASTContext & getContext() const
ImplicitParamDecl * getSelfDecl() const
bool hasEmptyCollections() const
Are the empty collection symbols available?
GlobalDecl - represents a global declaration.
bool isConstQualified() const
Determine whether this type is const-qualified.
virtual void EmitSynchronizedStmt(CodeGen::CodeGenFunction &CGF, const ObjCAtSynchronizedStmt &S)=0
The l-value was considered opaque, so the alignment was determined from a type.
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="")
llvm::Function * objc_loadWeakRetained
id objc_loadWeakRetained(id*);
SelectorTable & Selectors
Assigning into this object requires the old value to be released and the new value to be retained...
QualType getCanonicalType() const
PseudoObjectExpr - An expression which accesses a pseudo-object l-value.
IdentifierInfo * getIdentifierInfoForSlot(unsigned argIndex) const
Retrieve the identifier at a given position in the selector.
llvm::FunctionCallee objc_autoreleasePoolPop
void objc_autoreleasePoolPop(void*);
bool isExpressibleAsConstantInitializer() const
ObjCMethodFamily getMethodFamily() const
Derive the conventional family of this method.
static llvm::Value * emitARCUnsafeUnretainedScalarExpr(CodeGenFunction &CGF, const Expr *e)
Encodes a location in the source.
void EnsureInsertPoint()
EnsureInsertPoint - Ensure that an insertion point is defined so that emitted IR has a place to go...
llvm::Value * EmitObjCArrayLiteral(const ObjCArrayLiteral *E)
llvm::Function * clang_arc_use
void clang.arc.use(...);
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...
virtual llvm::FunctionCallee GetSetStructFunction()=0
void EmitARCRelease(llvm::Value *value, ARCPreciseLifetime_t precise)
Release the given object.
LValue EmitDeclRefLValue(const DeclRefExpr *E)
std::pair< LValue, llvm::Value * > EmitARCStoreUnsafeUnretained(const BinaryOperator *e, bool ignored)
virtual ConstantAddress GenerateConstantString(const StringLiteral *)=0
Generate a constant string object.
LValue EmitCheckedLValue(const Expr *E, TypeCheckKind TCK)
Same as EmitLValue but additionally we generate checking code to guard against undefined behavior...
CastKind getCastKind() const
RValue EmitCall(const CGFunctionInfo &CallInfo, const CGCallee &Callee, ReturnValueSlot ReturnValue, const CallArgList &Args, llvm::CallBase **callOrInvoke, SourceLocation Loc)
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.
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c dictionary literal.
void EmitObjCForCollectionStmt(const ObjCForCollectionStmt &S)
llvm::Value * EmitARCUnsafeClaimAutoreleasedReturnValue(llvm::Value *value)
Claim a possibly-autoreleased return value at +0.
llvm::Value * getPointer(CodeGenFunction &CGF) const
DeclStmt - Adaptor class for mixing declarations with statements and expressions. ...
Address CreateConstArrayGEP(Address Addr, uint64_t Index, const llvm::Twine &Name="")
Given addr = [n x T]* ...
Stmt * getBody() const override
Retrieve the body of this method, if it has one.
virtual llvm::FunctionCallee EnumerationMutationFunction()=0
EnumerationMutationFunction - Return the function that's called by the compiler when a mutation is de...
static TryEmitResult tryEmitARCRetainLoadOfScalar(CodeGenFunction &CGF, LValue lvalue, QualType type)
const CGFunctionInfo & arrangeObjCMethodDeclaration(const ObjCMethodDecl *MD)
Objective-C methods are C functions with some implicit parameters.
void EmitStmt(const Stmt *S, ArrayRef< const Attr *> Attrs=None)
EmitStmt - Emit the code for the statement.
virtual llvm::Value * EmitNSAutoreleasePoolClassRef(CodeGenFunction &CGF)
llvm::Function * objc_destroyWeak
void objc_destroyWeak(id*);
ObjCEntrypoints & getObjCEntrypoints() const
llvm::Function * objc_storeWeak
id objc_storeWeak(id*, id);
llvm::FunctionCallee objc_retainRuntimeFunction
id objc_retain(id); Note this is the runtime method not the intrinsic.
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...
bool isObjCObjectPointerType() 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.
Represents one property declaration in an Objective-C interface.
void SetLLVMFunctionAttributesForDefinition(const Decl *D, llvm::Function *F)
Set the LLVM function attributes which only apply to a function definition.
ImplicitCastExpr - Allows us to explicitly represent implicit type conversions, which have no direct ...
DestructionKind isDestructedType() const
Returns a nonzero value if objects of this type require non-trivial work to clean up after...
static Destroyer emitARCIntrinsicUse
All available information about a concrete callee.
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...
llvm::Value * EmitObjCAlloc(llvm::Value *value, llvm::Type *returnType)
Allocate the given objc object.
const ObjCMethodDecl * getMethodDecl() const
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.
llvm::Value * EmitARCRetain(QualType type, llvm::Value *value)
Produce the code to do a retain.
void emitARCMoveAssignWeak(QualType Ty, Address DstAddr, Address SrcAddr)
bool hasSameUnqualifiedType(QualType T1, QualType T2) const
Determine whether the given types are equivalent after cvr-qualifiers have been removed.
static Destroyer destroyARCStrongImprecise
void FinishFunction(SourceLocation EndLoc=SourceLocation())
FinishFunction - Complete IR generation of the current function.
Expr * Value
The value of the dictionary element.
std::pair< CharUnits, CharUnits > getTypeInfoInChars(const Type *T) const
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()
llvm::Value * getScalarVal() const
getScalarVal() - Return the Value* of this scalar value.
Expr * getResultExpr()
Return the result-bearing expression, or null if there is none.
llvm::CallBase * EmitCallOrInvoke(llvm::FunctionCallee Callee, ArrayRef< llvm::Value *> Args, const Twine &Name="")
Emits a call or invoke instruction to the given function, depending on the current state of the EH st...
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.
const ObjCInterfaceDecl * getClassInterface() const
Dataflow Directional Tag Classes.
llvm::Value * EmitObjCAllocWithZone(llvm::Value *value, llvm::Type *returnType)
Allocate the given objc object.
void GenerateObjCGetter(ObjCImplementationDecl *IMP, const ObjCPropertyImplDecl *PID)
GenerateObjCGetter - Synthesize an Objective-C property getter function.
unsigned char PointerAlignInBytes
void EmitObjCAutoreleasePoolPop(llvm::Value *Ptr)
Produce the code to do a primitive release.
The basic abstraction for the target Objective-C runtime.
llvm::Value * EmitARCLoadWeakRetained(Address addr)
i8* @objc_loadWeakRetained(i8** addr)
static ReturnStmt * Create(const ASTContext &Ctx, SourceLocation RL, Expr *E, const VarDecl *NRVOCandidate)
Create a return statement.
QualType getSuperType() const
Retrieve the type referred to by 'super'.
llvm::LoadInst * CreateAlignedLoad(llvm::Value *Addr, CharUnits Align, const llvm::Twine &Name="")
void EmitARCIntrinsicUse(ArrayRef< llvm::Value *> values)
Given a number of pointers, inform the optimizer that they're being intrinsically used up until this ...
llvm::Constant * getPointer() const
llvm::LoadInst * CreateLoad(Address Addr, const llvm::Twine &Name="")
bool isKeywordSelector() const
U cast(CodeGen::Address addr)
virtual llvm::FunctionCallee GetOptimizedPropertySetFunction(bool atomic, bool copy)=0
Return the runtime function for optimized setting properties.
const ObjCObjectType * getObjectType() const
Gets the type pointed to by this ObjC pointer.
QualType TypeOfSelfObject()
TypeOfSelfObject - Return type of object that this self represents.
Checking the destination of a store. Must be suitably sized and aligned.
llvm::FunctionCallee CreateRuntimeFunction(llvm::FunctionType *Ty, StringRef Name, llvm::AttributeList ExtraAttrs=llvm::AttributeList(), bool Local=false, bool AssumeConvergent=false)
Create or return a runtime function declaration with the specified type and name. ...
llvm::Function * getIntrinsic(unsigned IID, ArrayRef< llvm::Type *> Tys=None)
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
semantics_iterator semantics_begin()
llvm::Constant * GenerateObjCAtomicGetterCopyHelperFunction(const ObjCPropertyImplDecl *PID)
llvm::Module & getModule() const
static bool hasTrivialSetExpr(const ObjCPropertyImplDecl *PID)
void EmitObjCAtThrowStmt(const ObjCAtThrowStmt &S)
LValue MakeAddrLValue(Address Addr, QualType T, AlignmentSource Source=AlignmentSource::Type)
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. ...
QualType getClassReceiver() const
Returns the type of a class message send, or NULL if the message is not a class message.
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...
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
static llvm::Value * emitARCOperationAfterCall(CodeGenFunction &CGF, llvm::Value *value, ValueTransform doAfterCall, ValueTransform doFallback)
Insert code immediately after a call.
llvm::FunctionCallee objc_autoreleasePoolPopInvoke
void objc_autoreleasePoolPop(void*); Note this method is used when we are using exception handling ...
unsigned getNumElements() const
getNumElements - Return number of elements of objective-c array literal.
Represents Objective-C's collection statement.
CodeGenTypes & getTypes() const
void EmitStoreOfComplex(ComplexPairTy V, LValue dest, bool isInit)
EmitStoreOfComplex - Store a complex number into the specified l-value.
bool hasNonTrivialObjCLifetime() const
Selector getSelector(unsigned NumArgs, IdentifierInfo **IIV)
Can create any sort of selector.
llvm::Type * getElementType() const
Return the type of the values stored in this address.
This class organizes the cross-module state that is used while lowering AST types to LLVM types...
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.
llvm::PointerType * Int8PtrTy
const TargetInfo & Target
bool isDelegateInitCall() const
isDelegateInitCall - Answers whether this message send has been tagged as a "delegate init call"...
LValue EmitLValueForIvar(QualType ObjectTy, llvm::Value *Base, const ObjCIvarDecl *Ivar, unsigned CVRQualifiers)
param_const_iterator param_begin() const
llvm::Value * EmitIvarOffset(const ObjCInterfaceDecl *Interface, const ObjCIvarDecl *Ivar)
void SetInternalFunctionAttributes(GlobalDecl GD, llvm::Function *F, const CGFunctionInfo &FI)
Set the attributes on the LLVM function for the given decl and function info.
llvm::Value * EmitARCRetainAutorelease(QualType type, llvm::Value *value)
Do a fused retain/autorelease of the given object.
llvm::Function * objc_autoreleaseReturnValue
id objc_autoreleaseReturnValue(id);
QualType getConstantArrayType(QualType EltTy, const llvm::APInt &ArySize, const Expr *SizeExpr, ArrayType::ArraySizeModifier ASM, unsigned IndexTypeQuals) const
Return the unique reference to the type for a constant array of the specified element type...
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)
llvm::Function * objc_autorelease
id objc_autorelease(id);
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?
uint64_t getTypeSize(QualType T) const
Return the size of the specified (complete) type T, in bits.
ObjCIvarRefExpr - A reference to an ObjC instance variable.
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.
CanQualType getCanonicalType(QualType T) const
Return the canonical (structural) type corresponding to the specified potentially non-canonical type ...
virtual llvm::Value * GetClass(CodeGenFunction &CGF, const ObjCInterfaceDecl *OID)=0
GetClass - Return a reference to the class for the given interface decl.
llvm::FunctionCallee objc_allocWithZone
void objc_allocWithZone(id);
Reading or writing from this object requires a barrier call.
void EmitLexicalBlockStart(CGBuilderTy &Builder, SourceLocation Loc)
Emit metadata to indicate the beginning of a new lexical block and push the block onto the stack...
int64_t toBits(CharUnits CharSize) const
Convert a size in characters to a size in bits.
TranslationUnitDecl * getTranslationUnitDecl() const
llvm::iterator_range< arg_iterator > arguments()
A non-RAII class containing all the information about a bound opaque value.
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)
llvm::BasicBlock * getInvokeDest()
void EmitReturnStmt(const ReturnStmt &S)
EmitReturnStmt - Note that due to GCC extensions, this can have an operand if the function returns vo...
llvm::Function * objc_storeStrong
void objc_storeStrong(id*, id);
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.
QualType getPointerType(QualType T) const
Return the uniqued reference to the type for a pointer to the specified type.
ImplicitParamDecl * getCmdDecl() const
llvm::Function * objc_loadWeak
id objc_loadWeak(id*);
Represents Objective-C's @try ... @catch ... @finally statement.
SourceRange getSourceRange() const LLVM_READONLY
SourceLocation tokens are not useful in isolation - they are low level value objects created/interpre...
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)
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
SourceLocation getBeginLoc() const LLVM_READONLY
void StartObjCMethod(const ObjCMethodDecl *MD, const ObjCContainerDecl *CD)
StartObjCMethod - Begin emission of an ObjCMethod.
llvm::Constant * tryEmitAbstract(const Expr *E, QualType T)
Try to emit the result of the given expression as an abstract constant.
bool hasARCUnsafeClaimAutoreleasedReturnValue() const
Is objc_unsafeClaimAutoreleasedReturnValue available?
static Decl::Kind getKind(const Decl *D)
QualType getObjCFastEnumerationStateType()
Retrieve the record type that describes the state of an Objective-C fast enumeration loop (for...
void EmitObjCAutoreleasePoolCleanup(llvm::Value *Ptr)
bool hasNativeARC() const
Does this runtime natively provide the ARC entrypoints?
llvm::Function * objc_retain
id objc_retain(id);
void EmitAggregateCopy(LValue Dest, LValue Src, QualType EltTy, AggValueSlot::Overlap_t MayOverlap, bool isVolatile=false)
EmitAggregateCopy - Emit an aggregate copy.
A reference to a declared variable, function, enum, etc.
static RValue get(llvm::Value *V)
ObjCPropertyDecl * getPropertyDecl() const
llvm::Function * objc_autoreleasePoolPush
void *objc_autoreleasePoolPush(void);
static const Expr * findWeakLValue(const Expr *E)
Given an expression of ObjC pointer type, check whether it was immediately loaded from an ARC __weak ...
CharUnits getTypeSizeInChars(QualType T) const
Return the size of the specified (complete) type T, in characters.
static void emitAutoreleasedReturnValueMarker(CodeGenFunction &CGF)
Address EmitCompoundStmtWithoutScope(const CompoundStmt &S, bool GetLast=false, AggValueSlot AVS=AggValueSlot::ignored())
llvm::Value * LoadObjCSelf()
LoadObjCSelf - Load the value of self.
An l-value expression is a reference to an object with independent storage.
A trivial tuple used to represent a source range.
void EmitObjCAtTryStmt(const ObjCAtTryStmt &S)
LValue - This represents an lvalue references.
An abstract representation of regular/ObjC call/message targets.
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...
CodeGen::RValue GeneratePossiblySpecializedMessageSend(CodeGenFunction &CGF, ReturnValueSlot Return, QualType ResultType, Selector Sel, llvm::Value *Receiver, const CallArgList &Args, const ObjCInterfaceDecl *OID, const ObjCMethodDecl *Method, bool isClassMessage)
Generate an Objective-C message send operation.
llvm::Value * EmitObjCConsumeObject(QualType T, llvm::Value *Ptr)
Produce the code for a CK_ARCConsumeObject.
llvm::PointerIntPair< llvm::Value *, 1, bool > TryEmitResult
const LangOptions & getLangOpts() const
llvm::CallInst * EmitNounwindRuntimeCall(llvm::FunctionCallee callee, const Twine &name="")
The receiver is a superclass.
virtual llvm::FunctionCallee GetCppAtomicObjectSetFunction()=0
API for atomic copying of qualified aggregates with non-trivial copy assignment (c++) in setter...
void EmitObjCAutoreleasePoolStmt(const ObjCAutoreleasePoolStmt &S)
llvm::CallBase * EmitRuntimeCallOrInvoke(llvm::FunctionCallee callee, ArrayRef< llvm::Value *> args, const Twine &name="")
Emits a call or invoke instruction to the given runtime function.
SourceLocation getBegin() const
CallArgList - Type for representing both the value and type of arguments in a call.
Represents Objective-C's @autoreleasepool Statement.
SourceLocation getBodyRBrace() const
getBodyRBrace - Gets the right brace of the body, if a body exists.
llvm::Function * objc_retainBlock
id objc_retainBlock(id);
SourceLocation getLocation() const
void emitARCCopyAssignWeak(QualType Ty, Address DstAddr, Address SrcAddr)
void EmitNullInitialization(Address DestPtr, QualType Ty)
EmitNullInitialization - Generate code to set a value of the given type to null, If the type contains...
llvm::Value * EmitBuiltinAvailable(ArrayRef< llvm::Value *> Args)
ArrayRef< ParmVarDecl * > parameters() const
Expr * IgnoreParens() LLVM_READONLY
Skip past any parentheses which might surround this expression until reaching a fixed point...
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...
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, Stmt *PreInit, Expr *PostUpdate)
Creates clause with a list of variables VL and a linear step Step.
llvm::Value * EmitObjCSelectorExpr(const ObjCSelectorExpr *E)
Emit a selector.
CanQualType getSizeType() const
Return the unique type for "size_t" (C99 7.17), defined in <stddef.h>.
void Destroyer(CodeGenFunction &CGF, Address addr, QualType ty)
Qualifiers::ObjCLifetime getObjCLifetime() const
Returns lifetime attribute of this type.
static void emitCXXDestructMethod(CodeGenFunction &CGF, ObjCImplementationDecl *impl)
unsigned char PointerSizeInBytes
llvm::Value * EmitObjCProtocolExpr(const ObjCProtocolExpr *E)
llvm::FunctionCallee IsOSVersionAtLeastFn
llvm::FunctionType * GetFunctionType(const CGFunctionInfo &Info)
GetFunctionType - Get the LLVM function type for.
QualType getPointeeType() const
Gets the type pointed to by this ObjC pointer.
const llvm::Triple & getTriple() const