本文整理汇总了C++中llvm::StringRef类的典型用法代码示例。如果您正苦于以下问题:C++ StringRef类的具体用法?C++ StringRef怎么用?C++ StringRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了StringRef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
示例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);
}
示例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;
}
示例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
}
示例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));
}
示例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())));
}
示例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();
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}