[opaque pointer type] Fix a few uses of PointerType::getElementType in favor of uses of types already available elsewhere

These are a few cleanups I happened to have from trying to go in a
different direction recently, so just flushing them out while I have
them.

llvm-svn: 247593
This commit is contained in:
David Blaikie 2015-09-14 18:38:22 +00:00
parent de9588e049
commit 2a791d7d21
4 changed files with 10 additions and 12 deletions

View File

@ -151,8 +151,8 @@ bool CodeGenModule::TryEmitDefinitionAsAlias(GlobalDecl AliasDecl,
return false; return false;
// Derive the type for the alias. // Derive the type for the alias.
llvm::PointerType *AliasType llvm::Type *AliasValueType = getTypes().GetFunctionType(AliasDecl);
= getTypes().GetFunctionType(AliasDecl)->getPointerTo(); llvm::PointerType *AliasType = AliasValueType->getPointerTo();
// Find the referent. Some aliases might require a bitcast, in // Find the referent. Some aliases might require a bitcast, in
// which case the caller is responsible for ensuring the soundness // which case the caller is responsible for ensuring the soundness
@ -185,8 +185,8 @@ bool CodeGenModule::TryEmitDefinitionAsAlias(GlobalDecl AliasDecl,
return true; return true;
// Create the alias with no name. // Create the alias with no name.
auto *Alias = llvm::GlobalAlias::create(AliasType->getElementType(), 0, auto *Alias = llvm::GlobalAlias::create(AliasValueType, 0, Linkage, "",
Linkage, "", Aliasee, &getModule()); Aliasee, &getModule());
// Switch any previous uses to the alias. // Switch any previous uses to the alias.
if (Entry) { if (Entry) {

View File

@ -2772,8 +2772,7 @@ void CodeGenModule::EmitAliasDefinition(GlobalDecl GD) {
// Create the new alias itself, but don't set a name yet. // Create the new alias itself, but don't set a name yet.
auto *GA = llvm::GlobalAlias::create( auto *GA = llvm::GlobalAlias::create(
cast<llvm::PointerType>(Aliasee->getType())->getElementType(), 0, DeclTy, 0, llvm::Function::ExternalLinkage, "", Aliasee, &getModule());
llvm::Function::ExternalLinkage, "", Aliasee, &getModule());
if (Entry) { if (Entry) {
if (GA->getAliasee() == Entry) { if (GA->getAliasee() == Entry) {

View File

@ -3354,8 +3354,7 @@ static void emitConstructorDestructorAlias(CodeGenModule &CGM,
llvm::PointerType *AliasType = Aliasee->getType(); llvm::PointerType *AliasType = Aliasee->getType();
// Create the alias with no name. // Create the alias with no name.
auto *Alias = llvm::GlobalAlias::create( auto *Alias = llvm::GlobalAlias::create(Linkage, "", Aliasee);
AliasType->getElementType(), 0, Linkage, "", Aliasee, &CGM.getModule());
// Switch any previous uses to the alias. // Switch any previous uses to the alias.
if (Entry) { if (Entry) {

View File

@ -1733,10 +1733,10 @@ llvm::GlobalVariable *MicrosoftCXXABI::getAddrOfVTable(const CXXRecordDecl *RD,
if (C) if (C)
C->setSelectionKind(llvm::Comdat::Largest); C->setSelectionKind(llvm::Comdat::Largest);
} }
VFTable = llvm::GlobalAlias::create( VFTable = llvm::GlobalAlias::create(CGM.Int8PtrTy,
cast<llvm::SequentialType>(VTableGEP->getType())->getElementType(), /*AddressSpace=*/0, VFTableLinkage,
/*AddressSpace=*/0, VFTableLinkage, VFTableName.str(), VTableGEP, VFTableName.str(), VTableGEP,
&CGM.getModule()); &CGM.getModule());
VFTable->setUnnamedAddr(true); VFTable->setUnnamedAddr(true);
} else { } else {
// We don't need a GlobalAlias to be a symbol for the VTable if we won't // We don't need a GlobalAlias to be a symbol for the VTable if we won't