当前位置: 首页>>代码示例>>C++>>正文


C++ Twine::str方法代码示例

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


在下文中一共展示了Twine::str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Data

/// \brief Construct a triple from the string representation provided.
///
/// This stores the string representation and parses the various pieces into
/// enum members.
Triple::Triple(const Twine &Str)
    : Data(Str.str()), Arch(UnknownArch), SubArch(NoSubArch),
      Vendor(UnknownVendor), OS(UnknownOS), Environment(UnknownEnvironment),
      ObjectFormat(UnknownObjectFormat) {
  // Do minimal parsing by hand here.
  SmallVector<StringRef, 4> Components;
  StringRef(Data).split(Components, '-', /*MaxSplit*/ 3);
  if (Components.size() > 0) {
    Arch = parseArch(Components[0]);
    SubArch = parseSubArch(Components[0]);
    if (Components.size() > 1) {
      Vendor = parseVendor(Components[1]);
      if (Components.size() > 2) {
        OS = parseOS(Components[2]);
        if (Components.size() > 3) {
          Environment = parseEnvironment(Components[3]);
          ObjectFormat = parseFormat(Components[3]);
        }
      }
    }
  }
  if (ObjectFormat == UnknownObjectFormat)
    ObjectFormat = getDefaultFormat(*this);
}
开发者ID:RichardsonAlex,项目名称:llvm-1,代码行数:28,代码来源:Triple.cpp

示例2: Prefix

MCSection *HexagonTargetObjectFile::selectSmallSectionForGlobal(
      const GlobalValue *GV, SectionKind Kind, Mangler &Mang,
      const TargetMachine &TM) const {
  const Type *GTy = GV->getType()->getElementType();
  unsigned Size = getSmallestAddressableSize(GTy, GV, TM);

  // If we have -ffunction-section or -fdata-section then we should emit the
  // global value to a unique section specifically for it... even for sdata.
  bool EmitUniquedSection = TM.getDataSections();

  TRACE("Small data. Size(" << Size << ")");
  // Handle Small Section classification here.
  if (Kind.isBSS() || Kind.isBSSLocal()) {
    // If -mno-sort-sda is not set, find out smallest accessible entity in
    // declaration and add it to the section name string.
    // Note. It does not track the actual usage of the value, only its de-
    // claration. Also, compiler adds explicit pad fields to some struct
    // declarations - they are currently counted towards smallest addres-
    // sable entity.
    if (NoSmallDataSorting) {
      TRACE(" default sbss\n");
      return SmallBSSSection;
    }

    StringRef Prefix(".sbss");
    SmallString<128> Name(Prefix);
    Name.append(getSectionSuffixForSize(Size));

    if (EmitUniquedSection) {
      Name.append(".");
      Name.append(GV->getName());
    }
    TRACE(" unique sbss(" << Name << ")\n");
    return getContext().getELFSection(Name.str(), ELF::SHT_NOBITS,
                ELF::SHF_WRITE | ELF::SHF_ALLOC | ELF::SHF_HEX_GPREL);
  }

  if (Kind.isCommon()) {
    // This is purely for LTO+Linker Script because commons don't really have a
    // section. However, the BitcodeSectionWriter pass will query for the
    // sections of commons (and the linker expects us to know their section) so
    // we'll return one here.
    if (NoSmallDataSorting)
      return BSSSection;

    Twine Name = Twine(".scommon") + getSectionSuffixForSize(Size);
    TRACE(" small COMMON (" << Name << ")\n");

    return getContext().getELFSection(Name.str(), ELF::SHT_NOBITS,
                                      ELF::SHF_WRITE | ELF::SHF_ALLOC |
                                      ELF::SHF_HEX_GPREL);
  }

  // We could have changed sdata object to a constant... in this
  // case the Kind could be wrong for it.
  if (Kind.isMergeableConst()) {
    TRACE(" const_object_as_data ");
    const GlobalVariable *GVar = dyn_cast<GlobalVariable>(GV);
    if (GVar->hasSection() && isSmallDataSection(GVar->getSection()))
      Kind = SectionKind::getData();
  }

  if (Kind.isData()) {
    if (NoSmallDataSorting) {
      TRACE(" default sdata\n");
      return SmallDataSection;
    }

    StringRef Prefix(".sdata");
    SmallString<128> Name(Prefix);
    Name.append(getSectionSuffixForSize(Size));

    if (EmitUniquedSection) {
      Name.append(".");
      Name.append(GV->getName());
    }
    TRACE(" unique sdata(" << Name << ")\n");
    return getContext().getELFSection(Name.str(), ELF::SHT_PROGBITS,
                ELF::SHF_WRITE | ELF::SHF_ALLOC | ELF::SHF_HEX_GPREL);
  }

  TRACE("default ELF section\n");
  // Otherwise, we work the same as ELF.
  return TargetLoweringObjectFileELF::SelectSectionForGlobal(GV, Kind,
              Mang, TM);
}
开发者ID:AnachroNia,项目名称:llvm,代码行数:86,代码来源:HexagonTargetObjectFile.cpp

示例3: can_execute

bool can_execute(const Twine &Path) {
  return ls::Path(Path.str()).canExecute();
}
开发者ID:GameFusion,项目名称:ldc,代码行数:3,代码来源:ldmd.cpp

示例4: cacheDirectory

OnDiskCodeCompletionCache::OnDiskCodeCompletionCache(Twine cacheDirectory)
    : cacheDirectory(cacheDirectory.str()) {}
开发者ID:DevAndArtist,项目名称:swift,代码行数:2,代码来源:CodeCompletionCache.cpp

示例5: archive

static Error
malformedError(Twine Msg) {
  std::string StringMsg = "truncated or malformed archive (" + Msg.str() + ")";
  return make_error<GenericBinaryError>(std::move(StringMsg),
                                        object_error::parse_failed);
}
开发者ID:clockmaker002,项目名称:llvm,代码行数:6,代码来源:Archive.cpp

示例6:

Expr::Expr(Twine Name)
  : Expr_(GiNaC::symbol(Name.str())) {
}
开发者ID:lisqu,项目名称:selective-page-migration-ccnuma,代码行数:3,代码来源:Expr.cpp

示例7: getUnderlyingFS

 ErrorOr<vfs::Status> status(const Twine &Path) override {
   if (auto S = StatCache.lookup(Path.str()))
     return *S;
   return getUnderlyingFS().status(Path);
 }
开发者ID:vmiklos,项目名称:clang-tools-extra,代码行数:5,代码来源:FS.cpp

示例8: Msg

StringError::StringError(const Twine &S, std::error_code EC)
    : Msg(S.str()), EC(EC), PrintMsgOnly(true) {}
开发者ID:alex-t,项目名称:llvm,代码行数:2,代码来源:Error.cpp

示例9: Msg

GenericBinaryError::GenericBinaryError(Twine Msg, object_error ECOverride)
    : Msg(Msg.str()) {
  setErrorCode(make_error_code(ECOverride));
}
开发者ID:fcrick,项目名称:llvm,代码行数:4,代码来源:Error.cpp

示例10: addPathIfExists

void tools::addPathIfExists(const Driver &D, const Twine &Path,
                            ToolChain::path_list &Paths) {
  if (D.getVFS().exists(Path))
    Paths.push_back(Path.str());
}
开发者ID:jacobly0,项目名称:llvm-z80,代码行数:5,代码来源:CommonArgs.cpp

示例11: report

bool FileRemapper::report(const Twine &err, DiagnosticsEngine &Diag) {
  Diag.Report(Diag.getCustomDiagID(DiagnosticsEngine::Error, "%0"))
      << err.str();
  return true;
}
开发者ID:Xmister,项目名称:clang-onex,代码行数:5,代码来源:FileRemapper.cpp

示例12: createError

static Error createError(const Twine &Err) {
  return make_error<StringError>(StringRef(Err.str()),
                                 object_error::parse_failed);
}
开发者ID:dongjinxian,项目名称:llvm,代码行数:4,代码来源:COFFModuleDefinition.cpp

示例13: pl_reportViolation

    foreign_t pl_reportViolation(term_t RuleT, term_t MsgT, term_t CulpritsT) {
      // FIXME: all 'return FALSE' should be PL_warning'
      const char *Rule;
      if ( !PL_get_atom_chars(RuleT, (char **) &Rule)) return FALSE;
      const char *Msg;
      if ( !PL_get_atom_chars(MsgT, (char **) &Msg)) return FALSE;
      // atom_t StmtA = PL_new_atom("stmt");
      // functor_t StmtF = PL_new_functor(StmtA, 1);
      atom_t NamedDeclA = PL_new_atom("NamedDecl");
      functor_t NamedDeclF = PL_new_functor(NamedDeclA, 2);

      // functor_t SortF;
      // if ( !PL_get_functor(LocT, &SortF)) return FALSE;
      // term_t ElemT = PL_new_term_ref();
      // if ( !PL_get_arg(1, LocT, ElemT)) return FALSE;
      // SourceLocation SL;
      // if ( PL_unify_functor(LocT, StmtF)) {
      //   Stmt *S;
      //   if ( !PL_get_pointer(ElemT, (void **) &S)) return FALSE;
      //   SL = S->getLocStart();
      // }
      // // FIXME: same for Decl and other elems.

      const CompilerInstance &CI = getCompilationInfo()->getCompilerInstance();
      DiagnosticsEngine &DE = CI.getDiagnostics();
      Twine MsgWithRule = Twine(Rule) + Twine(": ") + Twine(Msg);
      unsigned DiagId = DE.getCustomDiagID(DiagnosticsEngine::Warning,
                                           MsgWithRule.str());
      DiagnosticBuilder DB = DE.Report(DiagId);

      term_t HeadT = PL_new_term_ref();
      term_t ListT = PL_copy_term_ref(CulpritsT); // copy as we need to write
      while(PL_get_list(ListT, HeadT, ListT)) {
        term_t ElemT = PL_new_term_ref();
        if ( !PL_get_arg(1, HeadT, ElemT)) return FALSE;
        if ( PL_unify_functor(HeadT, NamedDeclF)) {
          const NamedDecl *ND;
          if ( !PL_get_pointer(ElemT, (void **) &ND)) return FALSE;
          DB << ND->getDeclName();
          continue;
        }
        // FIXME: same for Type and other elems
      }
      DB.~DiagnosticBuilder();  // Emits the diagnostic

      ListT = PL_copy_term_ref(CulpritsT);
      while(PL_get_list(ListT, HeadT, ListT)) {
        functor_t SortF;
        if ( !PL_get_functor(HeadT, &SortF)) return FALSE;
        term_t ElemT = PL_new_term_ref();
        if ( !PL_get_arg(1, HeadT, ElemT)) return FALSE;
        term_t MsgT = PL_new_term_ref();
        if ( !PL_get_arg(2, HeadT, MsgT)) return FALSE;
        const char *Msg;
        if ( !PL_get_atom_chars(MsgT, (char **) &Msg)) return FALSE;
        if ( PL_unify_functor(HeadT, NamedDeclF)) {
          const NamedDecl *ND;
          if ( !PL_get_pointer(ElemT, (void **) &ND)) return FALSE;
          DiagId = DE.getCustomDiagID(DiagnosticsEngine::Note, Msg);
          DiagnosticBuilder DB = DE.Report(ND->getLocStart(), DiagId);
          DB << ND->getDeclName();
          DB.~DiagnosticBuilder(); // Emits the diagnostic
          continue;
        }
        // FIXME: same for Type and other elems
      }

      return TRUE;
    }
开发者ID:ajasmin,项目名称:Crisp,代码行数:69,代码来源:ClangPrologPredicates.cpp

示例14: Name

NamedMDNode::NamedMDNode(const Twine &N)
  : Name(N.str()), Parent(0),
    Operands(new SmallVector<TrackingVH<MDNode>, 4>()) {
}
开发者ID:QuentinFiard,项目名称:llvm,代码行数:4,代码来源:Metadata.cpp

示例15: error

void
BuildSystemFrontendDelegate::error(const Twine& message) {
  error("", {}, message.str());
}
开发者ID:apple,项目名称:swift-llbuild,代码行数:4,代码来源:BuildSystemFrontend.cpp


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