simplify a bunch of code to use the well-known LLVM IR types computed by CodeGenModule.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149943 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGRTTI.cpp b/lib/CodeGen/CGRTTI.cpp
index 2091892..a8c4ac4 100644
--- a/lib/CodeGen/CGRTTI.cpp
+++ b/lib/CodeGen/CGRTTI.cpp
@@ -26,8 +26,6 @@
   CodeGenModule &CGM;  // Per-module state.
   llvm::LLVMContext &VMContext;
   
-  llvm::Type *Int8PtrTy;
-  
   /// Fields - The fields of the RTTI descriptor currently being built.
   SmallVector<llvm::Constant *, 16> Fields;
 
@@ -65,8 +63,7 @@
   
 public:
   RTTIBuilder(CodeGenModule &CGM) : CGM(CGM), 
-    VMContext(CGM.getModule().getContext()),
-    Int8PtrTy(llvm::Type::getInt8PtrTy(VMContext)) { }
+    VMContext(CGM.getModule().getContext()) { }
 
   // Pointer type info flags.
   enum {
@@ -149,11 +146,12 @@
   
   if (!GV) {
     // Create a new global variable.
-    GV = new llvm::GlobalVariable(CGM.getModule(), Int8PtrTy, /*Constant=*/true,
+    GV = new llvm::GlobalVariable(CGM.getModule(), CGM.Int8PtrTy,
+                                  /*Constant=*/true,
                                   llvm::GlobalValue::ExternalLinkage, 0, Name);
   }
   
-  return llvm::ConstantExpr::getBitCast(GV, Int8PtrTy);
+  return llvm::ConstantExpr::getBitCast(GV, CGM.Int8PtrTy);
 }
 
 /// TypeInfoIsInStandardLibrary - Given a builtin type, returns whether the type
@@ -482,7 +480,7 @@
   }
 
   llvm::Constant *VTable = 
-    CGM.getModule().getOrInsertGlobal(VTableName, Int8PtrTy);
+    CGM.getModule().getOrInsertGlobal(VTableName, CGM.Int8PtrTy);
     
   llvm::Type *PtrDiffTy = 
     CGM.getTypes().ConvertType(CGM.getContext().getPointerDiffType());
@@ -490,7 +488,7 @@
   // The vtable address point is 2.
   llvm::Constant *Two = llvm::ConstantInt::get(PtrDiffTy, 2);
   VTable = llvm::ConstantExpr::getInBoundsGetElementPtr(VTable, Two);
-  VTable = llvm::ConstantExpr::getBitCast(VTable, Int8PtrTy);
+  VTable = llvm::ConstantExpr::getBitCast(VTable, CGM.Int8PtrTy);
 
   Fields.push_back(VTable);
 }
@@ -564,7 +562,7 @@
   if (OldGV && !OldGV->isDeclaration()) {
     maybeUpdateRTTILinkage(CGM, OldGV, Ty);
 
-    return llvm::ConstantExpr::getBitCast(OldGV, Int8PtrTy);
+    return llvm::ConstantExpr::getBitCast(OldGV, CGM.Int8PtrTy);
   }
 
   // Check if there is already an external RTTI descriptor for this type.
@@ -585,8 +583,7 @@
   // And the name.
   llvm::GlobalVariable *TypeName = GetAddrOfTypeName(Ty, Linkage);
 
-  llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(VMContext);
-  Fields.push_back(llvm::ConstantExpr::getBitCast(TypeName, Int8PtrTy));
+  Fields.push_back(llvm::ConstantExpr::getBitCast(TypeName, CGM.Int8PtrTy));
 
   switch (Ty->getTypeClass()) {
 #define TYPE(Class, Base)
@@ -708,7 +705,7 @@
 
   GV->setUnnamedAddr(true);
 
-  return llvm::ConstantExpr::getBitCast(GV, Int8PtrTy);
+  return llvm::ConstantExpr::getBitCast(GV, CGM.Int8PtrTy);
 }
 
 /// ComputeQualifierFlags - Compute the pointer type info flags from the
@@ -985,14 +982,11 @@
   // Return a bogus pointer if RTTI is disabled, unless it's for EH.
   // FIXME: should we even be calling this method if RTTI is disabled
   // and it's not for EH?
-  if (!ForEH && !getContext().getLangOptions().RTTI) {
-    llvm::Type *Int8PtrTy = llvm::Type::getInt8PtrTy(VMContext);
+  if (!ForEH && !getContext().getLangOptions().RTTI)
     return llvm::Constant::getNullValue(Int8PtrTy);
-  }
   
-  if (ForEH && Ty->isObjCObjectPointerType() && !Features.NeXTRuntime) {
+  if (ForEH && Ty->isObjCObjectPointerType() && !Features.NeXTRuntime)
     return ObjCRuntime->GetEHType(Ty);
-  }
 
   return RTTIBuilder(*this).BuildTypeInfo(Ty);
 }