24 #include "llvm/IR/CallSite.h" 26 using namespace clang;
27 using namespace CodeGen;
56 unsigned CVRQualifiers,
66 V = CGF.
Builder.CreateInBoundsGEP(V, Offset,
"add.ptr");
88 uint64_t FieldBitOffset =
94 llvm::alignTo(BitOffset + BitFieldSize, AlignmentBits));
118 struct CatchHandler {
121 llvm::BasicBlock *Block;
127 : MightThrow(MightThrow), Fn(Fn) {}
143 llvm::Constant *beginCatchFn,
144 llvm::Constant *endCatchFn,
145 llvm::Constant *exceptionRethrowFn) {
153 FinallyInfo.
enter(CGF, Finally->getFinallyBody(),
154 beginCatchFn, endCatchFn, exceptionRethrowFn);
164 Handlers.push_back(CatchHandler());
165 CatchHandler &Handler = Handlers.back();
166 Handler.Variable = CatchDecl;
172 Handler.TypeInfo =
nullptr;
181 for (
unsigned I = 0, E = Handlers.size(); I != E; ++I)
182 Catch->
setHandler(I, Handlers[I].TypeInfo, Handlers[I].Block);
193 CGBuilderTy::InsertPoint SavedIP = CGF.
Builder.saveAndClearIP();
196 for (
unsigned I = 0, E = Handlers.size(); I != E; ++I) {
197 CatchHandler &Handler = Handlers[I];
211 bool EndCatchMightThrow = (Handler.Variable ==
nullptr);
219 if (
const VarDecl *CatchParam = Handler.Variable) {
232 cleanups.ForceCleanup();
238 CGF.
Builder.restoreIP(SavedIP);
242 FinallyInfo.
exit(CGF);
269 llvm_unreachable(
"invalid ownership qualifier");
277 : SyncExitFn(SyncExitFn), SyncArg(SyncArg) {}
280 CGF.
Builder.CreateCall(SyncExitFn, SyncArg)->setDoesNotThrow();
287 llvm::Function *syncEnterFn,
288 llvm::Function *syncExitFn) {
304 CGF.
Builder.CreateCall(syncEnterFn, lock)->setDoesNotThrow();
329 llvm::PointerType *signatureType =
343 llvm::PointerType *signatureType =
const Type * getTypeForDecl() const
A (possibly-)qualified type.
CodeGenTypes & getTypes()
Stmt - This represents one statement.
const ObjCAtFinallyStmt * getFinallyStmt() const
Retrieve the @finally statement, if any.
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 ...
llvm::Value * EmitARCRetainNonBlock(llvm::Value *value)
Retain the given object, with normal retain semantics.
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.
unsigned getCharAlign() 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...
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)
uint64_t lookupFieldBitOffset(const ObjCInterfaceDecl *OID, const ObjCImplementationDecl *ID, const ObjCIvarDecl *Ivar) const
Get the offset of an ObjCIvarDecl in bits.
class EHCatchScope * pushCatch(unsigned NumHandlers)
Push a set of catch handlers on the stack.
Represents Objective-C's @catch statement.
A class controlling the emission of a finally block.
bool isBitField() const
Determines whether this field is a bitfield.
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.
llvm::PointerType * VoidPtrTy
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...
unsigned getBitWidthValue(const ASTContext &Ctx) const
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.
Represents an ObjC class declaration.
This object can be modified without requiring retains or releases.
const CGFunctionInfo & arrangeUnprototypedObjCMessageSend(QualType returnType, const CallArgList &args)
const ObjCAtCatchStmt * getCatchStmt(unsigned I) const
Retrieve a @catch statement.
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...
ASTContext & getContext() const
llvm::CallInst * EmitNounwindRuntimeCall(llvm::Value *callee, const Twine &name="")
QualType getUsageType(QualType objectType) const
Retrieve the type of this instance variable when viewed as a member of a specific object type...
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...
llvm::BasicBlock * getBlock() const
ObjCLifetime getObjCLifetime() const
const CompoundStmt * getSynchBody() 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.
static LValue MakeBitfield(Address Addr, const CGBitFieldInfo &Info, QualType type, LValueBaseInfo BaseInfo, TBAAAccessInfo TBAAInfo)
Create a new object to represent a bit-field access.
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()
const Stmt * getTryBody() const
Retrieve the @try body.
LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T)
unsigned ComputeBitfieldBitOffset(CodeGen::CodeGenModule &CGM, const ObjCInterfaceDecl *ID, const ObjCIvarDecl *Ivar)
const TargetInfo & getTarget() const
ASTContext & getContext() const
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...
const Stmt * getCatchBody() const
SmallVector< llvm::Value *, 8 > ObjCEHValueStack
ObjCEHValueStack - Stack of Objective-C exception values, used for rethrows.
llvm::CallSite EmitRuntimeCallOrInvoke(llvm::Value *callee, ArrayRef< llvm::Value *> args, const Twine &name="")
Emits a call or invoke instruction to the given runtime function.
void EmitStmt(const Stmt *S, ArrayRef< const Attr *> Attrs=None)
EmitStmt - Emit the code for the statement.
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.
ObjCImplementationDecl * getImplementation() const
llvm::Value * EmitScalarExpr(const Expr *E, bool IgnoreResultAssign=false)
EmitScalarExpr - Emit the computation of the specified expression of LLVM scalar type, returning the result.
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.
unsigned StorageSize
The storage size in bits which should be used when accessing this bitfield.
const Expr * getSynchExpr() const
llvm::StoreInst * CreateStore(llvm::Value *Val, Address Addr, bool IsVolatile=false)
ObjCImplementationDecl - Represents a class definition - this is where method definitions are specifi...
uint64_t getCharWidth() const
Return the size of the character type, in bits.
llvm::PointerType * Int8PtrTy
Represents Objective-C's @finally statement.
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.
QualType withCVRQualifiers(unsigned CVR) const
CharUnits toCharUnitsFromBits(int64_t BitSize) const
Convert a size in bits to a size in characters.
Reading or writing from this object requires a barrier call.
int64_t toBits(CharUnits CharSize) const
Convert a size in characters to a size in bits.
llvm::Type * ConvertType(QualType T)
Qualifiers getQualifiers() const
Retrieve the set of qualifiers applied to this type.
ObjCIvarDecl - Represents an ObjC instance variable.
Represents Objective-C's @try ... @catch ... @finally statement.
unsigned getNumCatchStmts() const
Retrieve the number of @catch statements in this try-catch-finally block.
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)
const VarDecl * getCatchParamDecl() const
void EmitBranchThroughCleanup(JumpDest Dest)
EmitBranchThroughCleanup - Emit a branch from the current insert block through the normal cleanup han...
LValue - This represents an lvalue references.
Information for lazily generating a cleanup.
QualType getObjCObjectPointerType(QualType OIT) const
Return a ObjCObjectPointerType type for the given ObjCObjectType.
llvm::Value * EmitObjCConsumeObject(QualType T, llvm::Value *Ptr)
Produce the code for a CK_ARCConsumeObject.
virtual llvm::Constant * GetEHType(QualType T)=0
Get the type constant to catch for the given ObjC pointer type.
const LangOptions & getLangOpts() const
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.
llvm::FunctionType * GetFunctionType(const CGFunctionInfo &Info)
GetFunctionType - Get the LLVM function type for.