]> granicus.if.org Git - clang/commitdiff
[opaque pointer type] Fix a few uses of PointerType::getElementType in favor of uses...
authorDavid Blaikie <dblaikie@gmail.com>
Mon, 14 Sep 2015 18:38:22 +0000 (18:38 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Mon, 14 Sep 2015 18:38:22 +0000 (18:38 +0000)
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.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@247593 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGCXX.cpp
lib/CodeGen/CodeGenModule.cpp
lib/CodeGen/ItaniumCXXABI.cpp
lib/CodeGen/MicrosoftCXXABI.cpp

index 0314b7c619a0bd8bf47473a38c98865911661421..592b74f190970e5c8d6115653123a73a543a5f30 100644 (file)
@@ -151,8 +151,8 @@ bool CodeGenModule::TryEmitDefinitionAsAlias(GlobalDecl AliasDecl,
     return false;
 
   // Derive the type for the alias.
-  llvm::PointerType *AliasType
-    = getTypes().GetFunctionType(AliasDecl)->getPointerTo();
+  llvm::Type *AliasValueType = getTypes().GetFunctionType(AliasDecl);
+  llvm::PointerType *AliasType = AliasValueType->getPointerTo();
 
   // Find the referent.  Some aliases might require a bitcast, in
   // which case the caller is responsible for ensuring the soundness
@@ -185,8 +185,8 @@ bool CodeGenModule::TryEmitDefinitionAsAlias(GlobalDecl AliasDecl,
     return true;
 
   // Create the alias with no name.
-  auto *Alias = llvm::GlobalAlias::create(AliasType->getElementType(), 0,
-                                          Linkage, "", Aliasee, &getModule());
+  auto *Alias = llvm::GlobalAlias::create(AliasValueType, 0, Linkage, "",
+                                          Aliasee, &getModule());
 
   // Switch any previous uses to the alias.
   if (Entry) {
index ea420229c74ff37eaeb0601582f2a80c93ee6ea7..737c49baa1a1d7c855ee2591bcc2562a5393fda8 100644 (file)
@@ -2772,8 +2772,7 @@ void CodeGenModule::EmitAliasDefinition(GlobalDecl GD) {
 
   // Create the new alias itself, but don't set a name yet.
   auto *GA = llvm::GlobalAlias::create(
-      cast<llvm::PointerType>(Aliasee->getType())->getElementType(), 0,
-      llvm::Function::ExternalLinkage, "", Aliasee, &getModule());
+      DeclTy, 0, llvm::Function::ExternalLinkage, "", Aliasee, &getModule());
 
   if (Entry) {
     if (GA->getAliasee() == Entry) {
index 0b69ff6c18f1165b5238e9b4c844776739905232..85f0ec44852d15d5f16834e7f919eee3003da3a7 100644 (file)
@@ -3354,8 +3354,7 @@ static void emitConstructorDestructorAlias(CodeGenModule &CGM,
   llvm::PointerType *AliasType = Aliasee->getType();
 
   // Create the alias with no name.
-  auto *Alias = llvm::GlobalAlias::create(
-      AliasType->getElementType(), 0, Linkage, "", Aliasee, &CGM.getModule());
+  auto *Alias = llvm::GlobalAlias::create(Linkage, "", Aliasee);
 
   // Switch any previous uses to the alias.
   if (Entry) {
index 172ddda50c8677f8018cf3dfcb0416eba8716780..804afd81a96ef9c72efc6b6e36d8cc0b02e823d3 100644 (file)
@@ -1733,10 +1733,10 @@ llvm::GlobalVariable *MicrosoftCXXABI::getAddrOfVTable(const CXXRecordDecl *RD,
       if (C)
         C->setSelectionKind(llvm::Comdat::Largest);
     }
-    VFTable = llvm::GlobalAlias::create(
-        cast<llvm::SequentialType>(VTableGEP->getType())->getElementType(),
-        /*AddressSpace=*/0, VFTableLinkage, VFTableName.str(), VTableGEP,
-        &CGM.getModule());
+    VFTable = llvm::GlobalAlias::create(CGM.Int8PtrTy,
+                                        /*AddressSpace=*/0, VFTableLinkage,
+                                        VFTableName.str(), VTableGEP,
+                                        &CGM.getModule());
     VFTable->setUnnamedAddr(true);
   } else {
     // We don't need a GlobalAlias to be a symbol for the VTable if we won't