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


C++ StringRef::end方法代码示例

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


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

示例1: benchmark

static void benchmark( llvm::TimerGroup &Group
                     , llvm::StringRef Name
                     , llvm::StringRef JSONText) {
  llvm::Timer BaseLine((Name + ": Loop").str(), Group);
  BaseLine.startTimer();
  char C = 0;
  for (llvm::StringRef::iterator I = JSONText.begin(),
                                 E = JSONText.end();
       I != E; ++I) { C += *I; }
  BaseLine.stopTimer();
  volatile char DontOptimizeOut = C; (void)DontOptimizeOut;

  llvm::Timer Tokenizing((Name + ": Tokenizing").str(), Group);
  Tokenizing.startTimer();
  {
    yaml::scanTokens(JSONText);
  }
  Tokenizing.stopTimer();

  llvm::Timer Parsing((Name + ": Parsing").str(), Group);
  Parsing.startTimer();
  {
    llvm::SourceMgr SM;
    llvm::yaml::Stream stream(JSONText, SM);
    stream.skip();
  }
  Parsing.stopTimer();
}
开发者ID:0xDEC0DE8,项目名称:mcsema,代码行数:28,代码来源:YAMLBench.cpp

示例2: getDiagCategoryEnum

static std::string getDiagCategoryEnum(llvm::StringRef name) {
  if (name.empty())
    return "DiagCat_None";
  SmallString<256> enumName = llvm::StringRef("DiagCat_");
  for (llvm::StringRef::iterator I = name.begin(), E = name.end(); I != E; ++I)
    enumName += isalnum(*I) ? *I : '_';
  return enumName.str();
}
开发者ID:ADonut,项目名称:LLVM-GPGPU,代码行数:8,代码来源:ClangDiagnosticsEmitter.cpp

示例3: Name

COFFSymbol::COFFSymbol(llvm::StringRef name)
  : Name(name.begin(), name.end())
  , Other(NULL)
  , Section(NULL)
  , Relocations(0)
  , MCData(NULL) {
  memset(&Data, 0, sizeof(Data));
}
开发者ID:CartBlanche,项目名称:llvm,代码行数:8,代码来源:WinCOFFObjectWriter.cpp

示例4:

//===----------------------------------------------------------------------===//
// parser<mcld::sys::fs::Path>
//===----------------------------------------------------------------------===//
bool parser<mcld::sys::fs::Path>::parse(llvm::cl::Option &O,
                       llvm::StringRef ArgName,
                       llvm::StringRef Arg,
                       mcld::sys::fs::Path &Val)
{
  Val.assign<llvm::StringRef::const_iterator>(Arg.begin(), Arg.end());
  return false;
}
开发者ID:Proshivalskiy,项目名称:MT6582_kernel_source,代码行数:11,代码来源:CommandLine.cpp

示例5: 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

示例6: shortString

string shortString(llvm::StringRef in) {
    string out;
    bool wasSpace = false;

    for (const char *i = in.begin(); i != in.end(); ++i) {
        if (isspace(*i)) {
            if (!wasSpace) {
                out.push_back(' ');
                wasSpace = true;
            }
        } else {
            out.push_back(*i);
            wasSpace = false;
        }
    }
    return out;
}
开发者ID:DawidvC,项目名称:clay,代码行数:17,代码来源:printer.cpp

示例7: ConvertUTF8toWide

bool ConvertUTF8toWide(unsigned WideCharWidth, llvm::StringRef Source,
                       char *&ResultPtr, const UTF8 *&ErrorPtr) {
  assert(WideCharWidth == 1 || WideCharWidth == 2 || WideCharWidth == 4);
  ConversionResult result = conversionOK;
  // Copy the character span over.
  if (WideCharWidth == 1) {
    const UTF8 *Pos = reinterpret_cast<const UTF8*>(Source.begin());
    if (!isLegalUTF8String(&Pos, reinterpret_cast<const UTF8*>(Source.end()))) {
      result = sourceIllegal;
      ErrorPtr = Pos;
    } else {
      memcpy(ResultPtr, Source.data(), Source.size());
      ResultPtr += Source.size();
    }
  } else if (WideCharWidth == 2) {
    const UTF8 *sourceStart = (const UTF8*)Source.data();
    // FIXME: Make the type of the result buffer correct instead of
    // using reinterpret_cast.
    UTF16 *targetStart = reinterpret_cast<UTF16*>(ResultPtr);
    ConversionFlags flags = strictConversion;
    result = ConvertUTF8toUTF16(
        &sourceStart, sourceStart + Source.size(),
        &targetStart, targetStart + Source.size(), flags);
    if (result == conversionOK)
      ResultPtr = reinterpret_cast<char*>(targetStart);
    else
      ErrorPtr = sourceStart;
  } else if (WideCharWidth == 4) {
    const UTF8 *sourceStart = (const UTF8*)Source.data();
    // FIXME: Make the type of the result buffer correct instead of
    // using reinterpret_cast.
    UTF32 *targetStart = reinterpret_cast<UTF32*>(ResultPtr);
    ConversionFlags flags = strictConversion;
    result = ConvertUTF8toUTF32(
        &sourceStart, sourceStart + Source.size(),
        &targetStart, targetStart + Source.size(), flags);
    if (result == conversionOK)
      ResultPtr = reinterpret_cast<char*>(targetStart);
    else
      ErrorPtr = sourceStart;
  }
  assert((result != targetExhausted)
         && "ConvertUTF8toUTFXX exhausted target buffer");
  return result == conversionOK;
}
开发者ID:alex-t,项目名称:llvm,代码行数:45,代码来源:ConvertUTFWrapper.cpp

示例8: insert

/// Add String to the table iff it is not already there.
/// @returns the index into the string table where the string is now located.
size_t StringTable::insert(llvm::StringRef String) {
  map::iterator i = Map.find(String);

  if (i != Map.end())
    return i->second;

  size_t Offset = Data.size();

  // Insert string data into string table.
  Data.insert(Data.end(), String.begin(), String.end());
  Data.push_back('\0');

  // Put a reference to it in the map.
  Map[String] = Offset;

  // Update the internal length field.
  update_length();

  return Offset;
}
开发者ID:CartBlanche,项目名称:llvm,代码行数:22,代码来源:WinCOFFObjectWriter.cpp

示例9: benchmark

void benchmark(llvm::TimerGroup &Group, llvm::StringRef Name,
               llvm::StringRef JSONText) {
  llvm::Timer BaseLine((Name + ": Loop").str(), Group);
  BaseLine.startTimer();
  char C = 0;
  for (llvm::StringRef::iterator I = JSONText.begin(),
                                 E = JSONText.end();
       I != E; ++I) { C += *I; }
  BaseLine.stopTimer();
  volatile char DontOptimizeOut = C; (void)DontOptimizeOut;

  llvm::Timer Parsing((Name + ": Parsing").str(), Group);
  Parsing.startTimer();
  llvm::SourceMgr SM;
  llvm::JSONParser Parser(JSONText, &SM);
  if (!Parser.validate()) {
    llvm::errs() << "Parsing error in JSON parser benchmark.\n";
    exit(1);
  }
  Parsing.stopTimer();
}
开发者ID:Blei,项目名称:llvm-dcpu16,代码行数:21,代码来源:JSONBench.cpp

示例10:

StringExtractor::StringExtractor(llvm::StringRef packet_str)
    : m_packet(), m_index(0) {
  m_packet.assign(packet_str.begin(), packet_str.end());
}
开发者ID:CodaFi,项目名称:swift-lldb,代码行数:4,代码来源:StringExtractor.cpp

示例11: if

/// decimal integer: [0-9] [0-9_]*
/// binary integer: [01] [01_]* [bB]
/// binary integer: "0b" [01_]+
/// octal integer: [0-7] [0-7_]* [qQoO]
/// hex integer: [0-9] [0-9a-fA-F_]* [hH]
/// hex integer: [$] [0-9] [0-9a-fA-F_]*
/// hex integer: "0x" [0-9a-fA-F_]+
///
/// decimal float: [0-9]+ [.] [0-9]* ([eE] [-+]? [0-9]+)?
/// decimal float: [0-9]+ [eE] [-+]? [0-9]+
/// hex float: "0x" [0-9a-fA-F_]* [.] [0-9a-fA-F]* ([pP] [-+]? [0-9]+)?
/// hex float: "0x" [0-9a-fA-F_]+ [pP] [-+]? [0-9]+
///
NasmNumericParser::NasmNumericParser(llvm::StringRef str,
                                     SourceLocation loc,
                                     Preprocessor& pp)
    : NumericParser(str)
{
    // This routine assumes that the range begin/end matches the regex for
    // integer and FP constants, and assumes that the byte at "*end" is both
    // valid and not part of the regex.  Because of this, it doesn't have to
    // check for 'overscan' in various places.
    assert(!isalnum(*m_digits_end) && *m_digits_end != '.' &&
           *m_digits_end != '_' && "Lexer didn't maximally munch?");

    const char* s = str.begin();
    bool float_ok = false;

    // Look for key radix flags (prefixes and suffixes)
    if (*s == '$')
    {
        m_radix = 16;
        ++s;
    }
    else if (m_digits_end[-1] == 'b' || m_digits_end[-1] == 'B')
    {
        m_radix = 2;
        --m_digits_end;
    }
    else if (m_digits_end[-1] == 'q' || m_digits_end[-1] == 'Q' ||
             m_digits_end[-1] == 'o' || m_digits_end[-1] == 'O')
    {
        m_radix = 8;
        --m_digits_end;
    }
    else if (m_digits_end[-1] == 'h' || m_digits_end[-1] == 'H')
    {
        m_radix = 16;
        --m_digits_end;
    }
    else if (*s == '0' && (s[1] == 'x' || s[1] == 'X') &&
             (isxdigit(s[2]) || s[2] == '.'))
    {
        m_radix = 16;
        float_ok = true;    // C99-style hex floating point
        s += 2;
    }
    else if (*s == '0' && (s[1] == 'b' || s[1] == 'B') &&
             (s[2] == '0' || s[2] == '1'))
    {
        m_radix = 2;
        s += 2;
    }
    else
    {
        // Otherwise it's a decimal or float
        m_radix = 10;
        float_ok = true;
    }

    m_digits_begin = s;

    switch (m_radix)
    {
        case 2:     s = SkipBinaryDigits(s); break;
        case 8:     s = SkipOctalDigits(s); break;
        case 10:    s = SkipDigits(s); break;
        case 16:    s = SkipHexDigits(s); break;
    }

    if (s == m_digits_end)
    {
        // Done.
    }
    else if (isxdigit(*s) && (!float_ok || (*s != 'e' && *s != 'E')))
    {
        unsigned int err;
        switch (m_radix)
        {
            case 2: err = diag::err_invalid_binary_digit; break;
            case 8: err = diag::err_invalid_octal_digit; break;
            case 10: err = diag::err_invalid_decimal_digit; break;
            case 16:
            default:
                assert(false && "unexpected radix");
                err = diag::err_invalid_decimal_digit;
                break;
        }
        pp.Diag(pp.AdvanceToTokenCharacter(loc, s-str.begin()), err)
            << std::string(s, s+1);
//.........这里部分代码省略.........
开发者ID:BrianGladman,项目名称:yasm-nextgen,代码行数:101,代码来源:NasmNumericParser.cpp

示例12: if

/// decimal integer: [1-9] [0-9]*
/// binary integer: "0" [bB] [01]+
/// octal integer: "0" [0-7]*
/// hex integer: "0" [xX] [0-9a-fA-F]+
///
/// float: "0" [a-zA-Z except bB or xX]
///        [-+]? [0-9]* ([.] [0-9]*)? ([eE] [-+]? [0-9]+)?
///
GasNumericParser::GasNumericParser(llvm::StringRef str,
                                   SourceLocation loc,
                                   Preprocessor& pp,
                                   bool force_float)
    : NumericParser(str)
{
    // This routine assumes that the range begin/end matches the regex for
    // integer and FP constants, and assumes that the byte at "*end" is both
    // valid and not part of the regex.  Because of this, it doesn't have to
    // check for 'overscan' in various places.
    assert(!isalnum(*m_digits_end) && *m_digits_end != '.' &&
           "Lexer didn't maximally munch?");

    const char* s = str.begin();

    // Look for key radix prefixes
    if (force_float)
    {
        // forced decimal float; skip the prefix if present
        m_radix = 10;
        m_is_float = true;
        if (*s == '0' && isalpha(s[1]))
            s += 2;
    }
    else if (*s == '0' && (s[1] == 'x' || s[1] == 'X'))
    {
        m_radix = 16;
        s += 2;
    }
    else if (*s == '0' && (s[1] == 'b' || s[1] == 'B'))
    {
        m_radix = 2;
        s += 2;
    }
    else if (*s == '0' && isalpha(s[1]))
    {
        // it's a decimal float; skip the prefix
        m_radix = 10;
        s += 2;
        m_is_float = true;
    }
    else if (*s == '0')
    {
        // It's an octal integer
        m_radix = 8;
    }
    else
    {
        // Otherwise it's a decimal
        m_radix = 10;
    }

    m_digits_begin = s;

    switch (m_radix)
    {
        case 2:     s = SkipBinaryDigits(s); break;
        case 8:     s = SkipOctalDigits(s); break;
        case 10:    s = SkipDigits(s); break;
        case 16:    s = SkipHexDigits(s); break;
    }

    if (s == m_digits_end)
    {
        // Done.
    }
    else if (isxdigit(*s) && (!m_is_float || (*s != 'e' && *s != 'E')))
    {
        unsigned int err;
        switch (m_radix)
        {
            case 2: err = diag::err_invalid_binary_digit; break;
            case 8: err = diag::err_invalid_octal_digit; break;
            case 10: err = diag::err_invalid_decimal_digit; break;
            case 16:
            default:
                assert(false && "unexpected radix");
                err = diag::err_invalid_decimal_digit;
                break;
        }
        pp.Diag(pp.AdvanceToTokenCharacter(loc, s-str.begin()), err)
            << std::string(s, s+1);
        m_had_error = true;
        return;
    }
    else if (m_is_float)
    {
        if (*s == '-' || *s == '+')
        {
            ++s;
            s = SkipDigits(s);
        }
//.........这里部分代码省略.........
开发者ID:BrianGladman,项目名称:yasm-nextgen,代码行数:101,代码来源:GasNumericParser.cpp

示例13: isWhitespaceOnly

bool ClangDocCommentVisitor::isWhitespaceOnly(llvm::StringRef S) const {
  return std::all_of(S.begin(), S.end(), isspace);
}
开发者ID:vmiklos,项目名称:clang-tools-extra,代码行数:3,代码来源:Serialize.cpp


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