mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-13 22:00:14 +00:00
Suppress all uses of LLVM_END_WITH_NULL. NFC.
Use variadic templates instead of relying on <cstdarg> + sentinel. This enforces better type checking and makes code more readable. Differential revision: https://reviews.llvm.org/D32550 llvm-svn: 302572
This commit is contained in:
parent
e38003f839
commit
1d993270b3
@ -961,9 +961,8 @@ llvm::Type *CodeGenModule::getBlockDescriptorType() {
|
||||
// const char *signature; // the block signature
|
||||
// const char *layout; // reserved
|
||||
// };
|
||||
BlockDescriptorType =
|
||||
llvm::StructType::create("struct.__block_descriptor",
|
||||
UnsignedLongTy, UnsignedLongTy, nullptr);
|
||||
BlockDescriptorType = llvm::StructType::create(
|
||||
"struct.__block_descriptor", UnsignedLongTy, UnsignedLongTy);
|
||||
|
||||
// Now form a pointer to that.
|
||||
unsigned AddrSpace = 0;
|
||||
@ -987,9 +986,8 @@ llvm::Type *CodeGenModule::getGenericBlockLiteralType() {
|
||||
// struct __block_descriptor *__descriptor;
|
||||
// };
|
||||
GenericBlockLiteralType =
|
||||
llvm::StructType::create("struct.__block_literal_generic",
|
||||
VoidPtrTy, IntTy, IntTy, VoidPtrTy,
|
||||
BlockDescPtrTy, nullptr);
|
||||
llvm::StructType::create("struct.__block_literal_generic", VoidPtrTy,
|
||||
IntTy, IntTy, VoidPtrTy, BlockDescPtrTy);
|
||||
|
||||
return GenericBlockLiteralType;
|
||||
}
|
||||
|
@ -4571,7 +4571,7 @@ Value *CodeGenFunction::EmitARMBuiltinExpr(unsigned BuiltinID,
|
||||
Function *F = CGM.getIntrinsic(BuiltinID == ARM::BI__builtin_arm_stlex
|
||||
? Intrinsic::arm_stlexd
|
||||
: Intrinsic::arm_strexd);
|
||||
llvm::Type *STy = llvm::StructType::get(Int32Ty, Int32Ty, nullptr);
|
||||
llvm::Type *STy = llvm::StructType::get(Int32Ty, Int32Ty);
|
||||
|
||||
Address Tmp = CreateMemTemp(E->getArg(0)->getType());
|
||||
Value *Val = EmitScalarExpr(E->getArg(0));
|
||||
@ -5401,7 +5401,7 @@ Value *CodeGenFunction::EmitAArch64BuiltinExpr(unsigned BuiltinID,
|
||||
Function *F = CGM.getIntrinsic(BuiltinID == AArch64::BI__builtin_arm_stlex
|
||||
? Intrinsic::aarch64_stlxp
|
||||
: Intrinsic::aarch64_stxp);
|
||||
llvm::Type *STy = llvm::StructType::get(Int64Ty, Int64Ty, nullptr);
|
||||
llvm::Type *STy = llvm::StructType::get(Int64Ty, Int64Ty);
|
||||
|
||||
Address Tmp = CreateMemTemp(E->getArg(0)->getType());
|
||||
EmitAnyExprToMem(E->getArg(0), Tmp, Qualifiers(), /*init*/ true);
|
||||
@ -7373,8 +7373,8 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID,
|
||||
// unsigned int __cpu_type;
|
||||
// unsigned int __cpu_subtype;
|
||||
// unsigned int __cpu_features[1];
|
||||
llvm::Type *STy = llvm::StructType::get(
|
||||
Int32Ty, Int32Ty, Int32Ty, llvm::ArrayType::get(Int32Ty, 1), nullptr);
|
||||
llvm::Type *STy = llvm::StructType::get(Int32Ty, Int32Ty, Int32Ty,
|
||||
llvm::ArrayType::get(Int32Ty, 1));
|
||||
|
||||
// Grab the global __cpu_model.
|
||||
llvm::Constant *CpuModel = CGM.CreateRuntimeVariable(STy, "__cpu_model");
|
||||
|
@ -265,7 +265,7 @@ llvm::Function *CGNVCUDARuntime::makeModuleCtorFunction() {
|
||||
"__cudaRegisterFatBinary");
|
||||
// struct { int magic, int version, void * gpu_binary, void * dont_care };
|
||||
llvm::StructType *FatbinWrapperTy =
|
||||
llvm::StructType::get(IntTy, IntTy, VoidPtrTy, VoidPtrTy, nullptr);
|
||||
llvm::StructType::get(IntTy, IntTy, VoidPtrTy, VoidPtrTy);
|
||||
|
||||
llvm::Function *ModuleCtorFunc = llvm::Function::Create(
|
||||
llvm::FunctionType::get(VoidTy, VoidPtrTy, false),
|
||||
|
@ -51,8 +51,7 @@ DominatingValue<RValue>::saved_type::save(CodeGenFunction &CGF, RValue rv) {
|
||||
if (rv.isComplex()) {
|
||||
CodeGenFunction::ComplexPairTy V = rv.getComplexVal();
|
||||
llvm::Type *ComplexTy =
|
||||
llvm::StructType::get(V.first->getType(), V.second->getType(),
|
||||
(void*) nullptr);
|
||||
llvm::StructType::get(V.first->getType(), V.second->getType());
|
||||
Address addr = CGF.CreateDefaultAlignTempAlloca(ComplexTy, "saved-complex");
|
||||
CGF.Builder.CreateStore(V.first,
|
||||
CGF.Builder.CreateStructGEP(addr, 0, CharUnits()));
|
||||
|
@ -765,8 +765,8 @@ llvm::BasicBlock *CodeGenFunction::EmitLandingPad() {
|
||||
llvm::BasicBlock *lpad = createBasicBlock("lpad");
|
||||
EmitBlock(lpad);
|
||||
|
||||
llvm::LandingPadInst *LPadInst = Builder.CreateLandingPad(
|
||||
llvm::StructType::get(Int8PtrTy, Int32Ty, nullptr), 0);
|
||||
llvm::LandingPadInst *LPadInst =
|
||||
Builder.CreateLandingPad(llvm::StructType::get(Int8PtrTy, Int32Ty), 0);
|
||||
|
||||
llvm::Value *LPadExn = Builder.CreateExtractValue(LPadInst, 0);
|
||||
Builder.CreateStore(LPadExn, getExceptionSlot());
|
||||
@ -1310,8 +1310,8 @@ llvm::BasicBlock *CodeGenFunction::getTerminateLandingPad() {
|
||||
if (!CurFn->hasPersonalityFn())
|
||||
CurFn->setPersonalityFn(getOpaquePersonalityFn(CGM, Personality));
|
||||
|
||||
llvm::LandingPadInst *LPadInst = Builder.CreateLandingPad(
|
||||
llvm::StructType::get(Int8PtrTy, Int32Ty, nullptr), 0);
|
||||
llvm::LandingPadInst *LPadInst =
|
||||
Builder.CreateLandingPad(llvm::StructType::get(Int8PtrTy, Int32Ty), 0);
|
||||
LPadInst->addClause(getCatchAllValue(*this));
|
||||
|
||||
llvm::Value *Exn = nullptr;
|
||||
@ -1387,8 +1387,7 @@ llvm::BasicBlock *CodeGenFunction::getEHResumeBlock(bool isCleanup) {
|
||||
llvm::Value *Exn = getExceptionFromSlot();
|
||||
llvm::Value *Sel = getSelectorFromSlot();
|
||||
|
||||
llvm::Type *LPadType = llvm::StructType::get(Exn->getType(),
|
||||
Sel->getType(), nullptr);
|
||||
llvm::Type *LPadType = llvm::StructType::get(Exn->getType(), Sel->getType());
|
||||
llvm::Value *LPadVal = llvm::UndefValue::get(LPadType);
|
||||
LPadVal = Builder.CreateInsertValue(LPadVal, Exn, 0, "lpad.val");
|
||||
LPadVal = Builder.CreateInsertValue(LPadVal, Sel, 1, "lpad.val");
|
||||
@ -1747,7 +1746,7 @@ void CodeGenFunction::EmitSEHExceptionCodeSave(CodeGenFunction &ParentCGF,
|
||||
// };
|
||||
// int exceptioncode = exception_pointers->ExceptionRecord->ExceptionCode;
|
||||
llvm::Type *RecordTy = CGM.Int32Ty->getPointerTo();
|
||||
llvm::Type *PtrsTy = llvm::StructType::get(RecordTy, CGM.VoidPtrTy, nullptr);
|
||||
llvm::Type *PtrsTy = llvm::StructType::get(RecordTy, CGM.VoidPtrTy);
|
||||
llvm::Value *Ptrs = Builder.CreateBitCast(SEHInfo, PtrsTy->getPointerTo());
|
||||
llvm::Value *Rec = Builder.CreateStructGEP(PtrsTy, Ptrs, 0);
|
||||
Rec = Builder.CreateAlignedLoad(Rec, getPointerAlign());
|
||||
|
@ -2859,9 +2859,9 @@ void CodeGenFunction::EmitCfiCheckFail() {
|
||||
EmitTrapCheck(DataIsNotNullPtr);
|
||||
|
||||
llvm::StructType *SourceLocationTy =
|
||||
llvm::StructType::get(VoidPtrTy, Int32Ty, Int32Ty, nullptr);
|
||||
llvm::StructType::get(VoidPtrTy, Int32Ty, Int32Ty);
|
||||
llvm::StructType *CfiCheckFailDataTy =
|
||||
llvm::StructType::get(Int8Ty, SourceLocationTy, VoidPtrTy, nullptr);
|
||||
llvm::StructType::get(Int8Ty, SourceLocationTy, VoidPtrTy);
|
||||
|
||||
llvm::Value *V = Builder.CreateConstGEP2_32(
|
||||
CfiCheckFailDataTy,
|
||||
|
@ -1361,9 +1361,8 @@ llvm::Constant *CodeGenModule::EmitConstantValue(const APValue &Value,
|
||||
Value.getComplexIntImag());
|
||||
|
||||
// FIXME: the target may want to specify that this is packed.
|
||||
llvm::StructType *STy = llvm::StructType::get(Complex[0]->getType(),
|
||||
Complex[1]->getType(),
|
||||
nullptr);
|
||||
llvm::StructType *STy =
|
||||
llvm::StructType::get(Complex[0]->getType(), Complex[1]->getType());
|
||||
return llvm::ConstantStruct::get(STy, Complex);
|
||||
}
|
||||
case APValue::Float: {
|
||||
@ -1384,9 +1383,8 @@ llvm::Constant *CodeGenModule::EmitConstantValue(const APValue &Value,
|
||||
Value.getComplexFloatImag());
|
||||
|
||||
// FIXME: the target may want to specify that this is packed.
|
||||
llvm::StructType *STy = llvm::StructType::get(Complex[0]->getType(),
|
||||
Complex[1]->getType(),
|
||||
nullptr);
|
||||
llvm::StructType *STy =
|
||||
llvm::StructType::get(Complex[0]->getType(), Complex[1]->getType());
|
||||
return llvm::ConstantStruct::get(STy, Complex);
|
||||
}
|
||||
case APValue::Vector: {
|
||||
|
@ -34,7 +34,6 @@
|
||||
#include "llvm/IR/LLVMContext.h"
|
||||
#include "llvm/IR/Module.h"
|
||||
#include "llvm/Support/Compiler.h"
|
||||
#include <cstdarg>
|
||||
|
||||
using namespace clang;
|
||||
using namespace CodeGen;
|
||||
@ -58,17 +57,13 @@ public:
|
||||
|
||||
/// Initialises the lazy function with the name, return type, and the types
|
||||
/// of the arguments.
|
||||
LLVM_END_WITH_NULL
|
||||
void init(CodeGenModule *Mod, const char *name, llvm::Type *RetTy, ...) {
|
||||
template <typename... Tys>
|
||||
void init(CodeGenModule *Mod, const char *name, llvm::Type *RetTy,
|
||||
Tys *... Types) {
|
||||
CGM = Mod;
|
||||
FunctionName = name;
|
||||
Function = nullptr;
|
||||
std::vector<llvm::Type *> ArgTys;
|
||||
va_list Args;
|
||||
va_start(Args, RetTy);
|
||||
while (llvm::Type *ArgTy = va_arg(Args, llvm::Type *))
|
||||
ArgTys.push_back(ArgTy);
|
||||
va_end(Args);
|
||||
std::vector<llvm::Type *> ArgTys{{Types...}};
|
||||
FTy = llvm::FunctionType::get(RetTy, ArgTys, false);
|
||||
}
|
||||
|
||||
@ -603,11 +598,10 @@ protected:
|
||||
public:
|
||||
CGObjCGCC(CodeGenModule &Mod) : CGObjCGNU(Mod, 8, 2) {
|
||||
// IMP objc_msg_lookup(id, SEL);
|
||||
MsgLookupFn.init(&CGM, "objc_msg_lookup", IMPTy, IdTy, SelectorTy,
|
||||
nullptr);
|
||||
MsgLookupFn.init(&CGM, "objc_msg_lookup", IMPTy, IdTy, SelectorTy);
|
||||
// IMP objc_msg_lookup_super(struct objc_super*, SEL);
|
||||
MsgLookupSuperFn.init(&CGM, "objc_msg_lookup_super", IMPTy,
|
||||
PtrToObjCSuperTy, SelectorTy, nullptr);
|
||||
PtrToObjCSuperTy, SelectorTy);
|
||||
}
|
||||
};
|
||||
|
||||
@ -702,52 +696,51 @@ class CGObjCGNUstep : public CGObjCGNU {
|
||||
CGObjCGNUstep(CodeGenModule &Mod) : CGObjCGNU(Mod, 9, 3) {
|
||||
const ObjCRuntime &R = CGM.getLangOpts().ObjCRuntime;
|
||||
|
||||
llvm::StructType *SlotStructTy = llvm::StructType::get(PtrTy,
|
||||
PtrTy, PtrTy, IntTy, IMPTy, nullptr);
|
||||
llvm::StructType *SlotStructTy =
|
||||
llvm::StructType::get(PtrTy, PtrTy, PtrTy, IntTy, IMPTy);
|
||||
SlotTy = llvm::PointerType::getUnqual(SlotStructTy);
|
||||
// Slot_t objc_msg_lookup_sender(id *receiver, SEL selector, id sender);
|
||||
SlotLookupFn.init(&CGM, "objc_msg_lookup_sender", SlotTy, PtrToIdTy,
|
||||
SelectorTy, IdTy, nullptr);
|
||||
SelectorTy, IdTy);
|
||||
// Slot_t objc_msg_lookup_super(struct objc_super*, SEL);
|
||||
SlotLookupSuperFn.init(&CGM, "objc_slot_lookup_super", SlotTy,
|
||||
PtrToObjCSuperTy, SelectorTy, nullptr);
|
||||
PtrToObjCSuperTy, SelectorTy);
|
||||
// If we're in ObjC++ mode, then we want to make
|
||||
if (CGM.getLangOpts().CPlusPlus) {
|
||||
llvm::Type *VoidTy = llvm::Type::getVoidTy(VMContext);
|
||||
// void *__cxa_begin_catch(void *e)
|
||||
EnterCatchFn.init(&CGM, "__cxa_begin_catch", PtrTy, PtrTy, nullptr);
|
||||
EnterCatchFn.init(&CGM, "__cxa_begin_catch", PtrTy, PtrTy);
|
||||
// void __cxa_end_catch(void)
|
||||
ExitCatchFn.init(&CGM, "__cxa_end_catch", VoidTy, nullptr);
|
||||
ExitCatchFn.init(&CGM, "__cxa_end_catch", VoidTy);
|
||||
// void _Unwind_Resume_or_Rethrow(void*)
|
||||
ExceptionReThrowFn.init(&CGM, "_Unwind_Resume_or_Rethrow", VoidTy,
|
||||
PtrTy, nullptr);
|
||||
PtrTy);
|
||||
} else if (R.getVersion() >= VersionTuple(1, 7)) {
|
||||
llvm::Type *VoidTy = llvm::Type::getVoidTy(VMContext);
|
||||
// id objc_begin_catch(void *e)
|
||||
EnterCatchFn.init(&CGM, "objc_begin_catch", IdTy, PtrTy, nullptr);
|
||||
EnterCatchFn.init(&CGM, "objc_begin_catch", IdTy, PtrTy);
|
||||
// void objc_end_catch(void)
|
||||
ExitCatchFn.init(&CGM, "objc_end_catch", VoidTy, nullptr);
|
||||
ExitCatchFn.init(&CGM, "objc_end_catch", VoidTy);
|
||||
// void _Unwind_Resume_or_Rethrow(void*)
|
||||
ExceptionReThrowFn.init(&CGM, "objc_exception_rethrow", VoidTy,
|
||||
PtrTy, nullptr);
|
||||
ExceptionReThrowFn.init(&CGM, "objc_exception_rethrow", VoidTy, PtrTy);
|
||||
}
|
||||
llvm::Type *VoidTy = llvm::Type::getVoidTy(VMContext);
|
||||
SetPropertyAtomic.init(&CGM, "objc_setProperty_atomic", VoidTy, IdTy,
|
||||
SelectorTy, IdTy, PtrDiffTy, nullptr);
|
||||
SelectorTy, IdTy, PtrDiffTy);
|
||||
SetPropertyAtomicCopy.init(&CGM, "objc_setProperty_atomic_copy", VoidTy,
|
||||
IdTy, SelectorTy, IdTy, PtrDiffTy, nullptr);
|
||||
IdTy, SelectorTy, IdTy, PtrDiffTy);
|
||||
SetPropertyNonAtomic.init(&CGM, "objc_setProperty_nonatomic", VoidTy,
|
||||
IdTy, SelectorTy, IdTy, PtrDiffTy, nullptr);
|
||||
IdTy, SelectorTy, IdTy, PtrDiffTy);
|
||||
SetPropertyNonAtomicCopy.init(&CGM, "objc_setProperty_nonatomic_copy",
|
||||
VoidTy, IdTy, SelectorTy, IdTy, PtrDiffTy, nullptr);
|
||||
VoidTy, IdTy, SelectorTy, IdTy, PtrDiffTy);
|
||||
// void objc_setCppObjectAtomic(void *dest, const void *src, void
|
||||
// *helper);
|
||||
CxxAtomicObjectSetFn.init(&CGM, "objc_setCppObjectAtomic", VoidTy, PtrTy,
|
||||
PtrTy, PtrTy, nullptr);
|
||||
PtrTy, PtrTy);
|
||||
// void objc_getCppObjectAtomic(void *dest, const void *src, void
|
||||
// *helper);
|
||||
CxxAtomicObjectGetFn.init(&CGM, "objc_getCppObjectAtomic", VoidTy, PtrTy,
|
||||
PtrTy, PtrTy, nullptr);
|
||||
PtrTy, PtrTy);
|
||||
}
|
||||
|
||||
llvm::Constant *GetCppAtomicObjectGetFunction() override {
|
||||
@ -849,14 +842,14 @@ protected:
|
||||
public:
|
||||
CGObjCObjFW(CodeGenModule &Mod): CGObjCGNU(Mod, 9, 3) {
|
||||
// IMP objc_msg_lookup(id, SEL);
|
||||
MsgLookupFn.init(&CGM, "objc_msg_lookup", IMPTy, IdTy, SelectorTy, nullptr);
|
||||
MsgLookupFn.init(&CGM, "objc_msg_lookup", IMPTy, IdTy, SelectorTy);
|
||||
MsgLookupFnSRet.init(&CGM, "objc_msg_lookup_stret", IMPTy, IdTy,
|
||||
SelectorTy, nullptr);
|
||||
SelectorTy);
|
||||
// IMP objc_msg_lookup_super(struct objc_super*, SEL);
|
||||
MsgLookupSuperFn.init(&CGM, "objc_msg_lookup_super", IMPTy,
|
||||
PtrToObjCSuperTy, SelectorTy, nullptr);
|
||||
PtrToObjCSuperTy, SelectorTy);
|
||||
MsgLookupSuperFnSRet.init(&CGM, "objc_msg_lookup_super_stret", IMPTy,
|
||||
PtrToObjCSuperTy, SelectorTy, nullptr);
|
||||
PtrToObjCSuperTy, SelectorTy);
|
||||
}
|
||||
};
|
||||
} // end anonymous namespace
|
||||
@ -945,35 +938,34 @@ CGObjCGNU::CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion,
|
||||
}
|
||||
PtrToIdTy = llvm::PointerType::getUnqual(IdTy);
|
||||
|
||||
ObjCSuperTy = llvm::StructType::get(IdTy, IdTy, nullptr);
|
||||
ObjCSuperTy = llvm::StructType::get(IdTy, IdTy);
|
||||
PtrToObjCSuperTy = llvm::PointerType::getUnqual(ObjCSuperTy);
|
||||
|
||||
llvm::Type *VoidTy = llvm::Type::getVoidTy(VMContext);
|
||||
|
||||
// void objc_exception_throw(id);
|
||||
ExceptionThrowFn.init(&CGM, "objc_exception_throw", VoidTy, IdTy, nullptr);
|
||||
ExceptionReThrowFn.init(&CGM, "objc_exception_throw", VoidTy, IdTy, nullptr);
|
||||
ExceptionThrowFn.init(&CGM, "objc_exception_throw", VoidTy, IdTy);
|
||||
ExceptionReThrowFn.init(&CGM, "objc_exception_throw", VoidTy, IdTy);
|
||||
// int objc_sync_enter(id);
|
||||
SyncEnterFn.init(&CGM, "objc_sync_enter", IntTy, IdTy, nullptr);
|
||||
SyncEnterFn.init(&CGM, "objc_sync_enter", IntTy, IdTy);
|
||||
// int objc_sync_exit(id);
|
||||
SyncExitFn.init(&CGM, "objc_sync_exit", IntTy, IdTy, nullptr);
|
||||
SyncExitFn.init(&CGM, "objc_sync_exit", IntTy, IdTy);
|
||||
|
||||
// void objc_enumerationMutation (id)
|
||||
EnumerationMutationFn.init(&CGM, "objc_enumerationMutation", VoidTy,
|
||||
IdTy, nullptr);
|
||||
EnumerationMutationFn.init(&CGM, "objc_enumerationMutation", VoidTy, IdTy);
|
||||
|
||||
// id objc_getProperty(id, SEL, ptrdiff_t, BOOL)
|
||||
GetPropertyFn.init(&CGM, "objc_getProperty", IdTy, IdTy, SelectorTy,
|
||||
PtrDiffTy, BoolTy, nullptr);
|
||||
PtrDiffTy, BoolTy);
|
||||
// void objc_setProperty(id, SEL, ptrdiff_t, id, BOOL, BOOL)
|
||||
SetPropertyFn.init(&CGM, "objc_setProperty", VoidTy, IdTy, SelectorTy,
|
||||
PtrDiffTy, IdTy, BoolTy, BoolTy, nullptr);
|
||||
PtrDiffTy, IdTy, BoolTy, BoolTy);
|
||||
// void objc_setPropertyStruct(void*, void*, ptrdiff_t, BOOL, BOOL)
|
||||
GetStructPropertyFn.init(&CGM, "objc_getPropertyStruct", VoidTy, PtrTy, PtrTy,
|
||||
PtrDiffTy, BoolTy, BoolTy, nullptr);
|
||||
GetStructPropertyFn.init(&CGM, "objc_getPropertyStruct", VoidTy, PtrTy, PtrTy,
|
||||
PtrDiffTy, BoolTy, BoolTy);
|
||||
// void objc_setPropertyStruct(void*, void*, ptrdiff_t, BOOL, BOOL)
|
||||
SetStructPropertyFn.init(&CGM, "objc_setPropertyStruct", VoidTy, PtrTy, PtrTy,
|
||||
PtrDiffTy, BoolTy, BoolTy, nullptr);
|
||||
SetStructPropertyFn.init(&CGM, "objc_setPropertyStruct", VoidTy, PtrTy, PtrTy,
|
||||
PtrDiffTy, BoolTy, BoolTy);
|
||||
|
||||
// IMP type
|
||||
llvm::Type *IMPArgs[] = { IdTy, SelectorTy };
|
||||
@ -997,21 +989,19 @@ CGObjCGNU::CGObjCGNU(CodeGenModule &cgm, unsigned runtimeABIVersion,
|
||||
// Get functions needed in GC mode
|
||||
|
||||
// id objc_assign_ivar(id, id, ptrdiff_t);
|
||||
IvarAssignFn.init(&CGM, "objc_assign_ivar", IdTy, IdTy, IdTy, PtrDiffTy,
|
||||
nullptr);
|
||||
IvarAssignFn.init(&CGM, "objc_assign_ivar", IdTy, IdTy, IdTy, PtrDiffTy);
|
||||
// id objc_assign_strongCast (id, id*)
|
||||
StrongCastAssignFn.init(&CGM, "objc_assign_strongCast", IdTy, IdTy,
|
||||
PtrToIdTy, nullptr);
|
||||
PtrToIdTy);
|
||||
// id objc_assign_global(id, id*);
|
||||
GlobalAssignFn.init(&CGM, "objc_assign_global", IdTy, IdTy, PtrToIdTy,
|
||||
nullptr);
|
||||
GlobalAssignFn.init(&CGM, "objc_assign_global", IdTy, IdTy, PtrToIdTy);
|
||||
// id objc_assign_weak(id, id*);
|
||||
WeakAssignFn.init(&CGM, "objc_assign_weak", IdTy, IdTy, PtrToIdTy, nullptr);
|
||||
WeakAssignFn.init(&CGM, "objc_assign_weak", IdTy, IdTy, PtrToIdTy);
|
||||
// id objc_read_weak(id*);
|
||||
WeakReadFn.init(&CGM, "objc_read_weak", IdTy, PtrToIdTy, nullptr);
|
||||
WeakReadFn.init(&CGM, "objc_read_weak", IdTy, PtrToIdTy);
|
||||
// void *objc_memmove_collectable(void*, void *, size_t);
|
||||
MemMoveFn.init(&CGM, "objc_memmove_collectable", PtrTy, PtrTy, PtrTy,
|
||||
SizeTy, nullptr);
|
||||
SizeTy);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1317,7 +1307,7 @@ CGObjCGNU::GenerateMessageSendSuper(CodeGenFunction &CGF,
|
||||
}
|
||||
}
|
||||
// Cast the pointer to a simplified version of the class structure
|
||||
llvm::Type *CastTy = llvm::StructType::get(IdTy, IdTy, nullptr);
|
||||
llvm::Type *CastTy = llvm::StructType::get(IdTy, IdTy);
|
||||
ReceiverClass = Builder.CreateBitCast(ReceiverClass,
|
||||
llvm::PointerType::getUnqual(CastTy));
|
||||
// Get the superclass pointer
|
||||
@ -1326,8 +1316,8 @@ CGObjCGNU::GenerateMessageSendSuper(CodeGenFunction &CGF,
|
||||
ReceiverClass =
|
||||
Builder.CreateAlignedLoad(ReceiverClass, CGF.getPointerAlign());
|
||||
// Construct the structure used to look up the IMP
|
||||
llvm::StructType *ObjCSuperTy = llvm::StructType::get(
|
||||
Receiver->getType(), IdTy, nullptr);
|
||||
llvm::StructType *ObjCSuperTy =
|
||||
llvm::StructType::get(Receiver->getType(), IdTy);
|
||||
|
||||
// FIXME: Is this really supposed to be a dynamic alloca?
|
||||
Address ObjCSuper = Address(Builder.CreateAlloca(ObjCSuperTy),
|
||||
@ -1565,11 +1555,8 @@ GenerateIvarList(ArrayRef<llvm::Constant *> IvarNames,
|
||||
IvarList.addInt(IntTy, (int)IvarNames.size());
|
||||
|
||||
// Get the ivar structure type.
|
||||
llvm::StructType *ObjCIvarTy = llvm::StructType::get(
|
||||
PtrToInt8Ty,
|
||||
PtrToInt8Ty,
|
||||
IntTy,
|
||||
nullptr);
|
||||
llvm::StructType *ObjCIvarTy =
|
||||
llvm::StructType::get(PtrToInt8Ty, PtrToInt8Ty, IntTy);
|
||||
|
||||
// Array of ivar structures.
|
||||
auto Ivars = IvarList.beginArray(ObjCIvarTy);
|
||||
@ -1611,7 +1598,7 @@ llvm::Constant *CGObjCGNU::GenerateClassStructure(
|
||||
// anyway; the classes will still work with the GNU runtime, they will just
|
||||
// be ignored.
|
||||
llvm::StructType *ClassTy = llvm::StructType::get(
|
||||
PtrToInt8Ty, // isa
|
||||
PtrToInt8Ty, // isa
|
||||
PtrToInt8Ty, // super_class
|
||||
PtrToInt8Ty, // name
|
||||
LongTy, // version
|
||||
@ -1620,18 +1607,18 @@ llvm::Constant *CGObjCGNU::GenerateClassStructure(
|
||||
IVars->getType(), // ivars
|
||||
Methods->getType(), // methods
|
||||
// These are all filled in by the runtime, so we pretend
|
||||
PtrTy, // dtable
|
||||
PtrTy, // subclass_list
|
||||
PtrTy, // sibling_class
|
||||
PtrTy, // protocols
|
||||
PtrTy, // gc_object_type
|
||||
PtrTy, // dtable
|
||||
PtrTy, // subclass_list
|
||||
PtrTy, // sibling_class
|
||||
PtrTy, // protocols
|
||||
PtrTy, // gc_object_type
|
||||
// New ABI:
|
||||
LongTy, // abi_version
|
||||
IvarOffsets->getType(), // ivar_offsets
|
||||
Properties->getType(), // properties
|
||||
IntPtrTy, // strong_pointers
|
||||
IntPtrTy, // weak_pointers
|
||||
nullptr);
|
||||
IntPtrTy // weak_pointers
|
||||
);
|
||||
|
||||
ConstantInitBuilder Builder(CGM);
|
||||
auto Elements = Builder.beginStruct(ClassTy);
|
||||
|
@ -105,8 +105,8 @@ private:
|
||||
llvm::Constant *getMessageSendFp2retFn() const {
|
||||
llvm::Type *params[] = { ObjectPtrTy, SelectorPtrTy };
|
||||
llvm::Type *longDoubleType = llvm::Type::getX86_FP80Ty(VMContext);
|
||||
llvm::Type *resultType =
|
||||
llvm::StructType::get(longDoubleType, longDoubleType, nullptr);
|
||||
llvm::Type *resultType =
|
||||
llvm::StructType::get(longDoubleType, longDoubleType);
|
||||
|
||||
return CGM.CreateRuntimeFunction(llvm::FunctionType::get(resultType,
|
||||
params, true),
|
||||
@ -5506,17 +5506,15 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm)
|
||||
// char *name;
|
||||
// char *attributes;
|
||||
// }
|
||||
PropertyTy = llvm::StructType::create("struct._prop_t",
|
||||
Int8PtrTy, Int8PtrTy, nullptr);
|
||||
PropertyTy = llvm::StructType::create("struct._prop_t", Int8PtrTy, Int8PtrTy);
|
||||
|
||||
// struct _prop_list_t {
|
||||
// uint32_t entsize; // sizeof(struct _prop_t)
|
||||
// uint32_t count_of_properties;
|
||||
// struct _prop_t prop_list[count_of_properties];
|
||||
// }
|
||||
PropertyListTy =
|
||||
llvm::StructType::create("struct._prop_list_t", IntTy, IntTy,
|
||||
llvm::ArrayType::get(PropertyTy, 0), nullptr);
|
||||
PropertyListTy = llvm::StructType::create(
|
||||
"struct._prop_list_t", IntTy, IntTy, llvm::ArrayType::get(PropertyTy, 0));
|
||||
// struct _prop_list_t *
|
||||
PropertyListPtrTy = llvm::PointerType::getUnqual(PropertyListTy);
|
||||
|
||||
@ -5525,9 +5523,8 @@ ObjCCommonTypesHelper::ObjCCommonTypesHelper(CodeGen::CodeGenModule &cgm)
|
||||
// char *method_type;
|
||||
// char *_imp;
|
||||
// }
|
||||
MethodTy = llvm::StructType::create("struct._objc_method",
|
||||
SelectorPtrTy, Int8PtrTy, Int8PtrTy,
|
||||
nullptr);
|
||||
MethodTy = llvm::StructType::create("struct._objc_method", SelectorPtrTy,
|
||||
Int8PtrTy, Int8PtrTy);
|
||||
|
||||
// struct _objc_cache *
|
||||
CacheTy = llvm::StructType::create(VMContext, "struct._objc_cache");
|
||||
@ -5540,17 +5537,16 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
|
||||
// SEL name;
|
||||
// char *types;
|
||||
// }
|
||||
MethodDescriptionTy =
|
||||
llvm::StructType::create("struct._objc_method_description",
|
||||
SelectorPtrTy, Int8PtrTy, nullptr);
|
||||
MethodDescriptionTy = llvm::StructType::create(
|
||||
"struct._objc_method_description", SelectorPtrTy, Int8PtrTy);
|
||||
|
||||
// struct _objc_method_description_list {
|
||||
// int count;
|
||||
// struct _objc_method_description[1];
|
||||
// }
|
||||
MethodDescriptionListTy = llvm::StructType::create(
|
||||
"struct._objc_method_description_list", IntTy,
|
||||
llvm::ArrayType::get(MethodDescriptionTy, 0), nullptr);
|
||||
MethodDescriptionListTy =
|
||||
llvm::StructType::create("struct._objc_method_description_list", IntTy,
|
||||
llvm::ArrayType::get(MethodDescriptionTy, 0));
|
||||
|
||||
// struct _objc_method_description_list *
|
||||
MethodDescriptionListPtrTy =
|
||||
@ -5566,11 +5562,10 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
|
||||
// const char ** extendedMethodTypes;
|
||||
// struct _objc_property_list *class_properties;
|
||||
// }
|
||||
ProtocolExtensionTy =
|
||||
llvm::StructType::create("struct._objc_protocol_extension",
|
||||
IntTy, MethodDescriptionListPtrTy,
|
||||
MethodDescriptionListPtrTy, PropertyListPtrTy,
|
||||
Int8PtrPtrTy, PropertyListPtrTy, nullptr);
|
||||
ProtocolExtensionTy = llvm::StructType::create(
|
||||
"struct._objc_protocol_extension", IntTy, MethodDescriptionListPtrTy,
|
||||
MethodDescriptionListPtrTy, PropertyListPtrTy, Int8PtrPtrTy,
|
||||
PropertyListPtrTy);
|
||||
|
||||
// struct _objc_protocol_extension *
|
||||
ProtocolExtensionPtrTy = llvm::PointerType::getUnqual(ProtocolExtensionTy);
|
||||
@ -5582,10 +5577,8 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
|
||||
|
||||
ProtocolListTy =
|
||||
llvm::StructType::create(VMContext, "struct._objc_protocol_list");
|
||||
ProtocolListTy->setBody(llvm::PointerType::getUnqual(ProtocolListTy),
|
||||
LongTy,
|
||||
llvm::ArrayType::get(ProtocolTy, 0),
|
||||
nullptr);
|
||||
ProtocolListTy->setBody(llvm::PointerType::getUnqual(ProtocolListTy), LongTy,
|
||||
llvm::ArrayType::get(ProtocolTy, 0));
|
||||
|
||||
// struct _objc_protocol {
|
||||
// struct _objc_protocol_extension *isa;
|
||||
@ -5596,9 +5589,7 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
|
||||
// }
|
||||
ProtocolTy->setBody(ProtocolExtensionPtrTy, Int8PtrTy,
|
||||
llvm::PointerType::getUnqual(ProtocolListTy),
|
||||
MethodDescriptionListPtrTy,
|
||||
MethodDescriptionListPtrTy,
|
||||
nullptr);
|
||||
MethodDescriptionListPtrTy, MethodDescriptionListPtrTy);
|
||||
|
||||
// struct _objc_protocol_list *
|
||||
ProtocolListPtrTy = llvm::PointerType::getUnqual(ProtocolListTy);
|
||||
@ -5612,8 +5603,8 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
|
||||
// char *ivar_type;
|
||||
// int ivar_offset;
|
||||
// }
|
||||
IvarTy = llvm::StructType::create("struct._objc_ivar",
|
||||
Int8PtrTy, Int8PtrTy, IntTy, nullptr);
|
||||
IvarTy = llvm::StructType::create("struct._objc_ivar", Int8PtrTy, Int8PtrTy,
|
||||
IntTy);
|
||||
|
||||
// struct _objc_ivar_list *
|
||||
IvarListTy =
|
||||
@ -5626,9 +5617,8 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
|
||||
MethodListPtrTy = llvm::PointerType::getUnqual(MethodListTy);
|
||||
|
||||
// struct _objc_class_extension *
|
||||
ClassExtensionTy =
|
||||
llvm::StructType::create("struct._objc_class_extension",
|
||||
IntTy, Int8PtrTy, PropertyListPtrTy, nullptr);
|
||||
ClassExtensionTy = llvm::StructType::create(
|
||||
"struct._objc_class_extension", IntTy, Int8PtrTy, PropertyListPtrTy);
|
||||
ClassExtensionPtrTy = llvm::PointerType::getUnqual(ClassExtensionTy);
|
||||
|
||||
ClassTy = llvm::StructType::create(VMContext, "struct._objc_class");
|
||||
@ -5648,18 +5638,9 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
|
||||
// struct _objc_class_ext *ext;
|
||||
// };
|
||||
ClassTy->setBody(llvm::PointerType::getUnqual(ClassTy),
|
||||
llvm::PointerType::getUnqual(ClassTy),
|
||||
Int8PtrTy,
|
||||
LongTy,
|
||||
LongTy,
|
||||
LongTy,
|
||||
IvarListPtrTy,
|
||||
MethodListPtrTy,
|
||||
CachePtrTy,
|
||||
ProtocolListPtrTy,
|
||||
Int8PtrTy,
|
||||
ClassExtensionPtrTy,
|
||||
nullptr);
|
||||
llvm::PointerType::getUnqual(ClassTy), Int8PtrTy, LongTy,
|
||||
LongTy, LongTy, IvarListPtrTy, MethodListPtrTy, CachePtrTy,
|
||||
ProtocolListPtrTy, Int8PtrTy, ClassExtensionPtrTy);
|
||||
|
||||
ClassPtrTy = llvm::PointerType::getUnqual(ClassTy);
|
||||
|
||||
@ -5673,12 +5654,10 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
|
||||
// struct _objc_property_list *instance_properties;// category's @property
|
||||
// struct _objc_property_list *class_properties;
|
||||
// }
|
||||
CategoryTy =
|
||||
llvm::StructType::create("struct._objc_category",
|
||||
Int8PtrTy, Int8PtrTy, MethodListPtrTy,
|
||||
MethodListPtrTy, ProtocolListPtrTy,
|
||||
IntTy, PropertyListPtrTy, PropertyListPtrTy,
|
||||
nullptr);
|
||||
CategoryTy = llvm::StructType::create(
|
||||
"struct._objc_category", Int8PtrTy, Int8PtrTy, MethodListPtrTy,
|
||||
MethodListPtrTy, ProtocolListPtrTy, IntTy, PropertyListPtrTy,
|
||||
PropertyListPtrTy);
|
||||
|
||||
// Global metadata structures
|
||||
|
||||
@ -5689,10 +5668,9 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
|
||||
// short cat_def_cnt;
|
||||
// char *defs[cls_def_cnt + cat_def_cnt];
|
||||
// }
|
||||
SymtabTy =
|
||||
llvm::StructType::create("struct._objc_symtab",
|
||||
LongTy, SelectorPtrTy, ShortTy, ShortTy,
|
||||
llvm::ArrayType::get(Int8PtrTy, 0), nullptr);
|
||||
SymtabTy = llvm::StructType::create("struct._objc_symtab", LongTy,
|
||||
SelectorPtrTy, ShortTy, ShortTy,
|
||||
llvm::ArrayType::get(Int8PtrTy, 0));
|
||||
SymtabPtrTy = llvm::PointerType::getUnqual(SymtabTy);
|
||||
|
||||
// struct _objc_module {
|
||||
@ -5701,10 +5679,8 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
|
||||
// char *name;
|
||||
// struct _objc_symtab* symtab;
|
||||
// }
|
||||
ModuleTy =
|
||||
llvm::StructType::create("struct._objc_module",
|
||||
LongTy, LongTy, Int8PtrTy, SymtabPtrTy, nullptr);
|
||||
|
||||
ModuleTy = llvm::StructType::create("struct._objc_module", LongTy, LongTy,
|
||||
Int8PtrTy, SymtabPtrTy);
|
||||
|
||||
// FIXME: This is the size of the setjmp buffer and should be target
|
||||
// specific. 18 is what's used on 32-bit X86.
|
||||
@ -5713,10 +5689,9 @@ ObjCTypesHelper::ObjCTypesHelper(CodeGen::CodeGenModule &cgm)
|
||||
// Exceptions
|
||||
llvm::Type *StackPtrTy = llvm::ArrayType::get(CGM.Int8PtrTy, 4);
|
||||
|
||||
ExceptionDataTy =
|
||||
llvm::StructType::create("struct._objc_exception_data",
|
||||
llvm::ArrayType::get(CGM.Int32Ty,SetJmpBufferSize),
|
||||
StackPtrTy, nullptr);
|
||||
ExceptionDataTy = llvm::StructType::create(
|
||||
"struct._objc_exception_data",
|
||||
llvm::ArrayType::get(CGM.Int32Ty, SetJmpBufferSize), StackPtrTy);
|
||||
}
|
||||
|
||||
ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModule &cgm)
|
||||
@ -5727,8 +5702,8 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul
|
||||
// struct _objc_method method_list[method_count];
|
||||
// }
|
||||
MethodListnfABITy =
|
||||
llvm::StructType::create("struct.__method_list_t", IntTy, IntTy,
|
||||
llvm::ArrayType::get(MethodTy, 0), nullptr);
|
||||
llvm::StructType::create("struct.__method_list_t", IntTy, IntTy,
|
||||
llvm::ArrayType::get(MethodTy, 0));
|
||||
// struct method_list_t *
|
||||
MethodListnfABIPtrTy = llvm::PointerType::getUnqual(MethodListnfABITy);
|
||||
|
||||
@ -5752,14 +5727,12 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul
|
||||
ProtocolListnfABITy =
|
||||
llvm::StructType::create(VMContext, "struct._objc_protocol_list");
|
||||
|
||||
ProtocolnfABITy =
|
||||
llvm::StructType::create("struct._protocol_t", ObjectPtrTy, Int8PtrTy,
|
||||
llvm::PointerType::getUnqual(ProtocolListnfABITy),
|
||||
MethodListnfABIPtrTy, MethodListnfABIPtrTy,
|
||||
MethodListnfABIPtrTy, MethodListnfABIPtrTy,
|
||||
PropertyListPtrTy, IntTy, IntTy, Int8PtrPtrTy,
|
||||
Int8PtrTy, PropertyListPtrTy,
|
||||
nullptr);
|
||||
ProtocolnfABITy = llvm::StructType::create(
|
||||
"struct._protocol_t", ObjectPtrTy, Int8PtrTy,
|
||||
llvm::PointerType::getUnqual(ProtocolListnfABITy), MethodListnfABIPtrTy,
|
||||
MethodListnfABIPtrTy, MethodListnfABIPtrTy, MethodListnfABIPtrTy,
|
||||
PropertyListPtrTy, IntTy, IntTy, Int8PtrPtrTy, Int8PtrTy,
|
||||
PropertyListPtrTy);
|
||||
|
||||
// struct _protocol_t*
|
||||
ProtocolnfABIPtrTy = llvm::PointerType::getUnqual(ProtocolnfABITy);
|
||||
@ -5769,8 +5742,7 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul
|
||||
// struct _protocol_t *[protocol_count];
|
||||
// }
|
||||
ProtocolListnfABITy->setBody(LongTy,
|
||||
llvm::ArrayType::get(ProtocolnfABIPtrTy, 0),
|
||||
nullptr);
|
||||
llvm::ArrayType::get(ProtocolnfABIPtrTy, 0));
|
||||
|
||||
// struct _objc_protocol_list*
|
||||
ProtocolListnfABIPtrTy = llvm::PointerType::getUnqual(ProtocolListnfABITy);
|
||||
@ -5784,7 +5756,7 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul
|
||||
// }
|
||||
IvarnfABITy = llvm::StructType::create(
|
||||
"struct._ivar_t", llvm::PointerType::getUnqual(IvarOffsetVarTy),
|
||||
Int8PtrTy, Int8PtrTy, IntTy, IntTy, nullptr);
|
||||
Int8PtrTy, Int8PtrTy, IntTy, IntTy);
|
||||
|
||||
// struct _ivar_list_t {
|
||||
// uint32 entsize; // sizeof(struct _ivar_t)
|
||||
@ -5792,8 +5764,8 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul
|
||||
// struct _iver_t list[count];
|
||||
// }
|
||||
IvarListnfABITy =
|
||||
llvm::StructType::create("struct._ivar_list_t", IntTy, IntTy,
|
||||
llvm::ArrayType::get(IvarnfABITy, 0), nullptr);
|
||||
llvm::StructType::create("struct._ivar_list_t", IntTy, IntTy,
|
||||
llvm::ArrayType::get(IvarnfABITy, 0));
|
||||
|
||||
IvarListnfABIPtrTy = llvm::PointerType::getUnqual(IvarListnfABITy);
|
||||
|
||||
@ -5812,13 +5784,10 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul
|
||||
// }
|
||||
|
||||
// FIXME. Add 'reserved' field in 64bit abi mode!
|
||||
ClassRonfABITy = llvm::StructType::create("struct._class_ro_t",
|
||||
IntTy, IntTy, IntTy, Int8PtrTy,
|
||||
Int8PtrTy, MethodListnfABIPtrTy,
|
||||
ProtocolListnfABIPtrTy,
|
||||
IvarListnfABIPtrTy,
|
||||
Int8PtrTy, PropertyListPtrTy,
|
||||
nullptr);
|
||||
ClassRonfABITy = llvm::StructType::create(
|
||||
"struct._class_ro_t", IntTy, IntTy, IntTy, Int8PtrTy, Int8PtrTy,
|
||||
MethodListnfABIPtrTy, ProtocolListnfABIPtrTy, IvarListnfABIPtrTy,
|
||||
Int8PtrTy, PropertyListPtrTy);
|
||||
|
||||
// ImpnfABITy - LLVM for id (*)(id, SEL, ...)
|
||||
llvm::Type *params[] = { ObjectPtrTy, SelectorPtrTy };
|
||||
@ -5835,11 +5804,9 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul
|
||||
|
||||
ClassnfABITy = llvm::StructType::create(VMContext, "struct._class_t");
|
||||
ClassnfABITy->setBody(llvm::PointerType::getUnqual(ClassnfABITy),
|
||||
llvm::PointerType::getUnqual(ClassnfABITy),
|
||||
CachePtrTy,
|
||||
llvm::PointerType::getUnqual(ClassnfABITy), CachePtrTy,
|
||||
llvm::PointerType::getUnqual(ImpnfABITy),
|
||||
llvm::PointerType::getUnqual(ClassRonfABITy),
|
||||
nullptr);
|
||||
llvm::PointerType::getUnqual(ClassRonfABITy));
|
||||
|
||||
// LLVM for struct _class_t *
|
||||
ClassnfABIPtrTy = llvm::PointerType::getUnqual(ClassnfABITy);
|
||||
@ -5854,15 +5821,10 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul
|
||||
// const struct _prop_list_t * const class_properties;
|
||||
// const uint32_t size;
|
||||
// }
|
||||
CategorynfABITy = llvm::StructType::create("struct._category_t",
|
||||
Int8PtrTy, ClassnfABIPtrTy,
|
||||
MethodListnfABIPtrTy,
|
||||
MethodListnfABIPtrTy,
|
||||
ProtocolListnfABIPtrTy,
|
||||
PropertyListPtrTy,
|
||||
PropertyListPtrTy,
|
||||
IntTy,
|
||||
nullptr);
|
||||
CategorynfABITy = llvm::StructType::create(
|
||||
"struct._category_t", Int8PtrTy, ClassnfABIPtrTy, MethodListnfABIPtrTy,
|
||||
MethodListnfABIPtrTy, ProtocolListnfABIPtrTy, PropertyListPtrTy,
|
||||
PropertyListPtrTy, IntTy);
|
||||
|
||||
// New types for nonfragile abi messaging.
|
||||
CodeGen::CodeGenTypes &Types = CGM.getTypes();
|
||||
@ -5899,9 +5861,8 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul
|
||||
// SUPER_IMP messenger;
|
||||
// SEL name;
|
||||
// };
|
||||
SuperMessageRefTy =
|
||||
llvm::StructType::create("struct._super_message_ref_t",
|
||||
ImpnfABITy, SelectorPtrTy, nullptr);
|
||||
SuperMessageRefTy = llvm::StructType::create("struct._super_message_ref_t",
|
||||
ImpnfABITy, SelectorPtrTy);
|
||||
|
||||
// SuperMessageRefPtrTy - LLVM for struct _super_message_ref_t*
|
||||
SuperMessageRefPtrTy = llvm::PointerType::getUnqual(SuperMessageRefTy);
|
||||
@ -5912,10 +5873,9 @@ ObjCNonFragileABITypesHelper::ObjCNonFragileABITypesHelper(CodeGen::CodeGenModul
|
||||
// const char* name; // c++ typeinfo string
|
||||
// Class cls;
|
||||
// };
|
||||
EHTypeTy =
|
||||
llvm::StructType::create("struct._objc_typeinfo",
|
||||
llvm::PointerType::getUnqual(Int8PtrTy),
|
||||
Int8PtrTy, ClassnfABIPtrTy, nullptr);
|
||||
EHTypeTy = llvm::StructType::create("struct._objc_typeinfo",
|
||||
llvm::PointerType::getUnqual(Int8PtrTy),
|
||||
Int8PtrTy, ClassnfABIPtrTy);
|
||||
EHTypePtrTy = llvm::PointerType::getUnqual(EHTypeTy);
|
||||
}
|
||||
|
||||
|
@ -728,7 +728,7 @@ CGOpenMPRuntime::CGOpenMPRuntime(CodeGenModule &CGM)
|
||||
IdentTy = llvm::StructType::create(
|
||||
"ident_t", CGM.Int32Ty /* reserved_1 */, CGM.Int32Ty /* flags */,
|
||||
CGM.Int32Ty /* reserved_2 */, CGM.Int32Ty /* reserved_3 */,
|
||||
CGM.Int8PtrTy /* psource */, nullptr);
|
||||
CGM.Int8PtrTy /* psource */);
|
||||
KmpCriticalNameTy = llvm::ArrayType::get(CGM.Int32Ty, /*NumElements*/ 8);
|
||||
|
||||
loadOffloadInfoMetadata();
|
||||
|
@ -751,7 +751,7 @@ void CodeGenModule::EmitCtorList(CtorList &Fns, const char *GlobalName) {
|
||||
|
||||
// Get the type of a ctor entry, { i32, void ()*, i8* }.
|
||||
llvm::StructType *CtorStructTy = llvm::StructType::get(
|
||||
Int32Ty, llvm::PointerType::getUnqual(CtorFTy), VoidPtrTy, nullptr);
|
||||
Int32Ty, llvm::PointerType::getUnqual(CtorFTy), VoidPtrTy);
|
||||
|
||||
// Construct the constructor and destructor arrays.
|
||||
ConstantInitBuilder builder(*this);
|
||||
|
@ -490,7 +490,7 @@ llvm::Type *CodeGenTypes::ConvertType(QualType T) {
|
||||
llvm_unreachable("Unexpected undeduced type!");
|
||||
case Type::Complex: {
|
||||
llvm::Type *EltTy = ConvertType(cast<ComplexType>(Ty)->getElementType());
|
||||
ResultType = llvm::StructType::get(EltTy, EltTy, nullptr);
|
||||
ResultType = llvm::StructType::get(EltTy, EltTy);
|
||||
break;
|
||||
}
|
||||
case Type::LValueReference:
|
||||
|
@ -499,7 +499,7 @@ llvm::Type *
|
||||
ItaniumCXXABI::ConvertMemberPointerType(const MemberPointerType *MPT) {
|
||||
if (MPT->isMemberDataPointer())
|
||||
return CGM.PtrDiffTy;
|
||||
return llvm::StructType::get(CGM.PtrDiffTy, CGM.PtrDiffTy, nullptr);
|
||||
return llvm::StructType::get(CGM.PtrDiffTy, CGM.PtrDiffTy);
|
||||
}
|
||||
|
||||
/// In the Itanium and ARM ABIs, method pointers have the form:
|
||||
|
@ -3159,8 +3159,7 @@ GetX86_64ByValArgumentPair(llvm::Type *Lo, llvm::Type *Hi,
|
||||
}
|
||||
}
|
||||
|
||||
llvm::StructType *Result = llvm::StructType::get(Lo, Hi, nullptr);
|
||||
|
||||
llvm::StructType *Result = llvm::StructType::get(Lo, Hi);
|
||||
|
||||
// Verify that the second element is at an 8-byte offset.
|
||||
assert(TD.getStructLayout(Result)->getElementOffset(1) == 8 &&
|
||||
@ -3235,8 +3234,7 @@ classifyReturnType(QualType RetTy) const {
|
||||
case ComplexX87:
|
||||
assert(Hi == ComplexX87 && "Unexpected ComplexX87 classification.");
|
||||
ResType = llvm::StructType::get(llvm::Type::getX86_FP80Ty(getVMContext()),
|
||||
llvm::Type::getX86_FP80Ty(getVMContext()),
|
||||
nullptr);
|
||||
llvm::Type::getX86_FP80Ty(getVMContext()));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -3732,7 +3730,7 @@ Address X86_64ABIInfo::EmitVAArg(CodeGenFunction &CGF, Address VAListAddr,
|
||||
CGF.Builder.CreateConstInBoundsByteGEP(RegAddrLo,
|
||||
CharUnits::fromQuantity(16));
|
||||
llvm::Type *DoubleTy = CGF.DoubleTy;
|
||||
llvm::StructType *ST = llvm::StructType::get(DoubleTy, DoubleTy, nullptr);
|
||||
llvm::StructType *ST = llvm::StructType::get(DoubleTy, DoubleTy);
|
||||
llvm::Value *V;
|
||||
Address Tmp = CGF.CreateMemTemp(Ty);
|
||||
Tmp = CGF.Builder.CreateElementBitCast(Tmp, ST);
|
||||
@ -4637,7 +4635,7 @@ PPC64_SVR4_ABIInfo::classifyReturnType(QualType RetTy) const {
|
||||
llvm::Type *CoerceTy;
|
||||
if (Bits > GPRBits) {
|
||||
CoerceTy = llvm::IntegerType::get(getVMContext(), GPRBits);
|
||||
CoerceTy = llvm::StructType::get(CoerceTy, CoerceTy, nullptr);
|
||||
CoerceTy = llvm::StructType::get(CoerceTy, CoerceTy);
|
||||
} else
|
||||
CoerceTy =
|
||||
llvm::IntegerType::get(getVMContext(), llvm::alignTo(Bits, 8));
|
||||
|
@ -233,19 +233,16 @@ void NilArgChecker::checkPreObjCMessage(const ObjCMethodCall &msg,
|
||||
if (StringSelectors.empty()) {
|
||||
ASTContext &Ctx = C.getASTContext();
|
||||
Selector Sels[] = {
|
||||
getKeywordSelector(Ctx, "caseInsensitiveCompare", nullptr),
|
||||
getKeywordSelector(Ctx, "compare", nullptr),
|
||||
getKeywordSelector(Ctx, "compare", "options", nullptr),
|
||||
getKeywordSelector(Ctx, "compare", "options", "range", nullptr),
|
||||
getKeywordSelector(Ctx, "compare", "options", "range", "locale",
|
||||
nullptr),
|
||||
getKeywordSelector(Ctx, "componentsSeparatedByCharactersInSet",
|
||||
nullptr),
|
||||
getKeywordSelector(Ctx, "initWithFormat",
|
||||
nullptr),
|
||||
getKeywordSelector(Ctx, "localizedCaseInsensitiveCompare", nullptr),
|
||||
getKeywordSelector(Ctx, "localizedCompare", nullptr),
|
||||
getKeywordSelector(Ctx, "localizedStandardCompare", nullptr),
|
||||
getKeywordSelector(Ctx, "caseInsensitiveCompare"),
|
||||
getKeywordSelector(Ctx, "compare"),
|
||||
getKeywordSelector(Ctx, "compare", "options"),
|
||||
getKeywordSelector(Ctx, "compare", "options", "range"),
|
||||
getKeywordSelector(Ctx, "compare", "options", "range", "locale"),
|
||||
getKeywordSelector(Ctx, "componentsSeparatedByCharactersInSet"),
|
||||
getKeywordSelector(Ctx, "initWithFormat"),
|
||||
getKeywordSelector(Ctx, "localizedCaseInsensitiveCompare"),
|
||||
getKeywordSelector(Ctx, "localizedCompare"),
|
||||
getKeywordSelector(Ctx, "localizedStandardCompare"),
|
||||
};
|
||||
for (Selector KnownSel : Sels)
|
||||
StringSelectors[KnownSel] = 0;
|
||||
@ -262,16 +259,15 @@ void NilArgChecker::checkPreObjCMessage(const ObjCMethodCall &msg,
|
||||
|
||||
if (ArrayWithObjectSel.isNull()) {
|
||||
ASTContext &Ctx = C.getASTContext();
|
||||
ArrayWithObjectSel = getKeywordSelector(Ctx, "arrayWithObject", nullptr);
|
||||
AddObjectSel = getKeywordSelector(Ctx, "addObject", nullptr);
|
||||
ArrayWithObjectSel = getKeywordSelector(Ctx, "arrayWithObject");
|
||||
AddObjectSel = getKeywordSelector(Ctx, "addObject");
|
||||
InsertObjectAtIndexSel =
|
||||
getKeywordSelector(Ctx, "insertObject", "atIndex", nullptr);
|
||||
getKeywordSelector(Ctx, "insertObject", "atIndex");
|
||||
ReplaceObjectAtIndexWithObjectSel =
|
||||
getKeywordSelector(Ctx, "replaceObjectAtIndex", "withObject", nullptr);
|
||||
getKeywordSelector(Ctx, "replaceObjectAtIndex", "withObject");
|
||||
SetObjectAtIndexedSubscriptSel =
|
||||
getKeywordSelector(Ctx, "setObject", "atIndexedSubscript", nullptr);
|
||||
ArrayByAddingObjectSel =
|
||||
getKeywordSelector(Ctx, "arrayByAddingObject", nullptr);
|
||||
getKeywordSelector(Ctx, "setObject", "atIndexedSubscript");
|
||||
ArrayByAddingObjectSel = getKeywordSelector(Ctx, "arrayByAddingObject");
|
||||
}
|
||||
|
||||
if (S == ArrayWithObjectSel || S == AddObjectSel ||
|
||||
@ -292,13 +288,11 @@ void NilArgChecker::checkPreObjCMessage(const ObjCMethodCall &msg,
|
||||
if (DictionaryWithObjectForKeySel.isNull()) {
|
||||
ASTContext &Ctx = C.getASTContext();
|
||||
DictionaryWithObjectForKeySel =
|
||||
getKeywordSelector(Ctx, "dictionaryWithObject", "forKey", nullptr);
|
||||
SetObjectForKeySel =
|
||||
getKeywordSelector(Ctx, "setObject", "forKey", nullptr);
|
||||
getKeywordSelector(Ctx, "dictionaryWithObject", "forKey");
|
||||
SetObjectForKeySel = getKeywordSelector(Ctx, "setObject", "forKey");
|
||||
SetObjectForKeyedSubscriptSel =
|
||||
getKeywordSelector(Ctx, "setObject", "forKeyedSubscript", nullptr);
|
||||
RemoveObjectForKeySel =
|
||||
getKeywordSelector(Ctx, "removeObjectForKey", nullptr);
|
||||
getKeywordSelector(Ctx, "setObject", "forKeyedSubscript");
|
||||
RemoveObjectForKeySel = getKeywordSelector(Ctx, "removeObjectForKey");
|
||||
}
|
||||
|
||||
if (S == DictionaryWithObjectForKeySel || S == SetObjectForKeySel) {
|
||||
|
@ -123,14 +123,14 @@ void NoReturnFunctionChecker::checkPostObjCMessage(const ObjCMethodCall &Msg,
|
||||
case 4:
|
||||
lazyInitKeywordSelector(HandleFailureInFunctionSel, C.getASTContext(),
|
||||
"handleFailureInFunction", "file", "lineNumber",
|
||||
"description", nullptr);
|
||||
"description");
|
||||
if (Sel != HandleFailureInFunctionSel)
|
||||
return;
|
||||
break;
|
||||
case 5:
|
||||
lazyInitKeywordSelector(HandleFailureInMethodSel, C.getASTContext(),
|
||||
"handleFailureInMethod", "object", "file",
|
||||
"lineNumber", "description", nullptr);
|
||||
"lineNumber", "description");
|
||||
if (Sel != HandleFailureInMethodSel)
|
||||
return;
|
||||
break;
|
||||
|
@ -703,31 +703,30 @@ private:
|
||||
ObjCMethodSummaries[ObjCSummaryKey(ClsII, S)] = Summ;
|
||||
}
|
||||
|
||||
template <typename... Keywords>
|
||||
void addMethodSummary(IdentifierInfo *ClsII, ObjCMethodSummariesTy &Summaries,
|
||||
const RetainSummary *Summ, va_list argp) {
|
||||
Selector S = getKeywordSelector(Ctx, argp);
|
||||
const RetainSummary *Summ, Keywords *... Kws) {
|
||||
Selector S = getKeywordSelector(Ctx, Kws...);
|
||||
Summaries[ObjCSummaryKey(ClsII, S)] = Summ;
|
||||
}
|
||||
|
||||
void addInstMethSummary(const char* Cls, const RetainSummary * Summ, ...) {
|
||||
va_list argp;
|
||||
va_start(argp, Summ);
|
||||
addMethodSummary(&Ctx.Idents.get(Cls), ObjCMethodSummaries, Summ, argp);
|
||||
va_end(argp);
|
||||
template <typename... Keywords>
|
||||
void addInstMethSummary(const char *Cls, const RetainSummary *Summ,
|
||||
Keywords *... Kws) {
|
||||
addMethodSummary(&Ctx.Idents.get(Cls), ObjCMethodSummaries, Summ, Kws...);
|
||||
}
|
||||
|
||||
void addClsMethSummary(const char* Cls, const RetainSummary * Summ, ...) {
|
||||
va_list argp;
|
||||
va_start(argp, Summ);
|
||||
addMethodSummary(&Ctx.Idents.get(Cls),ObjCClassMethodSummaries, Summ, argp);
|
||||
va_end(argp);
|
||||
template <typename... Keywords>
|
||||
void addClsMethSummary(const char *Cls, const RetainSummary *Summ,
|
||||
Keywords *... Kws) {
|
||||
addMethodSummary(&Ctx.Idents.get(Cls), ObjCClassMethodSummaries, Summ,
|
||||
Kws...);
|
||||
}
|
||||
|
||||
void addClsMethSummary(IdentifierInfo *II, const RetainSummary * Summ, ...) {
|
||||
va_list argp;
|
||||
va_start(argp, Summ);
|
||||
addMethodSummary(II, ObjCClassMethodSummaries, Summ, argp);
|
||||
va_end(argp);
|
||||
template <typename... Keywords>
|
||||
void addClsMethSummary(IdentifierInfo *II, const RetainSummary *Summ,
|
||||
Keywords *... Kws) {
|
||||
addMethodSummary(II, ObjCClassMethodSummaries, Summ, Kws...);
|
||||
}
|
||||
|
||||
public:
|
||||
@ -1640,20 +1639,16 @@ void RetainSummaryManager::InitializeMethodSummaries() {
|
||||
addClassMethSummary("NSAutoreleasePool", "new", NoTrackYet);
|
||||
|
||||
// Create summaries QCRenderer/QCView -createSnapShotImageOfType:
|
||||
addInstMethSummary("QCRenderer", AllocSumm,
|
||||
"createSnapshotImageOfType", nullptr);
|
||||
addInstMethSummary("QCView", AllocSumm,
|
||||
"createSnapshotImageOfType", nullptr);
|
||||
addInstMethSummary("QCRenderer", AllocSumm, "createSnapshotImageOfType");
|
||||
addInstMethSummary("QCView", AllocSumm, "createSnapshotImageOfType");
|
||||
|
||||
// Create summaries for CIContext, 'createCGImage' and
|
||||
// 'createCGLayerWithSize'. These objects are CF objects, and are not
|
||||
// automatically garbage collected.
|
||||
addInstMethSummary("CIContext", CFAllocSumm,
|
||||
"createCGImage", "fromRect", nullptr);
|
||||
addInstMethSummary("CIContext", CFAllocSumm, "createCGImage", "fromRect");
|
||||
addInstMethSummary("CIContext", CFAllocSumm, "createCGImage", "fromRect",
|
||||
"format", "colorSpace", nullptr);
|
||||
addInstMethSummary("CIContext", CFAllocSumm, "createCGLayerWithSize", "info",
|
||||
nullptr);
|
||||
"format", "colorSpace");
|
||||
addInstMethSummary("CIContext", CFAllocSumm, "createCGLayerWithSize", "info");
|
||||
}
|
||||
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
@ -11,48 +11,26 @@
|
||||
#define LLVM_CLANG_LIB_STATICANALYZER_CHECKERS_SELECTOREXTRAS_H
|
||||
|
||||
#include "clang/AST/ASTContext.h"
|
||||
#include <cstdarg>
|
||||
|
||||
namespace clang {
|
||||
namespace ento {
|
||||
|
||||
static inline Selector getKeywordSelectorImpl(ASTContext &Ctx,
|
||||
const char *First,
|
||||
va_list argp) {
|
||||
SmallVector<IdentifierInfo*, 10> II;
|
||||
II.push_back(&Ctx.Idents.get(First));
|
||||
|
||||
while (const char *s = va_arg(argp, const char *))
|
||||
II.push_back(&Ctx.Idents.get(s));
|
||||
template <typename... IdentifierInfos>
|
||||
static inline Selector getKeywordSelector(ASTContext &Ctx,
|
||||
IdentifierInfos *... IIs) {
|
||||
static_assert(sizeof...(IdentifierInfos),
|
||||
"keyword selectors must have at least one argument");
|
||||
SmallVector<IdentifierInfo *, 10> II{{&Ctx.Idents.get(IIs)...}};
|
||||
|
||||
return Ctx.Selectors.getSelector(II.size(), &II[0]);
|
||||
}
|
||||
|
||||
static inline Selector getKeywordSelector(ASTContext &Ctx, va_list argp) {
|
||||
const char *First = va_arg(argp, const char *);
|
||||
assert(First && "keyword selectors must have at least one argument");
|
||||
return getKeywordSelectorImpl(Ctx, First, argp);
|
||||
}
|
||||
|
||||
LLVM_END_WITH_NULL
|
||||
static inline Selector getKeywordSelector(ASTContext &Ctx,
|
||||
const char *First, ...) {
|
||||
va_list argp;
|
||||
va_start(argp, First);
|
||||
Selector result = getKeywordSelectorImpl(Ctx, First, argp);
|
||||
va_end(argp);
|
||||
return result;
|
||||
}
|
||||
|
||||
LLVM_END_WITH_NULL
|
||||
template <typename... IdentifierInfos>
|
||||
static inline void lazyInitKeywordSelector(Selector &Sel, ASTContext &Ctx,
|
||||
const char *First, ...) {
|
||||
IdentifierInfos *... IIs) {
|
||||
if (!Sel.isNull())
|
||||
return;
|
||||
va_list argp;
|
||||
va_start(argp, First);
|
||||
Sel = getKeywordSelectorImpl(Ctx, First, argp);
|
||||
va_end(argp);
|
||||
Sel = getKeywordSelector(Ctx, IIs...);
|
||||
}
|
||||
|
||||
static inline void lazyInitNullarySelector(Selector &Sel, ASTContext &Ctx,
|
||||
|
Loading…
x
Reference in New Issue
Block a user