• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TypeIndex类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中TypeIndex的典型用法代码示例。如果您正苦于以下问题:C++ TypeIndex类的具体用法?C++ TypeIndex怎么用?C++ TypeIndex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了TypeIndex类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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};
  }
}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:29,代码来源:DWARFLocationExpression.cpp


示例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>";
}
开发者ID:zhmz90,项目名称:llvm,代码行数:26,代码来源:TypeDumper.cpp


示例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;
}
开发者ID:Leedehai,项目名称:lld,代码行数:8,代码来源:PDB.cpp


示例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());
}
开发者ID:zhmz90,项目名称:llvm,代码行数:9,代码来源:TypeDumper.cpp


示例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());
}
开发者ID:bugsnag,项目名称:llvm,代码行数:10,代码来源:CVTypeDumper.cpp


示例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();
}
开发者ID:A-And,项目名称:corert,代码行数:11,代码来源:codeViewTypeBuilder.cpp


示例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);
    }
}
开发者ID:,项目名称:,代码行数:12,代码来源:


示例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);
}
开发者ID:CTSRD-CHERI,项目名称:cheribsd,代码行数:13,代码来源:SymbolCache.cpp


示例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();
}
开发者ID:A-And,项目名称:corert,代码行数:51,代码来源:codeViewTypeBuilder.cpp


示例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
}
开发者ID:littleblank,项目名称:llvm,代码行数:50,代码来源:CodeViewDebug.cpp


示例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());
}
开发者ID:CTSRD-CHERI,项目名称:cheribsd,代码行数:15,代码来源:TypeIndex.cpp


示例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;
}
开发者ID:BNieuwenhuizen,项目名称:llvm,代码行数:29,代码来源:TypeStreamMerger.cpp


示例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;
}
开发者ID:Leedehai,项目名称:llvm,代码行数:7,代码来源:CodeViewYAMLTypes.cpp


示例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();
}
开发者ID:A-And,项目名称:corert,代码行数:17,代码来源:codeViewTypeBuilder.cpp


示例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();
}
开发者ID:A-And,项目名称:corert,代码行数:18,代码来源:codeViewTypeBuilder.cpp


示例16: add_converter_variations

void TypeSystemInstance::add_converter_variations(TypeIndex from, TypeIndex to, p_conv_t conv)
{
    this->conv_graph.add_conv(from, to, conv);

/*
    // Add converters to make either type const.
    this->add_ptr_convs(from);
    this->add_ptr_convs(to);
*/
    auto from_info = from.get_info();
    auto to_info = to.get_info();

    // Reuse this converter for just the "to" obj const
    this->conv_graph.add_conv(from, get_index(to_info.as_const_value()), conv);

    // Reuse this converter for both from and to as const
    this->conv_graph.add_conv(get_index(from_info.as_const_value()), get_index(to_info.as_const_value()), conv);
}
开发者ID:,项目名称:,代码行数:18,代码来源:


示例17: has_type_index

bool TraceDbImpl::has_type_index(TypeIndex type)
{
    size_t id = type.get_id();

    if (id >= saved_type_indices.size())
        return false;
    else
        return saved_type_indices[id];
}
开发者ID:,项目名称:,代码行数:9,代码来源:


示例18: visitTypeBegin

Error TypeDumpVisitor::visitTypeBegin(CVType &Record, TypeIndex Index) {
  W->startLine() << getLeafTypeName(Record.Type);
  W->getOStream() << " (" << HexNumber(Index.getIndex()) << ")";
  W->getOStream() << " {\n";
  W->indent();
  W->printEnum("TypeLeafKind", unsigned(Record.Type),
               makeArrayRef(LeafTypeNames));
  return Error::success();
}
开发者ID:davidlt,项目名称:root,代码行数:9,代码来源:TypeDumpVisitor.cpp


示例19: set_has_type_index

void TraceDbImpl::set_has_type_index(TypeIndex type)
{
    size_t id = type.get_id();

    if (id >= saved_type_indices.size())
        saved_type_indices.resize(id+1);

    saved_type_indices[id] = true;
}
开发者ID:,项目名称:,代码行数:9,代码来源:


示例20: add_converter_simple

void TypeSystemInstance::add_converter_simple(TypeIndex from_type, TypeIndex to_type, p_conv_t conv)
{
    if (from_type.get_info().is_restricted)
    {
        stringstream msg;
        msg << "add_converter_simple error from_type is restricted " << from_type.description() << " " << from_type.get_id()
            << " to " << to_type.description() << " " << to_type.get_id() << " conv='" << conv->description() << "'";
        cout << msg.str() << endl;
        throw std::logic_error(msg.str());
    }

    this->conv_graph.add_conv(from_type, to_type, conv);
    //this->conv_graph.add_conv(from_type, get_index(from_type.get_info().as_restricted()), conv);
    //this->conv_graph.add_conv(to_type, get_index(to_type.get_info().as_restricted()), conv);

    if (!this->conv_graph.has_type(from_type))
    {
        stringstream msg;
        msg << "add_converter_simple missing just-added from type for conversion from " << from_type.description() << " " << from_type.get_id() << " to " << to_type.description() << " " << to_type.get_id() << " conv='" << conv->description() << "'";
        cout << msg.str() << endl;
        //throw std::logic_error(msg.str());
    }

    if (!this->conv_graph.has_type(to_type))
    {
        stringstream msg;
        msg << "add_converter_simple missing just-added to type for conversion from " << from_type.description() << " " << from_type.get_id() << " to " << to_type.description() << " " << to_type.get_id() << " conv='" << conv->description() << "'";
        cout << msg.str() << endl;
        //throw std::logic_error(msg.str());
    }

    if (!has_conv(from_type, to_type))
    {
        bool test_again = has_conv(from_type, to_type);
        stringstream msg;
        msg << test_again;
        msg << "add_converter_simple missing just-added conversion from " << from_type.description() << " " << from_type.get_id() << " to " << to_type.description() << " " << to_type.get_id() << " conv='" << conv->description() << "'";
        cout << msg.str() << endl;
        //throw std::logic_error(msg.str());
    }
}
开发者ID:,项目名称:,代码行数:41,代码来源:



注:本文中的TypeIndex类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TypeInfo类代码示例发布时间:2022-05-31
下一篇:
C++ TypeIdentifierPtr类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap