24 #include "llvm/IR/CallSite.h"
26 using namespace clang;
27 using namespace CodeGen;
60 assert(Index < RL->getFieldCount() &&
"Ivar is not inside record layout!");
90 unsigned CVRQualifiers,
96 V = CGF.
Builder.CreateInBoundsGEP(V, Offset,
"add.ptr");
99 V = CGF.
Builder.CreateBitCast(V, llvm::PointerType::getUnqual(LTy));
125 llvm::RoundUpToAlignment(BitOffset + BitFieldSize, AlignmentBits));
139 V = CGF.
Builder.CreateBitCast(V,
148 struct CatchHandler {
151 llvm::BasicBlock *Block;
156 CallObjCEndCatch(
bool MightThrow,
llvm::Value *Fn) :
157 MightThrow(MightThrow), Fn(Fn) {}
163 CGF.
Builder.CreateCall(Fn)->setDoesNotThrow();
175 llvm::Constant *beginCatchFn,
176 llvm::Constant *endCatchFn,
177 llvm::Constant *exceptionRethrowFn) {
185 FinallyInfo.
enter(CGF, Finally->getFinallyBody(),
186 beginCatchFn, endCatchFn, exceptionRethrowFn);
196 Handlers.push_back(CatchHandler());
197 CatchHandler &Handler = Handlers.back();
198 Handler.Variable = CatchDecl;
204 Handler.TypeInfo =
nullptr;
213 for (
unsigned I = 0, E = Handlers.size(); I != E; ++I)
214 Catch->
setHandler(I, Handlers[I].TypeInfo, Handlers[I].Block);
225 CGBuilderTy::InsertPoint SavedIP = CGF.
Builder.saveAndClearIP();
228 for (
unsigned I = 0, E = Handlers.size(); I != E; ++I) {
229 CatchHandler &Handler = Handlers[I];
237 Exn = CGF.
Builder.CreateCall(beginCatchFn, RawExn,
"exn.adjusted");
238 cast<llvm::CallInst>(Exn)->setDoesNotThrow();
245 bool EndCatchMightThrow = (Handler.Variable ==
nullptr);
253 if (
const VarDecl *CatchParam = Handler.Variable) {
254 llvm::Type *CatchType = CGF.
ConvertType(CatchParam->getType());
261 switch (CatchParam->getType().getQualifiers().getObjCLifetime()) {
269 CGF.
Builder.CreateStore(CastExn, CatchParamAddr);
283 cleanups.ForceCleanup();
289 CGF.
Builder.restoreIP(SavedIP);
293 FinallyInfo.
exit(CGF);
304 : SyncExitFn(SyncExitFn), SyncArg(SyncArg) {}
307 CGF.
Builder.CreateCall(SyncExitFn, SyncArg)->setDoesNotThrow();
314 llvm::Function *syncEnterFn,
315 llvm::Function *syncExitFn) {
331 CGF.
Builder.CreateCall(syncEnterFn, lock)->setDoesNotThrow();
356 llvm::PointerType *signatureType =
380 llvm::PointerType *signatureType =
const ObjCAtFinallyStmt * getFinallyStmt() const
Retrieve the @finally statement, if any.
CodeGenTypes & getTypes()
bool isBitField() const
Determines whether this field is a bitfield.
void EmitAutoVarDecl(const VarDecl &D)
const LangOptions & getLangOpts() const
llvm::Value * EmitARCRetainNonBlock(llvm::Value *value)
const ASTRecordLayout & getASTObjCImplementationLayout(const ObjCImplementationDecl *D) const
Get or compute information about the layout of the specified Objective-C implementation.
uint64_t ComputeIvarBaseOffset(CodeGen::CodeGenModule &CGM, const ObjCInterfaceDecl *OID, const ObjCIvarDecl *Ivar)
Defines the Objective-C statement AST node classes.
llvm::Type * ConvertTypeForMem(QualType T)
const ObjCInterfaceDecl * getContainingInterface() const
Return the class interface that this ivar is logically contained in; this is either the interface whe...
void EmitARCInitWeak(llvm::Value *value, llvm::Value *addr)
const VarDecl * getCatchParamDecl() const
class EHCatchScope * pushCatch(unsigned NumHandlers)
Represents Objective-C's @catch statement.
const CompoundStmt * getSynchBody() const
A class controlling the emission of a finally block.
MessageSendInfo getMessageSendInfo(const ObjCMethodDecl *method, QualType resultType, CallArgList &callArgs)
const Qualifiers & getQuals() const
static uint64_t LookupFieldBitOffset(CodeGen::CodeGenModule &CGM, const ObjCInterfaceDecl *OID, const ObjCImplementationDecl *ID, const ObjCIvarDecl *Ivar)
llvm::PointerType * VoidPtrTy
void addCVRQualifiers(unsigned mask)
CodeGen::CodeGenModule & CGM
const CGFunctionInfo & arrangeObjCMessageSendSignature(const ObjCMethodDecl *MD, QualType receiverType)
bool declaresSameEntity(const Decl *D1, const Decl *D2)
Determine whether two declarations declare the same entity.
const Stmt * getCatchBody() const
void EmitStmt(const Stmt *S)
llvm::BasicBlock * createBasicBlock(const Twine &name="", llvm::Function *parent=nullptr, llvm::BasicBlock *before=nullptr)
createBasicBlock - Create an LLVM basic block.
uint64_t getFieldOffset(unsigned FieldNo) const
llvm::Value * EmitARCRetainScalarExpr(const Expr *expr)
const ObjCAtCatchStmt * getCatchStmt(unsigned I) const
Retrieve a @catch statement.
Represents an ObjC class declaration.
llvm::CallSite EmitRuntimeCallOrInvoke(llvm::Value *callee, ArrayRef< llvm::Value * > args, const Twine &name="")
Emits a call or invoke instruction to the given runtime function.
static CGBitFieldInfo MakeInfo(class CodeGenTypes &Types, const FieldDecl *FD, uint64_t Offset, uint64_t Size, uint64_t StorageSize, CharUnits StorageOffset)
Given a bit-field decl, build an appropriate helper object for accessing that field (which is expecte...
const TargetInfo & getTarget() const
ID
Defines the set of possible language-specific address spaces.
unsigned getCharAlign() const
void enter(CodeGenFunction &CGF, const Stmt *Finally, llvm::Constant *beginCatchFn, llvm::Constant *endCatchFn, llvm::Constant *rethrowFn)
Enters a new scope for capturing cleanups, all of which will be executed once the scope is exited...
llvm::Value * GetAddrOfLocalVar(const VarDecl *VD)
GetAddrOfLocalVar - Return the address of a local variable.
ASTContext & getContext() const
llvm::BasicBlock * getBlock() const
Represents Objective-C's @synchronized statement.
static CharUnits fromQuantity(QuantityType Quantity)
fromQuantity - Construct a CharUnits quantity from a raw integer type.
llvm::Value * getExceptionFromSlot()
void EmitAtSynchronizedStmt(CodeGenFunction &CGF, const ObjCAtSynchronizedStmt &S, llvm::Function *syncEnterFn, llvm::Function *syncExitFn)
llvm::LLVMContext & getLLVMContext()
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T)
unsigned ComputeBitfieldBitOffset(CodeGen::CodeGenModule &CGM, const ObjCInterfaceDecl *ID, const ObjCIvarDecl *Ivar)
There is no lifetime qualification on this type.
FunctionType::ExtInfo getExtInfo() const
ASTContext & getContext() const
RequiredArgs getRequiredArgs() const
QualType withCVRQualifiers(unsigned CVR) const
unsigned getBitWidthValue(const ASTContext &Ctx) const
SmallVector< llvm::Value *, 8 > ObjCEHValueStack
const ObjCInterfaceDecl * getClassInterface() const
void exit(CodeGenFunction &CGF)
JumpDest getJumpDestInCurrentScope(llvm::BasicBlock *Target)
Assigning into this object requires a lifetime extension.
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
ObjCIvarDecl * getNextIvar()
static LValue MakeBitfield(llvm::Value *Addr, const CGBitFieldInfo &Info, QualType type, CharUnits Alignment)
Create a new object to represent a bit-field access.
const Expr * getSynchExpr() const
llvm::PointerType * Int8PtrTy
Represents Objective-C's @finally statement.
uint64_t getCharWidth() const
Return the size of the character type, in bits.
ObjCImplementationDecl * getImplementation() const
void EmitBlock(llvm::BasicBlock *BB, bool IsFinished=false)
unsigned getNumCatchStmts() const
Retrieve the number of @catch statements in this try-catch-finally block.
Reading or writing from this object requires a barrier call.
llvm::Type * ConvertType(QualType T)
Represents Objective-C's @try ... @catch ... @finally statement.
const Stmt * getTryBody() const
Retrieve the @try body.
void EmitTryCatchStmt(CodeGenFunction &CGF, const ObjCAtTryStmt &S, llvm::Constant *beginCatchFn, llvm::Constant *endCatchFn, llvm::Constant *exceptionRethrowFn)
LValue EmitValueForIvarAtOffset(CodeGen::CodeGenFunction &CGF, const ObjCInterfaceDecl *OID, llvm::Value *BaseValue, const ObjCIvarDecl *Ivar, unsigned CVRQualifiers, llvm::Value *Offset)
const CGFunctionInfo & arrangeFreeFunctionCall(const CallArgList &Args, const FunctionType *Ty, bool ChainCall)
void EmitBranchThroughCleanup(JumpDest Dest)
int64_t toBits(CharUnits CharSize) const
Convert a size in characters to a size in bits.
ObjCIvarDecl * all_declared_ivar_begin()
llvm::Value * EmitObjCConsumeObject(QualType T, llvm::Value *Ptr)
const ASTRecordLayout & getASTObjCInterfaceLayout(const ObjCInterfaceDecl *D) const
Get or compute information about the layout of the specified Objective-C interface.
virtual llvm::Constant * GetEHType(QualType T)=0
void setHandler(unsigned I, llvm::Constant *Type, llvm::BasicBlock *Block)
Structure with information about how a bitfield should be accessed.
llvm::FunctionType * GetFunctionType(const CGFunctionInfo &Info)
GetFunctionType - Get the LLVM function type for.