本文整理汇总了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();
}
示例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();
}
示例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));
}
示例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;
}
示例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;
}
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例10:
StringExtractor::StringExtractor(llvm::StringRef packet_str)
: m_packet(), m_index(0) {
m_packet.assign(packet_str.begin(), packet_str.end());
}
示例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);
//.........这里部分代码省略.........
示例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);
}
//.........这里部分代码省略.........
示例13: isWhitespaceOnly
bool ClangDocCommentVisitor::isWhitespaceOnly(llvm::StringRef S) const {
return std::all_of(S.begin(), S.end(), isspace);
}