forked from OSchip/llvm-project
Vtable -> VTable renames across the board.
llvm-svn: 101666
This commit is contained in:
parent
13bca6cd5a
commit
11e5140db9
|
@ -99,7 +99,7 @@ public:
|
|||
// elided if possible.
|
||||
unsigned CatchUndefined : 1; // Generate code to check for undefined ops.
|
||||
unsigned DumpRecordLayouts : 1; /// Dump the layout of IRgen'd records.
|
||||
unsigned DumpVtableLayouts : 1; /// Dump the layouts of emitted vtables.
|
||||
unsigned DumpVTableLayouts : 1; /// Dump the layouts of emitted vtables.
|
||||
|
||||
// FIXME: This is just a temporary option, for testing purposes.
|
||||
unsigned NoBitFieldTypeAlign : 1;
|
||||
|
@ -174,7 +174,7 @@ public:
|
|||
ShortWChar = 0;
|
||||
CatchUndefined = 0;
|
||||
DumpRecordLayouts = 0;
|
||||
DumpVtableLayouts = 0;
|
||||
DumpVTableLayouts = 0;
|
||||
NoBitFieldTypeAlign = 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -297,15 +297,15 @@ void CodeGenModule::getMangledCXXDtorName(MangleBuffer &Name,
|
|||
getMangleContext().mangleCXXDtor(D, Type, Name.getBuffer());
|
||||
}
|
||||
|
||||
static llvm::Value *BuildVirtualCall(CodeGenFunction &CGF, uint64_t VtableIndex,
|
||||
static llvm::Value *BuildVirtualCall(CodeGenFunction &CGF, uint64_t VTableIndex,
|
||||
llvm::Value *This, const llvm::Type *Ty) {
|
||||
Ty = Ty->getPointerTo()->getPointerTo()->getPointerTo();
|
||||
|
||||
llvm::Value *Vtable = CGF.Builder.CreateBitCast(This, Ty);
|
||||
Vtable = CGF.Builder.CreateLoad(Vtable);
|
||||
llvm::Value *VTable = CGF.Builder.CreateBitCast(This, Ty);
|
||||
VTable = CGF.Builder.CreateLoad(VTable);
|
||||
|
||||
llvm::Value *VFuncPtr =
|
||||
CGF.Builder.CreateConstInBoundsGEP1_64(Vtable, VtableIndex, "vfn");
|
||||
CGF.Builder.CreateConstInBoundsGEP1_64(VTable, VTableIndex, "vfn");
|
||||
return CGF.Builder.CreateLoad(VFuncPtr);
|
||||
}
|
||||
|
||||
|
@ -313,7 +313,7 @@ llvm::Value *
|
|||
CodeGenFunction::BuildVirtualCall(const CXXMethodDecl *MD, llvm::Value *This,
|
||||
const llvm::Type *Ty) {
|
||||
MD = MD->getCanonicalDecl();
|
||||
uint64_t VTableIndex = CGM.getVTables().getMethodVtableIndex(MD);
|
||||
uint64_t VTableIndex = CGM.getVTables().getMethodVTableIndex(MD);
|
||||
|
||||
return ::BuildVirtualCall(*this, VTableIndex, This, Ty);
|
||||
}
|
||||
|
@ -323,7 +323,7 @@ CodeGenFunction::BuildVirtualCall(const CXXDestructorDecl *DD, CXXDtorType Type,
|
|||
llvm::Value *&This, const llvm::Type *Ty) {
|
||||
DD = cast<CXXDestructorDecl>(DD->getCanonicalDecl());
|
||||
uint64_t VTableIndex =
|
||||
CGM.getVTables().getMethodVtableIndex(GlobalDecl(DD, Type));
|
||||
CGM.getVTables().getMethodVTableIndex(GlobalDecl(DD, Type));
|
||||
|
||||
return ::BuildVirtualCall(*this, VTableIndex, This, Ty);
|
||||
}
|
||||
|
|
|
@ -528,7 +528,7 @@ static bool HasIncompleteReturnTypeOrArgumentTypes(const FunctionProtoType *T) {
|
|||
}
|
||||
|
||||
const llvm::Type *
|
||||
CodeGenTypes::GetFunctionTypeForVtable(const CXXMethodDecl *MD) {
|
||||
CodeGenTypes::GetFunctionTypeForVTable(const CXXMethodDecl *MD) {
|
||||
const FunctionProtoType *FPT = MD->getType()->getAs<FunctionProtoType>();
|
||||
|
||||
if (!HasIncompleteReturnTypeOrArgumentTypes(FPT))
|
||||
|
|
|
@ -626,7 +626,7 @@ CGDebugInfo::CreateCXXMemberFunction(const CXXMethodDecl *Method,
|
|||
// It doesn't make sense to give a virtual destructor a vtable index,
|
||||
// since a single destructor has two entries in the vtable.
|
||||
if (!isa<CXXDestructorDecl>(Method))
|
||||
VIndex = CGM.getVTables().getMethodVtableIndex(Method);
|
||||
VIndex = CGM.getVTables().getMethodVTableIndex(Method);
|
||||
ContainingType = RecordTy;
|
||||
}
|
||||
|
||||
|
@ -734,8 +734,8 @@ llvm::DIType CGDebugInfo::getOrCreateVTablePtrType(llvm::DIFile Unit) {
|
|||
return VTablePtrType;
|
||||
}
|
||||
|
||||
/// getVtableName - Get vtable name for the given Class.
|
||||
llvm::StringRef CGDebugInfo::getVtableName(const CXXRecordDecl *RD) {
|
||||
/// getVTableName - Get vtable name for the given Class.
|
||||
llvm::StringRef CGDebugInfo::getVTableName(const CXXRecordDecl *RD) {
|
||||
// Otherwise construct gdb compatible name name.
|
||||
std::string Name = "_vptr$" + RD->getNameAsString();
|
||||
|
||||
|
@ -746,10 +746,10 @@ llvm::StringRef CGDebugInfo::getVtableName(const CXXRecordDecl *RD) {
|
|||
}
|
||||
|
||||
|
||||
/// CollectVtableInfo - If the C++ class has vtable info then insert appropriate
|
||||
/// CollectVTableInfo - If the C++ class has vtable info then insert appropriate
|
||||
/// debug info entry in EltTys vector.
|
||||
void CGDebugInfo::
|
||||
CollectVtableInfo(const CXXRecordDecl *RD, llvm::DIFile Unit,
|
||||
CollectVTableInfo(const CXXRecordDecl *RD, llvm::DIFile Unit,
|
||||
llvm::SmallVectorImpl<llvm::DIDescriptor> &EltTys) {
|
||||
const ASTRecordLayout &RL = CGM.getContext().getASTRecordLayout(RD);
|
||||
|
||||
|
@ -764,7 +764,7 @@ CollectVtableInfo(const CXXRecordDecl *RD, llvm::DIFile Unit,
|
|||
unsigned Size = CGM.getContext().getTypeSize(CGM.getContext().VoidPtrTy);
|
||||
llvm::DIType VPTR
|
||||
= DebugFactory.CreateDerivedType(llvm::dwarf::DW_TAG_member, Unit,
|
||||
getVtableName(RD), Unit,
|
||||
getVTableName(RD), Unit,
|
||||
0, Size, 0, 0, 0,
|
||||
getOrCreateVTablePtrType(Unit));
|
||||
EltTys.push_back(VPTR);
|
||||
|
@ -832,7 +832,7 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty,
|
|||
const CXXRecordDecl *CXXDecl = dyn_cast<CXXRecordDecl>(RD);
|
||||
if (CXXDecl) {
|
||||
CollectCXXBases(CXXDecl, Unit, EltTys, FwdDecl);
|
||||
CollectVtableInfo(CXXDecl, Unit, EltTys);
|
||||
CollectVTableInfo(CXXDecl, Unit, EltTys);
|
||||
}
|
||||
CollectRecordFields(RD, Unit, EltTys);
|
||||
llvm::MDNode *ContainingType = NULL;
|
||||
|
|
|
@ -112,7 +112,7 @@ class CGDebugInfo {
|
|||
void CollectRecordFields(const RecordDecl *Decl, llvm::DIFile F,
|
||||
llvm::SmallVectorImpl<llvm::DIDescriptor> &E);
|
||||
|
||||
void CollectVtableInfo(const CXXRecordDecl *Decl,
|
||||
void CollectVTableInfo(const CXXRecordDecl *Decl,
|
||||
llvm::DIFile F,
|
||||
llvm::SmallVectorImpl<llvm::DIDescriptor> &EltTys);
|
||||
|
||||
|
@ -201,8 +201,8 @@ private:
|
|||
/// is stored on the side.
|
||||
llvm::StringRef getFunctionName(const FunctionDecl *FD);
|
||||
|
||||
/// getVtableName - Get vtable name for the given Class.
|
||||
llvm::StringRef getVtableName(const CXXRecordDecl *Decl);
|
||||
/// getVTableName - Get vtable name for the given Class.
|
||||
llvm::StringRef getVTableName(const CXXRecordDecl *Decl);
|
||||
|
||||
};
|
||||
} // namespace CodeGen
|
||||
|
|
|
@ -333,7 +333,7 @@ void AggExprEmitter::VisitUnaryAddrOf(const UnaryOperator *E) {
|
|||
llvm::Value *FuncPtr;
|
||||
|
||||
if (MD->isVirtual()) {
|
||||
int64_t Index = CGF.CGM.getVTables().getMethodVtableIndex(MD);
|
||||
int64_t Index = CGF.CGM.getVTables().getMethodVTableIndex(MD);
|
||||
|
||||
// Itanium C++ ABI 2.3:
|
||||
// For a non-virtual function, this field is a simple function pointer.
|
||||
|
|
|
@ -205,20 +205,20 @@ CodeGenFunction::EmitCXXMemberPointerCallExpr(const CXXMemberCallExpr *E,
|
|||
Builder.CreateCondBr(IsVirtual, FnVirtual, FnNonVirtual);
|
||||
EmitBlock(FnVirtual);
|
||||
|
||||
const llvm::Type *VtableTy =
|
||||
const llvm::Type *VTableTy =
|
||||
FTy->getPointerTo()->getPointerTo();
|
||||
|
||||
llvm::Value *Vtable = Builder.CreateBitCast(This, VtableTy->getPointerTo());
|
||||
Vtable = Builder.CreateLoad(Vtable);
|
||||
llvm::Value *VTable = Builder.CreateBitCast(This, VTableTy->getPointerTo());
|
||||
VTable = Builder.CreateLoad(VTable);
|
||||
|
||||
Vtable = Builder.CreateBitCast(Vtable, Int8PtrTy);
|
||||
llvm::Value *VtableOffset =
|
||||
VTable = Builder.CreateBitCast(VTable, Int8PtrTy);
|
||||
llvm::Value *VTableOffset =
|
||||
Builder.CreateSub(FnAsInt, llvm::ConstantInt::get(PtrDiffTy, 1));
|
||||
|
||||
Vtable = Builder.CreateGEP(Vtable, VtableOffset, "fn");
|
||||
Vtable = Builder.CreateBitCast(Vtable, VtableTy);
|
||||
VTable = Builder.CreateGEP(VTable, VTableOffset, "fn");
|
||||
VTable = Builder.CreateBitCast(VTable, VTableTy);
|
||||
|
||||
llvm::Value *VirtualFn = Builder.CreateLoad(Vtable, "virtualfn");
|
||||
llvm::Value *VirtualFn = Builder.CreateLoad(VTable, "virtualfn");
|
||||
|
||||
EmitBranch(FnEnd);
|
||||
EmitBlock(FnNonVirtual);
|
||||
|
|
|
@ -446,7 +446,7 @@ public:
|
|||
|
||||
// Get the function pointer (or index if this is a virtual function).
|
||||
if (MD->isVirtual()) {
|
||||
uint64_t Index = CGM.getVTables().getMethodVtableIndex(MD);
|
||||
uint64_t Index = CGM.getVTables().getMethodVTableIndex(MD);
|
||||
|
||||
// Itanium C++ ABI 2.3:
|
||||
// For a non-virtual function, this field is a simple function pointer.
|
||||
|
|
|
@ -31,8 +31,8 @@ class RTTIBuilder {
|
|||
/// descriptor of the given type.
|
||||
llvm::Constant *GetAddrOfExternalRTTIDescriptor(QualType Ty);
|
||||
|
||||
/// BuildVtablePointer - Build the vtable pointer for the given type.
|
||||
void BuildVtablePointer(const Type *Ty);
|
||||
/// BuildVTablePointer - Build the vtable pointer for the given type.
|
||||
void BuildVTablePointer(const Type *Ty);
|
||||
|
||||
/// BuildSIClassTypeInfo - Build an abi::__si_class_type_info, used for single
|
||||
/// inheritance, according to the Itanium C++ ABI, 2.9.5p6b.
|
||||
|
@ -337,7 +337,7 @@ static llvm::GlobalVariable::LinkageTypes getTypeInfoLinkage(QualType Ty) {
|
|||
if (const RecordType *Record = dyn_cast<RecordType>(Ty)) {
|
||||
const CXXRecordDecl *RD = cast<CXXRecordDecl>(Record->getDecl());
|
||||
if (RD->isDynamicClass())
|
||||
return CodeGenModule::getVtableLinkage(RD);
|
||||
return CodeGenModule::getVTableLinkage(RD);
|
||||
}
|
||||
|
||||
return llvm::GlobalValue::WeakODRLinkage;
|
||||
|
@ -375,8 +375,8 @@ static bool CanUseSingleInheritance(const CXXRecordDecl *RD) {
|
|||
return true;
|
||||
}
|
||||
|
||||
void RTTIBuilder::BuildVtablePointer(const Type *Ty) {
|
||||
const char *VtableName;
|
||||
void RTTIBuilder::BuildVTablePointer(const Type *Ty) {
|
||||
const char *VTableName;
|
||||
|
||||
switch (Ty->getTypeClass()) {
|
||||
default: assert(0 && "Unhandled type!");
|
||||
|
@ -386,24 +386,24 @@ void RTTIBuilder::BuildVtablePointer(const Type *Ty) {
|
|||
case Type::Vector:
|
||||
case Type::ExtVector:
|
||||
// abi::__fundamental_type_info.
|
||||
VtableName = "_ZTVN10__cxxabiv123__fundamental_type_infoE";
|
||||
VTableName = "_ZTVN10__cxxabiv123__fundamental_type_infoE";
|
||||
break;
|
||||
|
||||
case Type::ConstantArray:
|
||||
case Type::IncompleteArray:
|
||||
// abi::__array_type_info.
|
||||
VtableName = "_ZTVN10__cxxabiv117__array_type_infoE";
|
||||
VTableName = "_ZTVN10__cxxabiv117__array_type_infoE";
|
||||
break;
|
||||
|
||||
case Type::FunctionNoProto:
|
||||
case Type::FunctionProto:
|
||||
// abi::__function_type_info.
|
||||
VtableName = "_ZTVN10__cxxabiv120__function_type_infoE";
|
||||
VTableName = "_ZTVN10__cxxabiv120__function_type_infoE";
|
||||
break;
|
||||
|
||||
case Type::Enum:
|
||||
// abi::__enum_type_info.
|
||||
VtableName = "_ZTVN10__cxxabiv116__enum_type_infoE";
|
||||
VTableName = "_ZTVN10__cxxabiv116__enum_type_infoE";
|
||||
break;
|
||||
|
||||
case Type::Record: {
|
||||
|
@ -412,13 +412,13 @@ void RTTIBuilder::BuildVtablePointer(const Type *Ty) {
|
|||
|
||||
if (!RD->hasDefinition() || !RD->getNumBases()) {
|
||||
// abi::__class_type_info.
|
||||
VtableName = "_ZTVN10__cxxabiv117__class_type_infoE";
|
||||
VTableName = "_ZTVN10__cxxabiv117__class_type_infoE";
|
||||
} else if (CanUseSingleInheritance(RD)) {
|
||||
// abi::__si_class_type_info.
|
||||
VtableName = "_ZTVN10__cxxabiv120__si_class_type_infoE";
|
||||
VTableName = "_ZTVN10__cxxabiv120__si_class_type_infoE";
|
||||
} else {
|
||||
// abi::__vmi_class_type_info.
|
||||
VtableName = "_ZTVN10__cxxabiv121__vmi_class_type_infoE";
|
||||
VTableName = "_ZTVN10__cxxabiv121__vmi_class_type_infoE";
|
||||
}
|
||||
|
||||
break;
|
||||
|
@ -426,27 +426,27 @@ void RTTIBuilder::BuildVtablePointer(const Type *Ty) {
|
|||
|
||||
case Type::Pointer:
|
||||
// abi::__pointer_type_info.
|
||||
VtableName = "_ZTVN10__cxxabiv119__pointer_type_infoE";
|
||||
VTableName = "_ZTVN10__cxxabiv119__pointer_type_infoE";
|
||||
break;
|
||||
|
||||
case Type::MemberPointer:
|
||||
// abi::__pointer_to_member_type_info.
|
||||
VtableName = "_ZTVN10__cxxabiv129__pointer_to_member_type_infoE";
|
||||
VTableName = "_ZTVN10__cxxabiv129__pointer_to_member_type_infoE";
|
||||
break;
|
||||
}
|
||||
|
||||
llvm::Constant *Vtable =
|
||||
CGM.getModule().getOrInsertGlobal(VtableName, Int8PtrTy);
|
||||
llvm::Constant *VTable =
|
||||
CGM.getModule().getOrInsertGlobal(VTableName, Int8PtrTy);
|
||||
|
||||
const llvm::Type *PtrDiffTy =
|
||||
CGM.getTypes().ConvertType(CGM.getContext().getPointerDiffType());
|
||||
|
||||
// The vtable address point is 2.
|
||||
llvm::Constant *Two = llvm::ConstantInt::get(PtrDiffTy, 2);
|
||||
Vtable = llvm::ConstantExpr::getInBoundsGetElementPtr(Vtable, &Two, 1);
|
||||
Vtable = llvm::ConstantExpr::getBitCast(Vtable, Int8PtrTy);
|
||||
VTable = llvm::ConstantExpr::getInBoundsGetElementPtr(VTable, &Two, 1);
|
||||
VTable = llvm::ConstantExpr::getBitCast(VTable, Int8PtrTy);
|
||||
|
||||
Fields.push_back(Vtable);
|
||||
Fields.push_back(VTable);
|
||||
}
|
||||
|
||||
llvm::Constant *RTTIBuilder::BuildTypeInfo(QualType Ty, bool Force) {
|
||||
|
@ -469,7 +469,7 @@ llvm::Constant *RTTIBuilder::BuildTypeInfo(QualType Ty, bool Force) {
|
|||
llvm::GlobalVariable::LinkageTypes Linkage = getTypeInfoLinkage(Ty);
|
||||
|
||||
// Add the vtable pointer.
|
||||
BuildVtablePointer(cast<Type>(Ty));
|
||||
BuildVTablePointer(cast<Type>(Ty));
|
||||
|
||||
// And the name.
|
||||
Fields.push_back(BuildName(Ty, DecideHidden(Ty), Linkage));
|
||||
|
|
|
@ -395,7 +395,7 @@ void CGRecordLayoutBuilder::LayoutBases(const CXXRecordDecl *RD,
|
|||
llvm::Type::getInt8PtrTy(Types.getLLVMContext());
|
||||
|
||||
assert(NextFieldOffsetInBytes == 0 &&
|
||||
"Vtable pointer must come first!");
|
||||
"VTable pointer must come first!");
|
||||
AppendField(NextFieldOffsetInBytes, Int8PtrTy->getPointerTo());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
//===--- CGVtables.cpp - Emit LLVM Code for C++ vtables -------------------===//
|
||||
//===--- CGVTables.cpp - Emit LLVM Code for C++ vtables -------------------===//
|
||||
//
|
||||
// The LLVM Compiler Infrastructure
|
||||
//
|
||||
|
@ -2362,7 +2362,7 @@ void VTableBuilder::dumpLayout(llvm::raw_ostream& Out) {
|
|||
|
||||
}
|
||||
|
||||
void CodeGenVTables::ComputeMethodVtableIndices(const CXXRecordDecl *RD) {
|
||||
void CodeGenVTables::ComputeMethodVTableIndices(const CXXRecordDecl *RD) {
|
||||
|
||||
// Itanium C++ ABI 2.5.2:
|
||||
// The order of the virtual function pointers in a virtual table is the
|
||||
|
@ -2419,12 +2419,12 @@ void CodeGenVTables::ComputeMethodVtableIndices(const CXXRecordDecl *RD) {
|
|||
cast<CXXDestructorDecl>(OverriddenMD);
|
||||
|
||||
// Add both the complete and deleting entries.
|
||||
MethodVtableIndices[GlobalDecl(DD, Dtor_Complete)] =
|
||||
getMethodVtableIndex(GlobalDecl(OverriddenDD, Dtor_Complete));
|
||||
MethodVtableIndices[GlobalDecl(DD, Dtor_Deleting)] =
|
||||
getMethodVtableIndex(GlobalDecl(OverriddenDD, Dtor_Deleting));
|
||||
MethodVTableIndices[GlobalDecl(DD, Dtor_Complete)] =
|
||||
getMethodVTableIndex(GlobalDecl(OverriddenDD, Dtor_Complete));
|
||||
MethodVTableIndices[GlobalDecl(DD, Dtor_Deleting)] =
|
||||
getMethodVTableIndex(GlobalDecl(OverriddenDD, Dtor_Deleting));
|
||||
} else {
|
||||
MethodVtableIndices[MD] = getMethodVtableIndex(OverriddenMD);
|
||||
MethodVTableIndices[MD] = getMethodVTableIndex(OverriddenMD);
|
||||
}
|
||||
|
||||
// We don't need to add an entry for this method.
|
||||
|
@ -2441,13 +2441,13 @@ void CodeGenVTables::ComputeMethodVtableIndices(const CXXRecordDecl *RD) {
|
|||
}
|
||||
|
||||
// Add the complete dtor.
|
||||
MethodVtableIndices[GlobalDecl(DD, Dtor_Complete)] = CurrentIndex++;
|
||||
MethodVTableIndices[GlobalDecl(DD, Dtor_Complete)] = CurrentIndex++;
|
||||
|
||||
// Add the deleting dtor.
|
||||
MethodVtableIndices[GlobalDecl(DD, Dtor_Deleting)] = CurrentIndex++;
|
||||
MethodVTableIndices[GlobalDecl(DD, Dtor_Deleting)] = CurrentIndex++;
|
||||
} else {
|
||||
// Add the entry.
|
||||
MethodVtableIndices[MD] = CurrentIndex++;
|
||||
MethodVTableIndices[MD] = CurrentIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2457,11 +2457,11 @@ void CodeGenVTables::ComputeMethodVtableIndices(const CXXRecordDecl *RD) {
|
|||
// its entries come after the declared virtual function pointers.
|
||||
|
||||
// Add the complete dtor.
|
||||
MethodVtableIndices[GlobalDecl(ImplicitVirtualDtor, Dtor_Complete)] =
|
||||
MethodVTableIndices[GlobalDecl(ImplicitVirtualDtor, Dtor_Complete)] =
|
||||
CurrentIndex++;
|
||||
|
||||
// Add the deleting dtor.
|
||||
MethodVtableIndices[GlobalDecl(ImplicitVirtualDtor, Dtor_Deleting)] =
|
||||
MethodVTableIndices[GlobalDecl(ImplicitVirtualDtor, Dtor_Deleting)] =
|
||||
CurrentIndex++;
|
||||
}
|
||||
|
||||
|
@ -2474,24 +2474,24 @@ uint64_t CodeGenVTables::getNumVirtualFunctionPointers(const CXXRecordDecl *RD)
|
|||
if (I != NumVirtualFunctionPointers.end())
|
||||
return I->second;
|
||||
|
||||
ComputeMethodVtableIndices(RD);
|
||||
ComputeMethodVTableIndices(RD);
|
||||
|
||||
I = NumVirtualFunctionPointers.find(RD);
|
||||
assert(I != NumVirtualFunctionPointers.end() && "Did not find entry!");
|
||||
return I->second;
|
||||
}
|
||||
|
||||
uint64_t CodeGenVTables::getMethodVtableIndex(GlobalDecl GD) {
|
||||
MethodVtableIndicesTy::iterator I = MethodVtableIndices.find(GD);
|
||||
if (I != MethodVtableIndices.end())
|
||||
uint64_t CodeGenVTables::getMethodVTableIndex(GlobalDecl GD) {
|
||||
MethodVTableIndicesTy::iterator I = MethodVTableIndices.find(GD);
|
||||
if (I != MethodVTableIndices.end())
|
||||
return I->second;
|
||||
|
||||
const CXXRecordDecl *RD = cast<CXXMethodDecl>(GD.getDecl())->getParent();
|
||||
|
||||
ComputeMethodVtableIndices(RD);
|
||||
ComputeMethodVTableIndices(RD);
|
||||
|
||||
I = MethodVtableIndices.find(GD);
|
||||
assert(I != MethodVtableIndices.end() && "Did not find index!");
|
||||
I = MethodVTableIndices.find(GD);
|
||||
assert(I != MethodVTableIndices.end() && "Did not find index!");
|
||||
return I->second;
|
||||
}
|
||||
|
||||
|
@ -2547,7 +2547,7 @@ llvm::Constant *CodeGenModule::GetAddrOfThunk(GlobalDecl GD,
|
|||
else
|
||||
getMangleContext().mangleThunk(MD, Thunk, Name);
|
||||
|
||||
const llvm::Type *Ty = getTypes().GetFunctionTypeForVtable(MD);
|
||||
const llvm::Type *Ty = getTypes().GetFunctionTypeForVTable(MD);
|
||||
return GetOrCreateLLVMFunction(Name, Ty, GlobalDecl());
|
||||
}
|
||||
|
||||
|
@ -2730,7 +2730,7 @@ void CodeGenVTables::EmitThunk(GlobalDecl GD, const ThunkInfo &Thunk)
|
|||
// There's already a declaration with the same name, check if it has the same
|
||||
// type or if we need to replace it.
|
||||
if (cast<llvm::GlobalValue>(Entry)->getType()->getElementType() !=
|
||||
CGM.getTypes().GetFunctionTypeForVtable(MD)) {
|
||||
CGM.getTypes().GetFunctionTypeForVTable(MD)) {
|
||||
llvm::GlobalValue *OldThunkFn = cast<llvm::GlobalValue>(Entry);
|
||||
|
||||
// If the types mismatch then we have to rewrite the definition.
|
||||
|
@ -2938,7 +2938,7 @@ CodeGenVTables::CreateVTableInitializer(const CXXRecordDecl *RD,
|
|||
NextVTableThunkIndex++;
|
||||
} else {
|
||||
const CXXMethodDecl *MD = cast<CXXMethodDecl>(GD.getDecl());
|
||||
const llvm::Type *Ty = CGM.getTypes().GetFunctionTypeForVtable(MD);
|
||||
const llvm::Type *Ty = CGM.getTypes().GetFunctionTypeForVTable(MD);
|
||||
|
||||
Init = CGM.GetAddrOfFunction(GD, Ty);
|
||||
}
|
||||
|
@ -3005,7 +3005,7 @@ GetGlobalVariable(llvm::Module &Module, llvm::StringRef Name,
|
|||
|
||||
llvm::GlobalVariable *CodeGenVTables::GetAddrOfVTable(const CXXRecordDecl *RD) {
|
||||
llvm::SmallString<256> OutName;
|
||||
CGM.getMangleContext().mangleCXXVtable(RD, OutName);
|
||||
CGM.getMangleContext().mangleCXXVTable(RD, OutName);
|
||||
llvm::StringRef Name = OutName.str();
|
||||
|
||||
ComputeVTableRelatedInformation(RD);
|
||||
|
@ -3023,7 +3023,7 @@ CodeGenVTables::EmitVTableDefinition(llvm::GlobalVariable *VTable,
|
|||
llvm::GlobalVariable::LinkageTypes Linkage,
|
||||
const CXXRecordDecl *RD) {
|
||||
// Dump the vtable layout if necessary.
|
||||
if (CGM.getLangOptions().DumpVtableLayouts) {
|
||||
if (CGM.getLangOptions().DumpVTableLayouts) {
|
||||
VTableBuilder Builder(*this, RD, 0, /*MostDerivedClassIsVirtual=*/0, RD);
|
||||
|
||||
Builder.dumpLayout(llvm::errs());
|
||||
|
@ -3053,7 +3053,7 @@ CodeGenVTables::GenerateConstructionVTable(const CXXRecordDecl *RD,
|
|||
/*MostDerivedClassIsVirtual=*/BaseIsVirtual, RD);
|
||||
|
||||
// Dump the vtable layout if necessary.
|
||||
if (CGM.getLangOptions().DumpVtableLayouts)
|
||||
if (CGM.getLangOptions().DumpVTableLayouts)
|
||||
Builder.dumpLayout(llvm::errs());
|
||||
|
||||
// Add the address points.
|
||||
|
@ -3062,7 +3062,7 @@ CodeGenVTables::GenerateConstructionVTable(const CXXRecordDecl *RD,
|
|||
|
||||
// Get the mangled construction vtable name.
|
||||
llvm::SmallString<256> OutName;
|
||||
CGM.getMangleContext().mangleCXXCtorVtable(RD, Base.getBaseOffset() / 8,
|
||||
CGM.getMangleContext().mangleCXXCtorVTable(RD, Base.getBaseOffset() / 8,
|
||||
Base.getBase(), OutName);
|
||||
llvm::StringRef Name = OutName.str();
|
||||
|
||||
|
@ -3096,9 +3096,9 @@ CodeGenVTables::GenerateConstructionVTable(const CXXRecordDecl *RD,
|
|||
void
|
||||
CodeGenVTables::GenerateClassData(llvm::GlobalVariable::LinkageTypes Linkage,
|
||||
const CXXRecordDecl *RD) {
|
||||
llvm::GlobalVariable *&VTable = Vtables[RD];
|
||||
llvm::GlobalVariable *&VTable = VTables[RD];
|
||||
if (VTable) {
|
||||
assert(VTable->getInitializer() && "Vtable doesn't have a definition!");
|
||||
assert(VTable->getInitializer() && "VTable doesn't have a definition!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -3157,11 +3157,11 @@ void CodeGenVTables::EmitVTableRelatedData(GlobalDecl GD) {
|
|||
return;
|
||||
}
|
||||
|
||||
if (Vtables.count(RD))
|
||||
if (VTables.count(RD))
|
||||
return;
|
||||
|
||||
if (RDKind == TSK_ImplicitInstantiation)
|
||||
CGM.DeferredVtables.push_back(RD);
|
||||
CGM.DeferredVTables.push_back(RD);
|
||||
else
|
||||
GenerateClassData(CGM.getVtableLinkage(RD), RD);
|
||||
GenerateClassData(CGM.getVTableLinkage(RD), RD);
|
||||
}
|
||||
|
|
|
@ -180,10 +180,10 @@ namespace CodeGen {
|
|||
class CodeGenVTables {
|
||||
CodeGenModule &CGM;
|
||||
|
||||
/// MethodVtableIndices - Contains the index (relative to the vtable address
|
||||
/// MethodVTableIndices - Contains the index (relative to the vtable address
|
||||
/// point) where the function pointer for a virtual function is stored.
|
||||
typedef llvm::DenseMap<GlobalDecl, int64_t> MethodVtableIndicesTy;
|
||||
MethodVtableIndicesTy MethodVtableIndices;
|
||||
typedef llvm::DenseMap<GlobalDecl, int64_t> MethodVTableIndicesTy;
|
||||
MethodVTableIndicesTy MethodVTableIndices;
|
||||
|
||||
typedef std::pair<const CXXRecordDecl *,
|
||||
const CXXRecordDecl *> ClassPairTy;
|
||||
|
@ -195,8 +195,8 @@ class CodeGenVTables {
|
|||
VirtualBaseClassOffsetOffsetsMapTy;
|
||||
VirtualBaseClassOffsetOffsetsMapTy VirtualBaseClassOffsetOffsets;
|
||||
|
||||
/// Vtables - All the vtables which have been defined.
|
||||
llvm::DenseMap<const CXXRecordDecl *, llvm::GlobalVariable *> Vtables;
|
||||
/// VTables - All the vtables which have been defined.
|
||||
llvm::DenseMap<const CXXRecordDecl *, llvm::GlobalVariable *> VTables;
|
||||
|
||||
/// NumVirtualFunctionPointers - Contains the number of virtual function
|
||||
/// pointers in the vtable for a given record decl.
|
||||
|
@ -265,7 +265,7 @@ class CodeGenVTables {
|
|||
/// pointers in the vtable for a given record decl.
|
||||
uint64_t getNumVirtualFunctionPointers(const CXXRecordDecl *RD);
|
||||
|
||||
void ComputeMethodVtableIndices(const CXXRecordDecl *RD);
|
||||
void ComputeMethodVTableIndices(const CXXRecordDecl *RD);
|
||||
|
||||
llvm::GlobalVariable *GenerateVTT(llvm::GlobalVariable::LinkageTypes Linkage,
|
||||
bool GenerateDefinition,
|
||||
|
@ -309,10 +309,10 @@ public:
|
|||
uint64_t getSecondaryVirtualPointerIndex(const CXXRecordDecl *RD,
|
||||
BaseSubobject Base);
|
||||
|
||||
/// getMethodVtableIndex - Return the index (relative to the vtable address
|
||||
/// getMethodVTableIndex - Return the index (relative to the vtable address
|
||||
/// point) where the function pointer for the given virtual function is
|
||||
/// stored.
|
||||
uint64_t getMethodVtableIndex(GlobalDecl GD);
|
||||
uint64_t getMethodVTableIndex(GlobalDecl GD);
|
||||
|
||||
/// getVirtualBaseOffsetOffset - Return the offset in bytes (relative to the
|
||||
/// vtable address point) where the offset of the virtual base that contains
|
||||
|
|
|
@ -492,11 +492,11 @@ void CodeGenModule::EmitDeferred() {
|
|||
// previously unused static decl may become used during the generation of code
|
||||
// for a static function, iterate until no changes are made.
|
||||
|
||||
while (!DeferredDeclsToEmit.empty() || !DeferredVtables.empty()) {
|
||||
if (!DeferredVtables.empty()) {
|
||||
const CXXRecordDecl *RD = DeferredVtables.back();
|
||||
DeferredVtables.pop_back();
|
||||
getVTables().GenerateClassData(getVtableLinkage(RD), RD);
|
||||
while (!DeferredDeclsToEmit.empty() || !DeferredVTables.empty()) {
|
||||
if (!DeferredVTables.empty()) {
|
||||
const CXXRecordDecl *RD = DeferredVTables.back();
|
||||
DeferredVTables.pop_back();
|
||||
getVTables().GenerateClassData(getVTableLinkage(RD), RD);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
@ -962,7 +962,7 @@ void CodeGenModule::EmitTentativeDefinition(const VarDecl *D) {
|
|||
}
|
||||
|
||||
llvm::GlobalVariable::LinkageTypes
|
||||
CodeGenModule::getVtableLinkage(const CXXRecordDecl *RD) {
|
||||
CodeGenModule::getVTableLinkage(const CXXRecordDecl *RD) {
|
||||
if (RD->isInAnonymousNamespace() || !RD->hasLinkage())
|
||||
return llvm::GlobalVariable::InternalLinkage;
|
||||
|
||||
|
|
|
@ -417,16 +417,16 @@ public:
|
|||
llvm::GlobalVariable::LinkageTypes
|
||||
getFunctionLinkage(const FunctionDecl *FD);
|
||||
|
||||
/// getVtableLinkage - Return the appropriate linkage for the vtable, VTT,
|
||||
/// getVTableLinkage - Return the appropriate linkage for the vtable, VTT,
|
||||
/// and type information of the given class.
|
||||
static llvm::GlobalVariable::LinkageTypes
|
||||
getVtableLinkage(const CXXRecordDecl *RD);
|
||||
getVTableLinkage(const CXXRecordDecl *RD);
|
||||
|
||||
/// GetTargetTypeStoreSize - Return the store size, in character units, of
|
||||
/// the given LLVM type.
|
||||
CharUnits GetTargetTypeStoreSize(const llvm::Type *Ty) const;
|
||||
|
||||
std::vector<const CXXRecordDecl*> DeferredVtables;
|
||||
std::vector<const CXXRecordDecl*> DeferredVTables;
|
||||
|
||||
private:
|
||||
llvm::GlobalValue *GetGlobalValue(llvm::StringRef Ref);
|
||||
|
|
|
@ -123,10 +123,10 @@ public:
|
|||
const llvm::FunctionType *GetFunctionType(GlobalDecl GD);
|
||||
|
||||
|
||||
/// GetFunctionTypeForVtable - Get the LLVM function type for use in a vtable,
|
||||
/// GetFunctionTypeForVTable - Get the LLVM function type for use in a vtable,
|
||||
/// given a CXXMethodDecl. If the method to has an incomplete return type,
|
||||
/// and/or incomplete argument types, this will return the opaque type.
|
||||
const llvm::Type *GetFunctionTypeForVtable(const CXXMethodDecl *MD);
|
||||
const llvm::Type *GetFunctionTypeForVTable(const CXXMethodDecl *MD);
|
||||
|
||||
const CGRecordLayout &getCGRecordLayout(const RecordDecl*) const;
|
||||
|
||||
|
|
|
@ -1966,7 +1966,7 @@ void MangleContext::mangleGuardVariable(const VarDecl *D,
|
|||
Mangler.mangleName(D);
|
||||
}
|
||||
|
||||
void MangleContext::mangleCXXVtable(const CXXRecordDecl *RD,
|
||||
void MangleContext::mangleCXXVTable(const CXXRecordDecl *RD,
|
||||
llvm::SmallVectorImpl<char> &Res) {
|
||||
// <special-name> ::= TV <type> # virtual table
|
||||
CXXNameMangler Mangler(*this, Res);
|
||||
|
@ -1982,7 +1982,7 @@ void MangleContext::mangleCXXVTT(const CXXRecordDecl *RD,
|
|||
Mangler.mangleName(RD);
|
||||
}
|
||||
|
||||
void MangleContext::mangleCXXCtorVtable(const CXXRecordDecl *RD, int64_t Offset,
|
||||
void MangleContext::mangleCXXCtorVTable(const CXXRecordDecl *RD, int64_t Offset,
|
||||
const CXXRecordDecl *Type,
|
||||
llvm::SmallVectorImpl<char> &Res) {
|
||||
// <special-name> ::= TC <type> <offset number> _ <base type>
|
||||
|
|
|
@ -103,9 +103,9 @@ public:
|
|||
const ThisAdjustment &ThisAdjustment,
|
||||
llvm::SmallVectorImpl<char> &);
|
||||
void mangleGuardVariable(const VarDecl *D, llvm::SmallVectorImpl<char> &);
|
||||
void mangleCXXVtable(const CXXRecordDecl *RD, llvm::SmallVectorImpl<char> &);
|
||||
void mangleCXXVTable(const CXXRecordDecl *RD, llvm::SmallVectorImpl<char> &);
|
||||
void mangleCXXVTT(const CXXRecordDecl *RD, llvm::SmallVectorImpl<char> &);
|
||||
void mangleCXXCtorVtable(const CXXRecordDecl *RD, int64_t Offset,
|
||||
void mangleCXXCtorVTable(const CXXRecordDecl *RD, int64_t Offset,
|
||||
const CXXRecordDecl *Type,
|
||||
llvm::SmallVectorImpl<char> &);
|
||||
void mangleCXXRTTI(QualType T, llvm::SmallVectorImpl<char> &);
|
||||
|
|
|
@ -528,7 +528,7 @@ static void LangOptsToArgs(const LangOptions &Opts,
|
|||
Res.push_back("-static-define");
|
||||
if (Opts.DumpRecordLayouts)
|
||||
Res.push_back("-fdump-record-layouts");
|
||||
if (Opts.DumpVtableLayouts)
|
||||
if (Opts.DumpVTableLayouts)
|
||||
Res.push_back("-fdump-vtable-layouts");
|
||||
if (Opts.NoBitFieldTypeAlign)
|
||||
Res.push_back("-fno-bitfield-type-alignment");
|
||||
|
@ -1226,7 +1226,7 @@ static void ParseLangArgs(LangOptions &Opts, ArgList &Args,
|
|||
Opts.SjLjExceptions = Args.hasArg(OPT_fsjlj_exceptions);
|
||||
Opts.Static = Args.hasArg(OPT_static_define);
|
||||
Opts.DumpRecordLayouts = Args.hasArg(OPT_fdump_record_layouts);
|
||||
Opts.DumpVtableLayouts = Args.hasArg(OPT_fdump_vtable_layouts);
|
||||
Opts.DumpVTableLayouts = Args.hasArg(OPT_fdump_vtable_layouts);
|
||||
Opts.NoBitFieldTypeAlign = Args.hasArg(OPT_fno_bitfield_type_align);
|
||||
Opts.OptimizeSize = 0;
|
||||
|
||||
|
|
|
@ -5432,7 +5432,7 @@ Sema::ActOnCXXConditionDeclaration(Scope *S, Declarator &D) {
|
|||
return Dcl;
|
||||
}
|
||||
|
||||
static bool needsVtable(CXXMethodDecl *MD, ASTContext &Context) {
|
||||
static bool needsVTable(CXXMethodDecl *MD, ASTContext &Context) {
|
||||
// Ignore dependent types.
|
||||
if (MD->isDependentContext())
|
||||
return false;
|
||||
|
@ -5495,7 +5495,7 @@ void Sema::MaybeMarkVirtualMembersReferenced(SourceLocation Loc,
|
|||
|
||||
// We will need to mark all of the virtual members as referenced to build the
|
||||
// vtable.
|
||||
if (!needsVtable(MD, Context))
|
||||
if (!needsVTable(MD, Context))
|
||||
return;
|
||||
|
||||
TemplateSpecializationKind kind = RD->getTemplateSpecializationKind();
|
||||
|
|
Loading…
Reference in New Issue