本文整理汇总了C++中llvm::StringRef::slice方法的典型用法代码示例。如果您正苦于以下问题:C++ StringRef::slice方法的具体用法?C++ StringRef::slice怎么用?C++ StringRef::slice使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm::StringRef
的用法示例。
在下文中一共展示了StringRef::slice方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getClangRepositoryPath
std::string getClangRepositoryPath() {
#ifdef SVN_REPOSITORY
llvm::StringRef URL(SVN_REPOSITORY);
#else
llvm::StringRef URL("");
#endif
// If the SVN_REPOSITORY is empty, try to use the SVN keyword. This helps us
// pick up a tag in an SVN export, for example.
static llvm::StringRef SVNRepository("$URL$");
if (URL.empty()) {
URL = SVNRepository.slice(SVNRepository.find(':'),
SVNRepository.find("/lib/Basic"));
}
// Strip off version from a build from an integration branch.
URL = URL.slice(0, URL.find("/src/tools/clang"));
// Trim path prefix off, assuming path came from standard cfe path.
size_t Start = URL.find("cfe/");
if (Start != llvm::StringRef::npos)
URL = URL.substr(Start + 4);
return URL;
}
示例3: loadBeginEntry
void TemplightProtobufReader::loadBeginEntry(llvm::StringRef aSubBuffer) {
// Set default values:
LastBeginEntry.InstantiationKind = 0;
LastBeginEntry.Name = "";
LastBeginEntry.TimeStamp = 0.0;
LastBeginEntry.MemoryUsage = 0;
while ( aSubBuffer.size() ) {
unsigned int cur_wire = llvm::protobuf::loadVarInt(aSubBuffer);
switch( cur_wire ) {
case llvm::protobuf::getVarIntWire<1>::value:
LastBeginEntry.InstantiationKind = llvm::protobuf::loadVarInt(aSubBuffer);
break;
case llvm::protobuf::getStringWire<2>::value: {
std::uint64_t cur_size = llvm::protobuf::loadVarInt(aSubBuffer);
loadTemplateName(aSubBuffer.slice(0, cur_size));
aSubBuffer = aSubBuffer.drop_front(cur_size);
break;
}
case llvm::protobuf::getStringWire<3>::value: {
std::uint64_t cur_size = llvm::protobuf::loadVarInt(aSubBuffer);
loadLocation(aSubBuffer.slice(0, cur_size), fileNameMap,
LastBeginEntry.FileName, LastBeginEntry.Line, LastBeginEntry.Column);
aSubBuffer = aSubBuffer.drop_front(cur_size);
break;
}
case llvm::protobuf::getDoubleWire<4>::value:
LastBeginEntry.TimeStamp = llvm::protobuf::loadDouble(aSubBuffer);
break;
case llvm::protobuf::getVarIntWire<5>::value:
LastBeginEntry.MemoryUsage = llvm::protobuf::loadVarInt(aSubBuffer);
break;
case llvm::protobuf::getStringWire<6>::value: {
std::uint64_t cur_size = llvm::protobuf::loadVarInt(aSubBuffer);
loadLocation(aSubBuffer.slice(0, cur_size), fileNameMap,
LastBeginEntry.TempOri_FileName, LastBeginEntry.TempOri_Line, LastBeginEntry.TempOri_Column);
aSubBuffer = aSubBuffer.drop_front(cur_size);
break;
}
default:
llvm::protobuf::skipData(aSubBuffer, cur_wire);
break;
}
}
LastChunk = TemplightProtobufReader::BeginEntry;
}
示例4: substrBefore
static llvm::StringRef substrBefore(llvm::StringRef whole,
llvm::StringRef part) {
return whole.slice(0, part.data() - whole.data());
}