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

C++ llvm::StringRef类代码示例

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

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



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

示例1: edit_distance

// Compute the edit distance between the two given strings.
unsigned StringRef::edit_distance(llvm::StringRef Other,
                                  bool AllowReplacements,
                                  unsigned MaxEditDistance) {
  return llvm::ComputeEditDistance(
      llvm::ArrayRef<char>(data(), size()),
      llvm::ArrayRef<char>(Other.data(), Other.size()),
      AllowReplacements, MaxEditDistance);
}
开发者ID:32bitmicro,项目名称:llvm,代码行数:9,代码来源:StringRef.cpp


示例2: edit_distance

// Compute the edit distance between the two given strings.
unsigned StringRef::edit_distance(llvm::StringRef Other,
                                  bool AllowReplacements,
                                  unsigned MaxEditDistance) const {
  return llvm::ComputeEditDistance(
      makeArrayRef(data(), size()),
      makeArrayRef(Other.data(), Other.size()),
      AllowReplacements, MaxEditDistance);
}
开发者ID:hsorby,项目名称:opencor,代码行数:9,代码来源:StringRef.cpp


示例3: if

lldb::ScriptLanguage
ScriptInterpreter::StringToLanguage(const llvm::StringRef &language) {
  if (language.equals_lower(LanguageToString(eScriptLanguageNone)))
    return eScriptLanguageNone;
  else if (language.equals_lower(LanguageToString(eScriptLanguagePython)))
    return eScriptLanguagePython;
  else
    return eScriptLanguageUnknown;
}
开发者ID:CodaFi,项目名称:swift-lldb,代码行数:9,代码来源:ScriptInterpreter.cpp


示例4: SetString

void PythonString::SetString(llvm::StringRef string) {
#if PY_MAJOR_VERSION >= 3
  PyObject *unicode = PyUnicode_FromStringAndSize(string.data(), string.size());
  PythonObject::Reset(PyRefType::Owned, unicode);
#else
  PyObject *str = PyString_FromStringAndSize(string.data(), string.size());
  PythonObject::Reset(PyRefType::Owned, str);
#endif
}
开发者ID:llvm-project,项目名称:lldb,代码行数:9,代码来源:PythonDataObjects.cpp


示例5: return

bool
impl::ElfMatch_x86_amd64(llvm::StringRef arch_keyword,
                         llvm::StringRef arch_machine,
                         ElfClass cls)
{
    return (arch_keyword.equals_lower("x86") &&
            arch_machine.equals_lower("amd64") &&
            (cls == ELFCLASSNONE || cls == ELFCLASS64));
}
开发者ID:BrianGladman,项目名称:yasm-nextgen,代码行数:9,代码来源:Elf_x86_amd64.cpp


示例6: return

 Type *vaListType() override {
   // We need to pass the actual va_list type for correct mangling. Simply
   // using TypeIdentifier here is a bit wonky but works, as long as the name
   // is actually available in the scope (this is what DMD does, so if a better
   // solution is found there, this should be adapted).
   static const llvm::StringRef ident = "__va_list";
   return (createTypeIdentifier(
       Loc(), Identifier::idPool(ident.data(), ident.size())));
 }
开发者ID:John-Colvin,项目名称:ldc,代码行数:9,代码来源:abi-arm.cpp


示例7: doesNoDiscardMacroExist

static bool doesNoDiscardMacroExist(ASTContext &Context,
                                    const llvm::StringRef &MacroId) {
  // Don't check for the Macro existence if we are using an attribute
  // either a C++17 standard attribute or pre C++17 syntax
  if (MacroId.startswith("[[") || MacroId.startswith("__attribute__"))
    return true;

  // Otherwise look up the macro name in the context to see if its defined.
  return Context.Idents.get(MacroId).hasMacroDefinition();
}
开发者ID:ingowald,项目名称:llvm-project,代码行数:10,代码来源:UseNodiscardCheck.cpp


示例8: emitRecord

void ClangDocBitcodeWriter::emitRecord(llvm::StringRef Str, RecordId ID) {
  assert(RecordIdNameMap[ID] && "Unknown RecordId.");
  assert(RecordIdNameMap[ID].Abbrev == &StringAbbrev &&
         "Abbrev type mismatch.");
  if (!prepRecordData(ID, !Str.empty()))
    return;
  assert(Str.size() < (1U << BitCodeConstants::StringLengthSize));
  Record.push_back(Str.size());
  Stream.EmitRecordWithBlob(Abbrevs.get(ID), Record, Str);
}
开发者ID:vmiklos,项目名称:clang-tools-extra,代码行数:10,代码来源:BitcodeWriter.cpp


示例9: demangleTypeAsString

std::string Context::demangleTypeAsString(llvm::StringRef MangledName,
                                          const DemangleOptions &Options) {
  NodePointer root = demangleTypeAsNode(MangledName);
  if (!root) return MangledName.str();
  
  std::string demangling = nodeToString(root, Options);
  if (demangling.empty())
    return MangledName.str();
  return demangling;
}
开发者ID:DevAndArtist,项目名称:swift,代码行数:10,代码来源:Context.cpp


示例10: if

lldb::SymbolType
ObjectFile::GetSymbolTypeFromName(llvm::StringRef name,
                                  lldb::SymbolType symbol_type_hint) {
  if (!name.empty()) {
    if (name.startswith("_T")) {
      // Swift
      if (name.startswith("_TM"))
        return lldb::eSymbolTypeMetadata;
      if (name.startswith("_TWvd"))
        return lldb::eSymbolTypeIVarOffset;
    } else if (name.startswith("_OBJC_")) {
      // ObjC
      if (name.startswith("_OBJC_CLASS_$_"))
        return lldb::eSymbolTypeObjCClass;
      if (name.startswith("_OBJC_METACLASS_$_"))
        return lldb::eSymbolTypeObjCMetaClass;
      if (name.startswith("_OBJC_IVAR_$_"))
        return lldb::eSymbolTypeObjCIVar;
    } else if (name.startswith(".objc_class_name_")) {
      // ObjC v1
      return lldb::eSymbolTypeObjCClass;
    }
  }
  return symbol_type_hint;
}
开发者ID:CodaFi,项目名称:swift-lldb,代码行数:25,代码来源:ObjectFile.cpp


示例11: EscapeBackticks

static void EscapeBackticks(llvm::StringRef str, std::string &dst) {
  dst.clear();
  dst.reserve(str.size());

  for (size_t i = 0, e = str.size(); i != e; ++i) {
    char c = str[i];
    if (c == '`') {
      if (i == 0 || str[i - 1] != '\\')
        dst += '\\';
    }
    dst += c;
  }
}
开发者ID:llvm-project,项目名称:lldb,代码行数:13,代码来源:OptionValueFormatEntity.cpp


示例12: symbol

Symbol symbol(llvm::StringRef QName) {
  Symbol Sym;
  Sym.ID = SymbolID(QName.str());
  size_t Pos = QName.rfind("::");
  if (Pos == llvm::StringRef::npos) {
    Sym.Name = QName;
    Sym.Scope = "";
  } else {
    Sym.Name = QName.substr(Pos + 2);
    Sym.Scope = QName.substr(0, Pos + 2);
  }
  return Sym;
}
开发者ID:ingowald,项目名称:llvm-project,代码行数:13,代码来源:TestIndex.cpp


示例13: SetGlobalWPIError

void ErrorBase::SetGlobalWPIError(llvm::StringRef errorMessage,
                                  llvm::StringRef contextMessage,
                                  llvm::StringRef filename,
                                  llvm::StringRef function,
                                  uint32_t lineNumber) {
  std::string err = errorMessage.str() + ": " + contextMessage.str();

  std::lock_guard<priority_mutex> mutex(_globalErrorMutex);
  if (_globalError.GetCode() != 0) {
    _globalError.Clear();
  }
  _globalError.Set(-1, err, filename, function, lineNumber, nullptr);
}
开发者ID:frc1678,项目名称:third-party,代码行数:13,代码来源:ErrorBase.cpp


示例14: Directory

MCLDDirectory::MCLDDirectory(llvm::StringRef pName)
  : Directory(), m_Name(pName.data(), pName.size()) {
  Directory::m_Path.assign(pName.str());

  if (!Directory::m_Path.empty())
    m_bInSysroot = ('=' == Directory::m_Path.native()[0]);

  Directory::m_Path.m_append_separator_if_needed();
  if (m_bInSysroot)
    Directory::m_Path.native().erase(Directory::m_Path.native().begin());
  else
    detail::open_dir(*this);
}
开发者ID:Proshivalskiy,项目名称:MT6582_kernel_source,代码行数:13,代码来源:MCLDDirectory.cpp


示例15: GenerateAutoloadingMap

  void Interpreter::GenerateAutoloadingMap(llvm::StringRef inFile,
                                           llvm::StringRef outFile,
                                           bool enableMacros,
                                           bool enableLogs) {

    const char *const dummy="cling";
    // Create an interpreter without any runtime, producing the fwd decls.
    cling::Interpreter fwdGen(1, &dummy, nullptr, true);

    // Copy the same header search options to the new instance.
    Preprocessor& fwdGenPP = fwdGen.getCI()->getPreprocessor();
    HeaderSearchOptions headerOpts = getCI()->getHeaderSearchOpts();
    clang::ApplyHeaderSearchOptions(fwdGenPP.getHeaderSearchInfo(), headerOpts,
                                    fwdGenPP.getLangOpts(),
                                    fwdGenPP.getTargetInfo().getTriple());


    CompilationOptions CO;
    CO.DeclarationExtraction = 0;
    CO.ValuePrinting = 0;
    CO.ResultEvaluation = 0;
    CO.DynamicScoping = 0;
    CO.Debug = isPrintingDebug();


    std::string includeFile = std::string("#include \"") + inFile.str() + "\"";
    cling::Transaction* T = fwdGen.m_IncrParser->Parse(includeFile , CO);

    // If this was already #included we will get a T == 0.
    if (!T)
      return;

    std::string err;
    llvm::raw_fd_ostream out(outFile.data(), err,
                             llvm::sys::fs::OpenFlags::F_None);
    if (enableLogs){
      llvm::raw_fd_ostream log(llvm::Twine(outFile).concat(llvm::Twine(".skipped")).str().c_str(),
                             err, llvm::sys::fs::OpenFlags::F_None);
      log << "Generated for :" << inFile << "\n";
      ForwardDeclPrinter visitor(out, log, fwdGen.getSema().getSourceManager(), *T);
      visitor.printStats();
    }
    else {
      llvm::raw_null_ostream sink;
      ForwardDeclPrinter visitor(out, sink, fwdGen.getSema().getSourceManager(), *T);
    }
    // Avoid assertion in the ~IncrementalParser.
    T->setState(Transaction::kCommitted);
    // unload(1);
    return;
  }
开发者ID:aurelie-flandi,项目名称:root,代码行数:51,代码来源:Interpreter.cpp


示例16: WriteString

void WireEncoder::WriteString(llvm::StringRef str) {
  // length
  std::size_t len = str.size();
  if (m_proto_rev < 0x0300u) {
    if (len > 0xffff) len = 0xffff; // Limited to 64K length; truncate
    Write16(len);
  } else
    WriteUleb128(len);

  // contents
  Reserve(len);
  std::memcpy(m_cur, str.data(), len);
  m_cur += len;
}
开发者ID:gmckaskle,项目名称:ntcore,代码行数:14,代码来源:WireEncoder.cpp


示例17: PreprocessingDirective

InclusionDirective::InclusionDirective(PreprocessingRecord &PPRec,
                                       InclusionKind Kind, 
                                       llvm::StringRef FileName, 
                                       bool InQuotes, const FileEntry *File, 
                                       SourceRange Range)
  : PreprocessingDirective(InclusionDirectiveKind, Range), 
    InQuotes(InQuotes), Kind(Kind), File(File) 
{ 
  char *Memory 
    = (char*)PPRec.Allocate(FileName.size() + 1, llvm::alignOf<char>());
  memcpy(Memory, FileName.data(), FileName.size());
  Memory[FileName.size()] = 0;
  this->FileName = llvm::StringRef(Memory, FileName.size());
}
开发者ID:5432935,项目名称:crossbridge,代码行数:14,代码来源:PreprocessingRecord.cpp


示例18: GetTypeAsCString

lldb::OptionValueSP
OptionValueDictionary::GetSubValue(const ExecutionContext *exe_ctx,
                                   llvm::StringRef name, bool will_modify,
                                   Status &error) const {
  lldb::OptionValueSP value_sp;
  if (name.empty())
    return nullptr;

  llvm::StringRef left, temp;
  std::tie(left, temp) = name.split('[');
  if (left.size() == name.size()) {
    error.SetErrorStringWithFormat("invalid value path '%s', %s values only "
      "support '[<key>]' subvalues where <key> "
      "a string value optionally delimited by "
      "single or double quotes",
      name.str().c_str(), GetTypeAsCString());
    return nullptr;
  }
  assert(!temp.empty());

  llvm::StringRef key, quote_char;

  if (temp[0] == '\"' || temp[0] == '\'') {
    quote_char = temp.take_front();
    temp = temp.drop_front();
  }

  llvm::StringRef sub_name;
  std::tie(key, sub_name) = temp.split(']');

  if (!key.consume_back(quote_char) || key.empty()) {
    error.SetErrorStringWithFormat("invalid value path '%s', "
      "key names must be formatted as ['<key>'] where <key> "
      "is a string that doesn't contain quotes and the quote"
      " char is optional", name.str().c_str());
    return nullptr;
  }

  value_sp = GetValueForKey(ConstString(key));
  if (!value_sp) {
    error.SetErrorStringWithFormat(
      "dictionary does not contain a value for the key name '%s'",
      key.str().c_str());
    return nullptr;
  }

  if (sub_name.empty())
    return value_sp;
  return value_sp->GetSubValue(exe_ctx, sub_name, will_modify, error);
}
开发者ID:FreeBSDFoundation,项目名称:freebsd,代码行数:50,代码来源:OptionValueDictionary.cpp


示例19: getThunkTarget

std::string Context::getThunkTarget(llvm::StringRef MangledName) {
  if (!isThunkSymbol(MangledName))
    return std::string();

  if (isMangledName(MangledName)) {
    // The targets of those thunks not derivable from the mangling.
    if (MangledName.endswith("TR") ||
        MangledName.endswith("Tr") ||
        MangledName.endswith("TW") )
      return std::string();

    if (MangledName.endswith("fC")) {
      std::string target = MangledName.str();
      target[target.size() - 1] = 'c';
      return target;
    }

    return MangledName.substr(0, MangledName.size() - 2).str();
  }
  // Old mangling.
  assert(MangledName.startswith("_T"));
  StringRef Remaining = MangledName.substr(2);
  if (Remaining.startswith("PA_"))
    return Remaining.substr(3).str();
  if (Remaining.startswith("PAo_"))
    return Remaining.substr(4).str();
  assert(Remaining.startswith("To") || Remaining.startswith("TO"));
  return std::string("_T") + Remaining.substr(2).str();
}
开发者ID:DevAndArtist,项目名称:swift,代码行数:29,代码来源:Context.cpp


示例20: insertExportType

bool RSContext::insertExportType(const llvm::StringRef &TypeName,
                                 RSExportType *ET) {
  ExportTypeMap::value_type *NewItem =
      ExportTypeMap::value_type::Create(TypeName.begin(),
                                        TypeName.end(),
                                        mExportTypes.getAllocator(),
                                        ET);

  if (mExportTypes.insert(NewItem)) {
    return true;
  } else {
    free(NewItem);
    return false;
  }
}
开发者ID:Proshivalskiy,项目名称:MT6582_kernel_source,代码行数:15,代码来源:slang_rs_context.cpp



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ llvm::Triple类代码示例发布时间:2022-05-31
下一篇:
C++ llvm::StringMap类代码示例发布时间: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