本文整理汇总了C++中TypeIndex类的典型用法代码示例。如果您正苦于以下问题:C++ TypeIndex类的具体用法?C++ TypeIndex怎么用?C++ TypeIndex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TypeIndex类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GetIntegralTypeInfo
static std::pair<size_t, bool> GetIntegralTypeInfo(TypeIndex ti,
TpiStream &tpi) {
if (ti.isSimple()) {
SimpleTypeKind stk = ti.getSimpleKind();
return {GetTypeSizeForSimpleKind(stk), IsSimpleTypeSignedInteger(stk)};
}
CVType cvt = tpi.getType(ti);
switch (cvt.kind()) {
case LF_MODIFIER: {
ModifierRecord mfr;
llvm::cantFail(TypeDeserializer::deserializeAs<ModifierRecord>(cvt, mfr));
return GetIntegralTypeInfo(mfr.ModifiedType, tpi);
}
case LF_POINTER: {
PointerRecord pr;
llvm::cantFail(TypeDeserializer::deserializeAs<PointerRecord>(cvt, pr));
return GetIntegralTypeInfo(pr.ReferentType, tpi);
}
case LF_ENUM: {
EnumRecord er;
llvm::cantFail(TypeDeserializer::deserializeAs<EnumRecord>(cvt, er));
return GetIntegralTypeInfo(er.UnderlyingType, tpi);
}
default:
assert(false && "Type is not integral!");
return {0, false};
}
}
示例2: getTypeName
StringRef CVTypeDumper::getTypeName(TypeIndex TI) {
if (TI.isNoType())
return "<no type>";
if (TI.isSimple()) {
// This is a simple type.
for (const auto &SimpleTypeName : SimpleTypeNames) {
if (SimpleTypeName.Value == TI.getSimpleKind()) {
if (TI.getSimpleMode() == SimpleTypeMode::Direct)
return SimpleTypeName.Name.drop_back(1);
// Otherwise, this is a pointer type. We gloss over the distinction
// between near, far, 64, 32, etc, and just give a pointer type.
return SimpleTypeName.Name;
}
}
return "<unknown simple type>";
}
// User-defined type.
StringRef UDTName;
unsigned UDTIndex = TI.getIndex() - 0x1000;
if (UDTIndex < CVUDTNames.size())
return CVUDTNames[UDTIndex];
return "<unknown UDT>";
}
示例3: remapTypeIndex
static bool remapTypeIndex(TypeIndex &TI, ArrayRef<TypeIndex> TypeIndexMap) {
if (TI.isSimple())
return true;
if (TI.toArrayIndex() >= TypeIndexMap.size())
return false;
TI = TypeIndexMap[TI.toArrayIndex()];
return true;
}
示例4: printTypeIndex
void CVTypeDumper::printTypeIndex(StringRef FieldName, TypeIndex TI) {
StringRef TypeName;
if (!TI.isNoType())
TypeName = getTypeName(TI);
if (!TypeName.empty())
W.printHex(FieldName, TypeName, TI.getIndex());
else
W.printHex(FieldName, TI.getIndex());
}
示例5: printTypeIndex
void CVTypeDumper::printTypeIndex(ScopedPrinter &Printer, StringRef FieldName,
TypeIndex TI, TypeDatabase &DB) {
StringRef TypeName;
if (!TI.isNoneType())
TypeName = DB.getTypeName(TI);
if (!TypeName.empty())
Printer.printHex(FieldName, TypeName, TI.getIndex());
else
Printer.printHex(FieldName, TI.getIndex());
}
示例6: PointerToClass
unsigned UserDefinedCodeViewTypesBuilder::GetPointerTypeIndex(const PointerTypeDescriptor& PointerDescriptor)
{
uint32_t elementType = PointerDescriptor.ElementType;
PointerKind pointerKind = PointerDescriptor.Is64Bit ? PointerKind::Near64 : PointerKind::Near32;
PointerMode pointerMode = PointerDescriptor.IsReference ? PointerMode::LValueReference : PointerMode::Pointer;
PointerOptions pointerOptions = PointerDescriptor.IsConst ? PointerOptions::Const : PointerOptions::None;
PointerRecord PointerToClass(TypeIndex(elementType), pointerKind, pointerMode, pointerOptions, 0);
TypeIndex PointerIndex = TypeTable.writeKnownType(PointerToClass);
return PointerIndex.getIndex();
}
示例7: register_type_index
void TraceDbImpl::register_type_index(TypeIndex type)
{
if (!has_type_index(type))
{
run_void(insert_type_index,
{
{"Id", (int)type.get_id()},
{"Description", type.description()}
});
set_has_type_index(type);
}
}
示例8: createSimpleType
SymIndexId SymbolCache::createSimpleType(TypeIndex Index,
ModifierOptions Mods) {
if (Index.getSimpleMode() != codeview::SimpleTypeMode::Direct)
return createSymbol<NativeTypePointer>(Index);
const auto Kind = Index.getSimpleKind();
const auto It = std::find_if(
std::begin(BuiltinTypes), std::end(BuiltinTypes),
[Kind](const BuiltinTypeEntry &Builtin) { return Builtin.Kind == Kind; });
if (It == std::end(BuiltinTypes))
return 0;
return createSymbol<NativeTypeBuiltin>(Mods, It->Type, It->Size);
}
示例9: FLBR
unsigned UserDefinedCodeViewTypesBuilder::GetCompleteClassTypeIndex(
const ClassTypeDescriptor &ClassDescriptor,
const ClassFieldsTypeDescriptior &ClassFieldsDescriptor,
const DataFieldDescriptor *FieldsDescriptors,
const StaticDataFieldDescriptor *StaticsDescriptors) {
FieldListRecordBuilder FLBR(TypeTable);
FLBR.begin();
uint16_t memberCount = 0;
if (!ClassDescriptor.IsStruct) {
memberCount++;
AddClassVTShape(FLBR);
}
if (ClassDescriptor.BaseClassId != 0) {
memberCount++;
AddBaseClass(FLBR, ClassDescriptor.BaseClassId);
}
for (int i = 0; i < ClassFieldsDescriptor.FieldsCount; ++i) {
DataFieldDescriptor desc = FieldsDescriptors[i];
MemberAccess Access = MemberAccess::Public;
TypeIndex MemberBaseType(desc.FieldTypeIndex);
if (desc.Offset == 0xFFFFFFFF)
{
StaticDataMemberRecord SDMR(Access, MemberBaseType, desc.Name);
FLBR.writeMemberType(SDMR);
}
else
{
int MemberOffsetInBytes = desc.Offset;
DataMemberRecord DMR(Access, MemberBaseType, MemberOffsetInBytes,
desc.Name);
FLBR.writeMemberType(DMR);
}
memberCount++;
}
TypeIndex FieldListIndex = FLBR.end(true);
TypeRecordKind Kind =
ClassDescriptor.IsStruct ? TypeRecordKind::Struct : TypeRecordKind::Class;
ClassOptions CO = GetCommonClassOptions();
ClassRecord CR(Kind, memberCount, CO, FieldListIndex,
TypeIndex(), TypeIndex(), ClassFieldsDescriptor.Size,
ClassDescriptor.Name, StringRef());
TypeIndex ClassIndex = TypeTable.writeKnownType(CR);
UserDefinedTypes.push_back(std::make_pair(ClassDescriptor.Name, ClassIndex.getIndex()));
return ClassIndex.getIndex();
}
示例10: assert
void CodeViewDebug::emitInlinedCallSite(const FunctionInfo &FI,
const DILocation *InlinedAt,
const InlineSite &Site) {
MCSymbol *InlineBegin = MMI->getContext().createTempSymbol(),
*InlineEnd = MMI->getContext().createTempSymbol();
assert(SubprogramToFuncId.count(Site.Inlinee));
TypeIndex InlineeIdx = SubprogramToFuncId[Site.Inlinee];
// SymbolRecord
OS.AddComment("Record length");
OS.emitAbsoluteSymbolDiff(InlineEnd, InlineBegin, 2); // RecordLength
OS.EmitLabel(InlineBegin);
OS.AddComment("Record kind: S_INLINESITE");
OS.EmitIntValue(SymbolRecordKind::S_INLINESITE, 2); // RecordKind
OS.AddComment("PtrParent");
OS.EmitIntValue(0, 4);
OS.AddComment("PtrEnd");
OS.EmitIntValue(0, 4);
OS.AddComment("Inlinee type index");
OS.EmitIntValue(InlineeIdx.getIndex(), 4);
unsigned FileId = maybeRecordFile(Site.Inlinee->getFile());
unsigned StartLineNum = Site.Inlinee->getLine();
SmallVector<unsigned, 3> SecondaryFuncIds;
collectInlineSiteChildren(SecondaryFuncIds, FI, Site);
OS.EmitCVInlineLinetableDirective(Site.SiteFuncId, FileId, StartLineNum,
FI.Begin, FI.End, SecondaryFuncIds);
OS.EmitLabel(InlineEnd);
for (const LocalVariable &Var : Site.InlinedLocals)
emitLocalVariable(Var);
// Recurse on child inlined call sites before closing the scope.
for (const DILocation *ChildSite : Site.ChildSites) {
auto I = FI.InlineSites.find(ChildSite);
assert(I != FI.InlineSites.end() &&
"child site not in function inline site map");
emitInlinedCallSite(FI, ChildSite, I->second);
}
// Close the scope.
OS.AddComment("Record length");
OS.EmitIntValue(2, 2); // RecordLength
OS.AddComment("Record kind: S_INLINESITE_END");
OS.EmitIntValue(SymbolRecordKind::S_INLINESITE_END, 2); // RecordKind
}
示例11:
void llvm::codeview::printTypeIndex(ScopedPrinter &Printer, StringRef FieldName,
TypeIndex TI, TypeCollection &Types) {
StringRef TypeName;
if (!TI.isNoneType()) {
if (TI.isSimple())
TypeName = TypeIndex::simpleTypeName(TI);
else
TypeName = Types.getTypeName(TI);
}
if (!TypeName.empty())
Printer.printHex(FieldName, TypeName, TI.getIndex());
else
Printer.printHex(FieldName, TI.getIndex());
}
示例12: remapIndex
bool TypeStreamMerger::remapIndex(TypeIndex &Idx, ArrayRef<TypeIndex> Map) {
// Simple types are unchanged.
if (Idx.isSimple())
return true;
// Check if this type index refers to a record we've already translated
// successfully. If it refers to a type later in the stream or a record we
// had to defer, defer it until later pass.
unsigned MapPos = slotForIndex(Idx);
if (MapPos < Map.size() && Map[MapPos] != Untranslated) {
Idx = Map[MapPos];
return true;
}
// If this is the second pass and this index isn't in the map, then it points
// outside the current type stream, and this is a corrupt record.
if (IsSecondPass && MapPos >= Map.size()) {
// FIXME: Print a more useful error. We can give the current record and the
// index that we think its pointing to.
LastError = joinErrors(std::move(*LastError), errorCorruptRecord());
}
++NumBadIndices;
// This type index is invalid. Remap this to "not translated by cvpack",
// and return failure.
Idx = Untranslated;
return false;
}
示例13:
StringRef ScalarTraits<TypeIndex>::input(StringRef Scalar, void *Ctx,
TypeIndex &S) {
uint32_t I;
StringRef Result = ScalarTraits<uint32_t>::input(Scalar, Ctx, I);
S.setIndex(I);
return Result;
}
示例14: FLRB
unsigned UserDefinedCodeViewTypesBuilder::GetEnumFieldListType(
uint64 Count, const EnumRecordTypeDescriptor *TypeRecords) {
FieldListRecordBuilder FLRB(TypeTable);
FLRB.begin();
#ifndef NDEBUG
uint64 MaxInt = (unsigned int)-1;
assert(Count <= MaxInt && "There are too many fields inside enum");
#endif
for (int i = 0; i < (int)Count; ++i) {
EnumRecordTypeDescriptor record = TypeRecords[i];
EnumeratorRecord ER(MemberAccess::Public, APSInt::getUnsigned(record.Value),
record.Name);
FLRB.writeMemberType(ER);
}
TypeIndex Type = FLRB.end(true);
return Type.getIndex();
}
示例15: GetCommonClassOptions
unsigned UserDefinedCodeViewTypesBuilder::GetEnumTypeIndex(
const EnumTypeDescriptor &TypeDescriptor,
const EnumRecordTypeDescriptor *TypeRecords) {
ClassOptions CO = GetCommonClassOptions();
unsigned FieldListIndex =
GetEnumFieldListType(TypeDescriptor.ElementCount, TypeRecords);
TypeIndex FieldListIndexType = TypeIndex(FieldListIndex);
TypeIndex ElementTypeIndex = TypeIndex(TypeDescriptor.ElementType);
EnumRecord EnumRecord(TypeDescriptor.ElementCount, CO, FieldListIndexType,
TypeDescriptor.Name, StringRef(),
ElementTypeIndex);
TypeIndex Type = TypeTable.writeKnownType(EnumRecord);
UserDefinedTypes.push_back(std::make_pair(TypeDescriptor.Name, Type.getIndex()));
return Type.getIndex();
}