本文整理汇总了C++中llvm::StringRef::rfind方法的典型用法代码示例。如果您正苦于以下问题:C++ StringRef::rfind方法的具体用法?C++ StringRef::rfind怎么用?C++ StringRef::rfind使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm::StringRef
的用法示例。
在下文中一共展示了StringRef::rfind方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ConstantExpr
BOZConstantExpr::BOZConstantExpr(ASTContext &C, SourceLocation Loc,
SourceLocation MaxLoc, llvm::StringRef Data)
: ConstantExpr(BOZConstantExprClass, C.IntegerTy, Loc, MaxLoc) {
unsigned Radix = 0;
switch (Data[0]) {
case 'B':
Kind = BinaryExprClass;
Radix = 2;
break;
case 'O':
Kind = Octal;
Radix = 8;
break;
case 'Z': case 'X':
Kind = Hexadecimal;
Radix = 16;
break;
}
size_t LastQuote = Data.rfind(Data[1]);
assert(LastQuote == llvm::StringRef::npos && "Invalid BOZ constant!");
llvm::StringRef NumStr = Data.slice(2, LastQuote);
APInt Val;
NumStr.getAsInteger(Radix, Val);
Num.setValue(C, Val);
}
示例2: 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;
}
示例3: sym
// Helpers to produce fake index symbols for memIndex() or completions().
// USRFormat is a regex replacement string for the unqualified part of the USR.
Symbol sym(llvm::StringRef QName, index::SymbolKind Kind,
llvm::StringRef USRFormat) {
Symbol Sym;
std::string USR = "c:"; // We synthesize a few simple cases of USRs by hand!
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);
USR += "@[email protected]" + replace(QName.substr(0, Pos), "::", "@[email protected]"); // ns:: -> @[email protected]
}
USR += llvm::Regex("^.*$").sub(USRFormat, Sym.Name); // e.g. func -> @[email protected]#
Sym.ID = SymbolID(USR);
Sym.SymInfo.Kind = Kind;
Sym.Flags |= Symbol::IndexedForCodeCompletion;
Sym.Origin = SymbolOrigin::Static;
return Sym;
}