本文整理汇总了C++中CVType类的典型用法代码示例。如果您正苦于以下问题:C++ CVType类的具体用法?C++ CVType怎么用?C++ CVType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CVType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ti
Error UdtRecordCompleter::visitKnownMember(CVMemberRecord &cvr,
DataMemberRecord &data_member) {
uint64_t offset = data_member.FieldOffset * 8;
uint32_t bitfield_width = 0;
TypeIndex ti(data_member.Type);
if (!ti.isSimple()) {
CVType cvt = m_tpi.getType(ti);
if (cvt.kind() == LF_BITFIELD) {
BitFieldRecord bfr;
llvm::cantFail(TypeDeserializer::deserializeAs<BitFieldRecord>(cvt, bfr));
offset += bfr.BitOffset;
bitfield_width = bfr.BitSize;
ti = bfr.Type;
}
}
clang::QualType member_qt = m_ast_builder.GetOrCreateType(PdbTypeSymId(ti));
m_ast_builder.CompleteType(member_qt);
lldb::AccessType access = TranslateMemberAccess(data_member.getAccess());
clang::FieldDecl *decl = ClangASTContext::AddFieldToRecordType(
m_derived_ct, data_member.Name, m_ast_builder.ToCompilerType(member_qt),
access, bitfield_width);
// FIXME: Add a PdbSymUid namespace for field list members and update
// the m_uid_to_decl map with this decl.
m_layout.field_offsets.insert(std::make_pair(decl, offset));
return Error::success();
}
示例2: JC
Expected<uint32_t> llvm::pdb::hashTypeRecord(const CVType &Rec) {
switch (Rec.kind()) {
case LF_CLASS:
case LF_STRUCTURE:
case LF_INTERFACE:
return getHashForUdt<ClassRecord>(Rec);
case LF_UNION:
return getHashForUdt<UnionRecord>(Rec);
case LF_ENUM:
return getHashForUdt<EnumRecord>(Rec);
case LF_UDT_SRC_LINE:
return getSourceLineHash<UdtSourceLineRecord>(Rec);
case LF_UDT_MOD_SRC_LINE:
return getSourceLineHash<UdtModSourceLineRecord>(Rec);
default:
break;
}
// Run CRC32 over the bytes. This corresponds to `hashBufv8`.
JamCRC JC(/*Init=*/0U);
ArrayRef<char> Bytes(reinterpret_cast<const char *>(Rec.data().data()),
Rec.data().size());
JC.update(Bytes);
return JC.getCRC();
}
示例3: remapType
Error TypeStreamMerger::remapType(const CVType &Type) {
auto DoSerialize = [this, Type]() -> ArrayRef<uint8_t> {
RemappedType R(Type);
SmallVector<TiReference, 32> Refs;
discoverTypeIndices(Type.RecordData, Refs);
if (!remapIndices(R, Refs))
return {};
return serializeRemapped(R);
};
TypeIndex DestIdx = Untranslated;
if (UseGlobalHashes) {
GlobalTypeTableBuilder &Dest =
isIdRecord(Type.kind()) ? *DestGlobalIdStream : *DestGlobalTypeStream;
GloballyHashedType H = GlobalHashes[CurIndex.toArrayIndex()];
DestIdx = Dest.insertRecordAs(H, DoSerialize);
} else {
MergingTypeTableBuilder &Dest =
isIdRecord(Type.kind()) ? *DestIdStream : *DestTypeStream;
auto Data = DoSerialize();
if (!Data.empty())
DestIdx = Dest.insertRecordBytes(Data);
}
addMapping(DestIdx);
++CurIndex;
assert((IsSecondPass || IndexMap.size() == slotForIndex(CurIndex)) &&
"visitKnownRecord should add one index map entry");
return Error::success();
}
示例4: 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};
}
}
示例5: visitKnownRecord
static Error visitKnownRecord(CVType &Record, TypeVisitorCallbacks &Callbacks) {
TypeRecordKind RK = static_cast<TypeRecordKind>(Record.kind());
T KnownRecord(RK);
if (auto EC = Callbacks.visitKnownRecord(Record, KnownRecord))
return EC;
return Error::success();
}
示例6: getHashForUdt
static Expected<uint32_t> getHashForUdt(const CVType &Rec) {
T Deserialized;
if (auto E = TypeDeserializer::deserializeAs(const_cast<CVType &>(Rec),
Deserialized))
return std::move(E);
return getHashForUdt(Deserialized, Rec.data());
}
示例7: switch
size_t lldb_private::npdb::GetSizeOfType(PdbTypeSymId id,
llvm::pdb::TpiStream &tpi) {
if (id.index.isSimple()) {
switch (id.index.getSimpleMode()) {
case SimpleTypeMode::Direct:
return GetTypeSizeForSimpleKind(id.index.getSimpleKind());
case SimpleTypeMode::NearPointer32:
case SimpleTypeMode::FarPointer32:
return 4;
case SimpleTypeMode::NearPointer64:
return 8;
case SimpleTypeMode::NearPointer128:
return 16;
default:
break;
}
return 0;
}
TypeIndex index = id.index;
if (IsForwardRefUdt(index, tpi))
index = llvm::cantFail(tpi.findFullDeclForForwardRef(index));
CVType cvt = tpi.getType(index);
switch (cvt.kind()) {
case LF_MODIFIER:
return GetSizeOfType({LookThroughModifierRecord(cvt)}, tpi);
case LF_ENUM: {
EnumRecord record;
llvm::cantFail(TypeDeserializer::deserializeAs<EnumRecord>(cvt, record));
return GetSizeOfType({record.UnderlyingType}, tpi);
}
case LF_POINTER:
return GetSizeOfTypeInternal<PointerRecord>(cvt);
case LF_ARRAY:
return GetSizeOfTypeInternal<ArrayRecord>(cvt);
case LF_CLASS:
case LF_STRUCTURE:
case LF_INTERFACE:
return GetSizeOfTypeInternal<ClassRecord>(cvt);
case LF_UNION:
return GetSizeOfTypeInternal<UnionRecord>(cvt);
default:
break;
}
return 0;
}
示例8: visitTypeEnd
Error TypeDumpVisitor::visitTypeEnd(CVType &Record) {
if (PrintRecordBytes)
W->printBinaryBlock("LeafData", getBytesAsCharacters(Record.content()));
W->unindent();
W->startLine() << "}\n";
return Error::success();
}
示例9: fromCodeViewRecordImpl
static inline Expected<LeafRecord> fromCodeViewRecordImpl(CVType Type) {
LeafRecord Result;
auto Impl = std::make_shared<LeafRecordImpl<T>>(Type.kind());
if (auto EC = Impl->fromCodeViewRecord(Type))
return std::move(EC);
Result.Leaf = Impl;
return Result;
}
示例10: TTB
ArrayRef<uint8_t> llvm::CodeViewYAML::toDebugT(ArrayRef<LeafRecord> Leafs,
BumpPtrAllocator &Alloc) {
TypeTableBuilder TTB(Alloc, false);
uint32_t Size = sizeof(uint32_t);
for (const auto &Leaf : Leafs) {
CVType T = Leaf.toCodeViewRecord(TTB);
Size += T.length();
assert(T.length() % 4 == 0 && "Improper type record alignment!");
}
uint8_t *ResultBuffer = Alloc.Allocate<uint8_t>(Size);
MutableArrayRef<uint8_t> Output(ResultBuffer, Size);
BinaryStreamWriter Writer(Output, support::little);
ExitOnError Err("Error writing type record to .debug$T section");
Err(Writer.writeInteger<uint32_t>(COFF::DEBUG_SECTION_MAGIC));
for (const auto &R : TTB.records()) {
Err(Writer.writeBytes(R));
}
assert(Writer.bytesRemaining() == 0 && "Didn't write all type record bytes!");
return Output;
}
示例11: switch
Expected<LeafRecord> LeafRecord::fromCodeViewRecord(CVType Type) {
#define TYPE_RECORD(EnumName, EnumVal, ClassName) \
case EnumName: \
return fromCodeViewRecordImpl<ClassName##Record>(Type);
#define TYPE_RECORD_ALIAS(EnumName, EnumVal, AliasName, ClassName) \
TYPE_RECORD(EnumName, EnumVal, ClassName)
#define MEMBER_RECORD(EnumName, EnumVal, ClassName)
#define MEMBER_RECORD_ALIAS(EnumName, EnumVal, AliasName, ClassName)
switch (Type.kind()) {
#include "llvm/DebugInfo/CodeView/CodeViewTypes.def"
default: { llvm_unreachable("Unknown leaf kind!"); }
}
return make_error<CodeViewError>(cv_error_code::corrupt_record);
}
示例12: m_id
UdtRecordCompleter::UdtRecordCompleter(PdbTypeSymId id,
CompilerType &derived_ct,
clang::TagDecl &tag_decl,
PdbAstBuilder &ast_builder,
TpiStream &tpi)
: m_id(id), m_derived_ct(derived_ct), m_tag_decl(tag_decl),
m_ast_builder(ast_builder), m_tpi(tpi) {
CVType cvt = m_tpi.getType(m_id.index);
switch (cvt.kind()) {
case LF_ENUM:
llvm::cantFail(TypeDeserializer::deserializeAs<EnumRecord>(cvt, m_cvr.er));
break;
case LF_UNION:
llvm::cantFail(TypeDeserializer::deserializeAs<UnionRecord>(cvt, m_cvr.ur));
break;
case LF_CLASS:
case LF_STRUCTURE:
llvm::cantFail(TypeDeserializer::deserializeAs<ClassRecord>(cvt, m_cvr.cr));
break;
default:
llvm_unreachable("unreachable!");
}
}
示例13: switch
bool llvm::codeview::isUdtForwardRef(CVType CVT) {
ClassOptions UdtOptions = ClassOptions::None;
switch (CVT.kind()) {
case LF_STRUCTURE:
case LF_CLASS:
case LF_INTERFACE:
UdtOptions = getUdtOptions<ClassRecord>(std::move(CVT));
break;
case LF_ENUM:
UdtOptions = getUdtOptions<EnumRecord>(std::move(CVT));
break;
case LF_UNION:
UdtOptions = getUdtOptions<UnionRecord>(std::move(CVT));
break;
default:
return false;
}
return (UdtOptions & ClassOptions::ForwardReference) != ClassOptions::None;
}
示例14: create
CVTagRecord CVTagRecord::create(CVType type) {
assert(IsTagRecord(type) && "type is not a tag record!");
switch (type.kind()) {
case LF_CLASS:
case LF_STRUCTURE:
case LF_INTERFACE: {
ClassRecord cr;
llvm::cantFail(TypeDeserializer::deserializeAs<ClassRecord>(type, cr));
return CVTagRecord(std::move(cr));
}
case LF_UNION: {
UnionRecord ur;
llvm::cantFail(TypeDeserializer::deserializeAs<UnionRecord>(type, ur));
return CVTagRecord(std::move(ur));
}
case LF_ENUM: {
EnumRecord er;
llvm::cantFail(TypeDeserializer::deserializeAs<EnumRecord>(type, er));
return CVTagRecord(std::move(er));
}
default:
llvm_unreachable("Unreachable!");
}
}
示例15: GetFirstPointer
//Special override for CVImageType
PrecisionType * GetFirstPointer(CVImageType::Pointer in)
{
CVType * firstCovariantVectorX = in->GetBufferPointer();
return firstCovariantVectorX->GetDataPointer();
}