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");
124 llvm::alignTo(BitOffset + BitFieldSize, AlignmentBits));
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) {
266 cleanups.ForceCleanup();
272 CGF.
Builder.restoreIP(SavedIP);
276 FinallyInfo.
exit(CGF);
303 llvm_unreachable(
"invalid ownership qualifier");
311 : SyncExitFn(SyncExitFn), SyncArg(SyncArg) {}
314 CGF.
Builder.CreateCall(SyncExitFn, SyncArg)->setDoesNotThrow();
321 llvm::Function *syncEnterFn,
322 llvm::Function *syncExitFn) {
338 CGF.
Builder.CreateCall(syncEnterFn, lock)->setDoesNotThrow();
363 llvm::PointerType *signatureType =
377 llvm::PointerType *signatureType =
const ObjCAtFinallyStmt * getFinallyStmt() const
Retrieve the @finally statement, if any.
A (possibly-)qualified type.
CodeGenTypes & getTypes()
bool isBitField() const
Determines whether this field is a bitfield.
static LValue MakeBitfield(Address Addr, const CGBitFieldInfo &Info, QualType type, AlignmentSource alignSource)
Create a new object to represent a bit-field access.
void EmitAutoVarDecl(const VarDecl &D)
EmitAutoVarDecl - Emit an auto variable declaration.
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
const LangOptions & getLangOpts() const
llvm::Value * EmitARCRetainNonBlock(llvm::Value *value)
Retain the given object, with normal retain semantics.
const ASTRecordLayout & getASTObjCImplementationLayout(const ObjCImplementationDecl *D) const
Get or compute information about the layout of the specified Objective-C implementation.
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...
uint64_t ComputeIvarBaseOffset(CodeGen::CodeGenModule &CGM, const ObjCInterfaceDecl *OID, const ObjCIvarDecl *Ivar)
Compute an offset to the given ivar, suitable for passing to EmitValueForIvarAtOffset.
ObjCLifetime getObjCLifetime() const
ObjCMethodDecl - Represents an instance or class method declaration.
Defines the Objective-C statement AST node classes.
llvm::Type * ConvertTypeForMem(QualType T)
ConvertTypeForMem - Convert type T into a llvm::Type.
A scope which attempts to handle some, possibly all, types of exceptions.
A jump destination is an abstract label, branching to which may require a jump out through normal cle...
void popCatchScope()
popCatchScope - Pops the catch scope at the top of the EHScope stack, emitting any required code (oth...
const ObjCInterfaceDecl * getContainingInterface() const
Return the class interface that this ivar is logically contained in; this is either the interface whe...
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
void EmitInitOfCatchParam(CodeGenFunction &CGF, llvm::Value *exn, const VarDecl *paramDecl)
const VarDecl * getCatchParamDecl() const
class EHCatchScope * pushCatch(unsigned NumHandlers)
Push a set of catch handlers on the stack.
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)
Compute the pointer-to-function type to which a message send should be casted in order to correctly c...
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.
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)
Arrange the argument and result information for the function type through which to perform a send to ...
const CGFunctionInfo & arrangeCall(const CGFunctionInfo &declFI, const CallArgList &args)
Given a function info for a declaration, return the function info for a call with the given arguments...
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)
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.
uint64_t getFieldOffset(unsigned FieldNo) const
getFieldOffset - Get the offset of the given field index, in bits.
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.
const ObjCAtCatchStmt * getCatchStmt(unsigned I) const
Retrieve a @catch statement.
Represents an ObjC class declaration.
detail::InMemoryDirectory::const_iterator I
This object can be modified without requiring retains or releases.
const CGFunctionInfo & arrangeUnprototypedObjCMessageSend(QualType returnType, const CallArgList &args)
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
unsigned getCharAlign() const
ASTRecordLayout - This class contains layout information for one RecordDecl, which is a struct/union/...
Expr - This represents one expression.
void enter(CodeGenFunction &CGF, const Stmt *Finally, llvm::Constant *beginCatchFn, llvm::Constant *endCatchFn, llvm::Constant *rethrowFn)
Enters a finally block for an implementation using zero-cost exceptions.
Enters a new scope for capturing cleanups, all of which will be executed once the scope is exited...
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()
Returns the contents of the function's exception object and selector slots.
void EmitAtSynchronizedStmt(CodeGenFunction &CGF, const ObjCAtSynchronizedStmt &S, llvm::Function *syncEnterFn, llvm::Function *syncExitFn)
Emits an @synchronize() statement, using the syncEnterFn and syncExitFn arguments as the functions ca...
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)
The l-value was considered opaque, so the alignment was determined from a type.
There is no lifetime qualification on this type.
Address CreateBitCast(Address Addr, llvm::Type *Ty, const llvm::Twine &Name="")
Assigning into this object requires the old value to be released and the new value to be retained...
ASTContext & getContext() const
QualType withCVRQualifiers(unsigned CVR) const
unsigned getBitWidthValue(const ASTContext &Ctx) const
SmallVector< llvm::Value *, 8 > ObjCEHValueStack
ObjCEHValueStack - Stack of Objective-C exception values, used for rethrows.
const ObjCInterfaceDecl * getClassInterface() const
void exit(CodeGenFunction &CGF)
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...
Assigning into this object requires a lifetime extension.
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
EmitScalarExpr - Emit the computation of the specified expression of LLVM scalar type, returning the result.
ObjCIvarDecl * getNextIvar()
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 Expr * getSynchExpr() const
unsigned StorageSize
The storage size in bits which should be used when accessing this bitfield.
detail::InMemoryDirectory::const_iterator E
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
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)
EmitBlock - Emit the given block.
void EmitARCInitWeak(Address addr, llvm::Value *value)
i8* @objc_initWeak(i8** addr, i8* value) Returns value.
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)
ObjCIvarDecl - Represents an ObjC instance variable.
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)
Emits a try / catch statement.
LValue EmitValueForIvarAtOffset(CodeGen::CodeGenFunction &CGF, const ObjCInterfaceDecl *OID, llvm::Value *BaseValue, const ObjCIvarDecl *Ivar, unsigned CVRQualifiers, llvm::Value *Offset)
void EmitBranchThroughCleanup(JumpDest Dest)
EmitBranchThroughCleanup - Emit a branch from the current insert block through the normal cleanup han...
int64_t toBits(CharUnits CharSize) const
Convert a size in characters to a size in bits.
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.
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
Get the type constant to catch for the given ObjC pointer type.
CallArgList - Type for representing both the value and type of arguments in a call.
void setHandler(unsigned I, llvm::Constant *Type, llvm::BasicBlock *Block)
Structure with information about how a bitfield should be accessed.
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
llvm::FunctionType * GetFunctionType(const CGFunctionInfo &Info)
GetFunctionType - Get the LLVM function type for.