[clang][opaque pointers] Fix up a bunch of "getType()->getElementType()"
In contexts where we know an LLVM type is a pointer, there's generally some simpler way to get the pointee type.
This commit is contained in:
parent
3e5d671c19
commit
83fa811e5b
|
@ -1233,7 +1233,7 @@ static llvm::Value *CreateCoercedLoad(Address Src, llvm::Type *Ty,
|
|||
|
||||
if (llvm::StructType *SrcSTy = dyn_cast<llvm::StructType>(SrcTy)) {
|
||||
Src = EnterStructPointerForCoercedAccess(Src, SrcSTy, DstSize, CGF);
|
||||
SrcTy = Src.getType()->getElementType();
|
||||
SrcTy = Src.getElementType();
|
||||
}
|
||||
|
||||
uint64_t SrcSize = CGF.CGM.getDataLayout().getTypeAllocSize(SrcTy);
|
||||
|
@ -1299,7 +1299,7 @@ static void CreateCoercedStore(llvm::Value *Src,
|
|||
bool DstIsVolatile,
|
||||
CodeGenFunction &CGF) {
|
||||
llvm::Type *SrcTy = Src->getType();
|
||||
llvm::Type *DstTy = Dst.getType()->getElementType();
|
||||
llvm::Type *DstTy = Dst.getElementType();
|
||||
if (SrcTy == DstTy) {
|
||||
CGF.Builder.CreateStore(Src, Dst, DstIsVolatile);
|
||||
return;
|
||||
|
@ -1309,7 +1309,7 @@ static void CreateCoercedStore(llvm::Value *Src,
|
|||
|
||||
if (llvm::StructType *DstSTy = dyn_cast<llvm::StructType>(DstTy)) {
|
||||
Dst = EnterStructPointerForCoercedAccess(Dst, DstSTy, SrcSize, CGF);
|
||||
DstTy = Dst.getType()->getElementType();
|
||||
DstTy = Dst.getElementType();
|
||||
}
|
||||
|
||||
llvm::PointerType *SrcPtrTy = llvm::dyn_cast<llvm::PointerType>(SrcTy);
|
||||
|
@ -4304,7 +4304,7 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo,
|
|||
llvm::StructType *STy =
|
||||
dyn_cast<llvm::StructType>(ArgInfo.getCoerceToType());
|
||||
if (STy && ArgInfo.isDirect() && ArgInfo.getCanBeFlattened()) {
|
||||
llvm::Type *SrcTy = Src.getType()->getElementType();
|
||||
llvm::Type *SrcTy = Src.getElementType();
|
||||
uint64_t SrcSize = CGM.getDataLayout().getTypeAllocSize(SrcTy);
|
||||
uint64_t DstSize = CGM.getDataLayout().getTypeAllocSize(STy);
|
||||
|
||||
|
|
|
@ -341,7 +341,7 @@ CodeGenFunction::AddInitializerToStaticVarDecl(const VarDecl &D,
|
|||
// the global to match the initializer. (We have to do this
|
||||
// because some types, like unions, can't be completely represented
|
||||
// in the LLVM type system.)
|
||||
if (GV->getType()->getElementType() != Init->getType()) {
|
||||
if (GV->getValueType() != Init->getType()) {
|
||||
llvm::GlobalVariable *OldGV = GV;
|
||||
|
||||
GV = new llvm::GlobalVariable(CGM.getModule(), Init->getType(),
|
||||
|
|
|
@ -3634,7 +3634,7 @@ void CGObjCMac::GenerateClass(const ObjCImplementationDecl *ID) {
|
|||
// Check for a forward reference.
|
||||
llvm::GlobalVariable *GV = CGM.getModule().getGlobalVariable(Name, true);
|
||||
if (GV) {
|
||||
assert(GV->getType()->getElementType() == ObjCTypes.ClassTy &&
|
||||
assert(GV->getValueType() == ObjCTypes.ClassTy &&
|
||||
"Forward metaclass reference has incorrect type.");
|
||||
values.finishAndSetAsInitializer(GV);
|
||||
GV->setSection(Section);
|
||||
|
@ -3697,7 +3697,7 @@ llvm::Constant *CGObjCMac::EmitMetaClass(const ObjCImplementationDecl *ID,
|
|||
// Check for a forward reference.
|
||||
llvm::GlobalVariable *GV = CGM.getModule().getGlobalVariable(Name, true);
|
||||
if (GV) {
|
||||
assert(GV->getType()->getElementType() == ObjCTypes.ClassTy &&
|
||||
assert(GV->getValueType() == ObjCTypes.ClassTy &&
|
||||
"Forward metaclass reference has incorrect type.");
|
||||
values.finishAndSetAsInitializer(GV);
|
||||
} else {
|
||||
|
@ -3728,7 +3728,7 @@ llvm::Constant *CGObjCMac::EmitMetaClassRef(const ObjCInterfaceDecl *ID) {
|
|||
llvm::GlobalValue::PrivateLinkage, nullptr,
|
||||
Name);
|
||||
|
||||
assert(GV->getType()->getElementType() == ObjCTypes.ClassTy &&
|
||||
assert(GV->getValueType() == ObjCTypes.ClassTy &&
|
||||
"Forward metaclass reference has incorrect type.");
|
||||
return GV;
|
||||
}
|
||||
|
@ -3742,7 +3742,7 @@ llvm::Value *CGObjCMac::EmitSuperClassRef(const ObjCInterfaceDecl *ID) {
|
|||
llvm::GlobalValue::PrivateLinkage, nullptr,
|
||||
Name);
|
||||
|
||||
assert(GV->getType()->getElementType() == ObjCTypes.ClassTy &&
|
||||
assert(GV->getValueType() == ObjCTypes.ClassTy &&
|
||||
"Forward class metadata reference has incorrect type.");
|
||||
return GV;
|
||||
}
|
||||
|
|
|
@ -3176,7 +3176,7 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(
|
|||
}
|
||||
|
||||
if ((isa<llvm::Function>(Entry) || isa<llvm::GlobalAlias>(Entry)) &&
|
||||
(Entry->getType()->getElementType() == Ty)) {
|
||||
(Entry->getValueType() == Ty)) {
|
||||
return Entry;
|
||||
}
|
||||
|
||||
|
@ -3225,7 +3225,7 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(
|
|||
}
|
||||
|
||||
llvm::Constant *BC = llvm::ConstantExpr::getBitCast(
|
||||
F, Entry->getType()->getElementType()->getPointerTo());
|
||||
F, Entry->getValueType()->getPointerTo());
|
||||
addGlobalValReplacement(Entry, BC);
|
||||
}
|
||||
|
||||
|
@ -3284,7 +3284,7 @@ llvm::Constant *CodeGenModule::GetOrCreateLLVMFunction(
|
|||
|
||||
// Make sure the result is of the requested type.
|
||||
if (!IsIncompleteFunction) {
|
||||
assert(F->getType()->getElementType() == Ty);
|
||||
assert(F->getFunctionType() == Ty);
|
||||
return F;
|
||||
}
|
||||
|
||||
|
@ -3575,7 +3575,7 @@ CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
|
|||
llvm::Constant *Init = emitter.tryEmitForInitializer(*InitDecl);
|
||||
if (Init) {
|
||||
auto *InitType = Init->getType();
|
||||
if (GV->getType()->getElementType() != InitType) {
|
||||
if (GV->getValueType() != InitType) {
|
||||
// The type of the initializer does not match the definition.
|
||||
// This happens when an initializer has a different type from
|
||||
// the type of the global (because of padding at the end of a
|
||||
|
@ -3648,7 +3648,7 @@ llvm::GlobalVariable *CodeGenModule::CreateOrReplaceCXXRuntimeVariable(
|
|||
|
||||
if (GV) {
|
||||
// Check if the variable has the right type.
|
||||
if (GV->getType()->getElementType() == Ty)
|
||||
if (GV->getValueType() == Ty)
|
||||
return GV;
|
||||
|
||||
// Because C++ name mangling, the only way we can end up with an already
|
||||
|
@ -3992,7 +3992,7 @@ void CodeGenModule::EmitGlobalVarDefinition(const VarDecl *D,
|
|||
// "extern int x[];") and then a definition of a different type (e.g.
|
||||
// "int x[10];"). This also happens when an initializer has a different type
|
||||
// from the type of the global (this happens with unions).
|
||||
if (!GV || GV->getType()->getElementType() != InitType ||
|
||||
if (!GV || GV->getValueType() != InitType ||
|
||||
GV->getType()->getAddressSpace() !=
|
||||
getContext().getTargetAddressSpace(GetGlobalVarAddressSpace(D))) {
|
||||
|
||||
|
@ -4472,7 +4472,7 @@ void CodeGenModule::EmitGlobalFunctionDefinition(GlobalDecl GD,
|
|||
llvm::FunctionType *Ty = getTypes().GetFunctionType(FI);
|
||||
|
||||
// Get or create the prototype for the function.
|
||||
if (!GV || (GV->getType()->getElementType() != Ty))
|
||||
if (!GV || (GV->getValueType() != Ty))
|
||||
GV = cast<llvm::GlobalValue>(GetAddrOfFunction(GD, Ty, /*ForVTable=*/false,
|
||||
/*DontDefer=*/true,
|
||||
ForDefinition));
|
||||
|
|
Loading…
Reference in New Issue