本文整理汇总了C++中llvm::ArrayRef类的典型用法代码示例。如果您正苦于以下问题:C++ ArrayRef类的具体用法?C++ ArrayRef怎么用?C++ ArrayRef使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ArrayRef类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
PythonBytes::SetBytes(llvm::ArrayRef<uint8_t> bytes)
{
const char *data = reinterpret_cast<const char *>(bytes.data());
PyObject *py_bytes = PyBytes_FromStringAndSize(data, bytes.size());
PythonObject::Reset(PyRefType::Owned, py_bytes);
}
示例2: consumeObject
// Minidump string
llvm::Optional<std::string>
lldb_private::minidump::parseMinidumpString(llvm::ArrayRef<uint8_t> &data) {
std::string result;
const uint32_t *source_length;
Status error = consumeObject(data, source_length);
if (error.Fail() || *source_length > data.size() || *source_length % 2 != 0)
return llvm::None;
auto source_start = reinterpret_cast<const llvm::UTF16 *>(data.data());
// source_length is the length of the string in bytes
// we need the length of the string in UTF-16 characters/code points (16 bits
// per char)
// that's why it's divided by 2
const auto source_end = source_start + (*source_length) / 2;
// resize to worst case length
result.resize(UNI_MAX_UTF8_BYTES_PER_CODE_POINT * (*source_length) / 2);
auto result_start = reinterpret_cast<llvm::UTF8 *>(&result[0]);
const auto result_end = result_start + result.size();
llvm::ConvertUTF16toUTF8(&source_start, source_end, &result_start, result_end,
llvm::strictConversion);
const auto result_size =
std::distance(reinterpret_cast<llvm::UTF8 *>(&result[0]), result_start);
result.resize(result_size); // shrink to actual length
return result;
}
示例3: AcceptedChanges
NullptrFixer::NullptrFixer(unsigned &AcceptedChanges,
llvm::ArrayRef<llvm::StringRef> UserMacros,
Transform &Owner)
: AcceptedChanges(AcceptedChanges), Owner(Owner) {
UserNullMacros.insert(UserNullMacros.begin(), UserMacros.begin(),
UserMacros.end());
UserNullMacros.insert(UserNullMacros.begin(), llvm::StringRef(NullMacroName));
}
示例4:
UnknownSyntax
SyntaxFactory::makeUnknownSyntax(llvm::ArrayRef<RC<TokenSyntax>> Tokens) {
RawSyntax::LayoutList Layout;
std::copy(Tokens.begin(), Tokens.end(), std::back_inserter(Layout));
auto Raw = RawSyntax::make(SyntaxKind::Unknown, Layout,
SourcePresence::Present);
auto Data = UnknownSyntaxData::make(Raw);
return { Data, Data.get() };
}
示例5: lookup
// Returns qualified names of symbols with any of IDs in the index.
std::vector<std::string> lookup(const SymbolIndex &I,
llvm::ArrayRef<SymbolID> IDs) {
LookupRequest Req;
Req.IDs.insert(IDs.begin(), IDs.end());
std::vector<std::string> Results;
I.lookup(Req, [&](const Symbol &Sym) {
Results.push_back(getQualifiedName(Sym));
});
return Results;
}
示例6: printNameList
void printNameList(llvm::raw_ostream &out, llvm::ArrayRef<ObjectPtr> x, llvm::ArrayRef<unsigned> dispatchIndices)
{
for (size_t i = 0; i < x.size(); ++i) {
if (i != 0)
out << ", ";
if (find(dispatchIndices.begin(), dispatchIndices.end(), i) != dispatchIndices.end())
out << "*";
printName(out, x[i]);
}
}
示例7: emitWarning
void emitWarning(const char* warning_msg,
llvm::ArrayRef<llvm::Value*> extra_args,
Compiler* compiler)
{
std::vector<llvm::Value*> args;
args.push_back(compiler->emitConstantPointer(warning_msg));
args.insert(args.end(), extra_args.begin(), extra_args.end());
Function* warning = getDeclaration("Rf_warning", compiler);
compiler->emitCallOrInvoke(warning, args);
}
示例8: emitError
void emitError(const char* error_msg, llvm::ArrayRef<llvm::Value*> extra_args,
Compiler* compiler)
{
std::vector<llvm::Value*> args;
args.push_back(compiler->emitConstantPointer(error_msg));
args.insert(args.end(), extra_args.begin(), extra_args.end());
Function* error = getDeclaration("Rf_error", compiler);
compiler->emitCallOrInvoke(error, args);
compiler->CreateUnreachable();
}
示例9: makeArrayRef
llvm::ArrayRef<MinidumpMemoryDescriptor>
MinidumpMemoryDescriptor::ParseMemoryList(llvm::ArrayRef<uint8_t> &data) {
const llvm::support::ulittle32_t *mem_ranges_count;
Status error = consumeObject(data, mem_ranges_count);
if (error.Fail() ||
*mem_ranges_count * sizeof(MinidumpMemoryDescriptor) > data.size())
return {};
return llvm::makeArrayRef(
reinterpret_cast<const MinidumpMemoryDescriptor *>(data.data()),
*mem_ranges_count);
}
示例10: loadImports
static void loadImports(llvm::ArrayRef<ImportPtr> imports)
{
for (size_t i = 0; i < imports.size(); ++i) {
module->imports.push_back(imports[i]);
}
for (size_t i = 0; i < imports.size(); ++i) {
loadDependent(module, NULL, imports[i], false);
}
for (size_t i = 0; i < imports.size(); ++i) {
initModule(imports[i]->module);
}
}
示例11: jitTopLevel
static void jitTopLevel(llvm::ArrayRef<TopLevelItemPtr> toplevels)
{
if (toplevels.empty()) {
return;
}
if (printAST) {
for (size_t i = 0; i < toplevels.size(); ++i) {
llvm::errs() << i << ": " << toplevels[i] << "\n";
}
}
addGlobals(module, toplevels);
}
示例12: addGlobals
void addGlobals(ModulePtr m, llvm::ArrayRef<TopLevelItemPtr> toplevels) {
TopLevelItemPtr const *i, *end;
for (i = toplevels.begin(), end = toplevels.end();
i != end; ++i) {
m->topLevelItems.push_back(*i);
TopLevelItem *x = i->ptr();
x->env = m->env;
switch (x->objKind) {
case ENUM_DECL : {
EnumDecl *enumer = (EnumDecl *)x;
TypePtr t = enumType(enumer);
addGlobal(m, enumer->name, enumer->visibility, t.ptr());
for (unsigned i = 0 ; i < enumer->members.size(); ++i) {
EnumMember *member = enumer->members[i].ptr();
member->index = (int)i;
member->type = t;
addGlobal(m, member->name, enumer->visibility, member);
}
break;
}
case PROCEDURE : {
Procedure *proc = (Procedure *)x;
if (proc->interface != NULL)
proc->interface->env = m->env;
// fallthrough
}
default :
if (x->name.ptr())
addGlobal(m, x->name, x->visibility, x);
break;
}
}
llvm::ArrayRef<TopLevelItemPtr> items = m->topLevelItems;
for (size_t i = items.size() - toplevels.size(); i < items.size(); ++i) {
Object *obj = items[i].ptr();
switch (obj->objKind) {
case OVERLOAD :
initOverload((Overload *)obj);
break;
case INSTANCE_DECL :
initVariantInstance((InstanceDecl *)obj);
break;
case STATIC_ASSERT_TOP_LEVEL:
checkStaticAssert((StaticAssertTopLevel *)obj);
break;
default:
break;
}
}
}
示例13: DumpDWARFExpr
static void DumpDWARFExpr(Stream &s, llvm::ArrayRef<uint8_t> expr, Thread *thread) {
if (auto order_and_width = GetByteOrderAndAddrSize(thread)) {
DataExtractor extractor(expr.data(), expr.size(), order_and_width->first,
order_and_width->second);
if (!DWARFExpression::PrintDWARFExpression(s, extractor,
order_and_width->second,
/*dwarf_ref_size*/ 4,
/*location_expression*/ false))
s.PutCString("invalid-dwarf-expr");
} else
s.PutCString("dwarf-expr");
}
示例14: circularImportsError
static void circularImportsError(llvm::ArrayRef<string> modules) {
string s;
llvm::raw_string_ostream ss(s);
ss << "import loop:\n";
for (string const *it = modules.begin(); it != modules.end(); ++it) {
ss << " " << *it;
if (it + 1 != modules.end()) {
// because error() function adds trailing newline
ss << "\n";
}
}
return error(ss.str());
}
示例15: write
/// \brief Write a block of data, and get the offset that it starts at.
/// \param Bytes the array of bytes to be written.
/// \return the offset that this block was written at.
///
offset_uint write(llvm::ArrayRef<char> Bytes) {
// If the stream doesn't exist, silently ignore the write request.
if (!Out)
return noOffset();
auto const Size = Bytes.size();
Out->write(Bytes.data(), Size);
// Update the current offset and return the original value.
auto const WrittenAt = Offset;
Offset += Size;
return WrittenAt;
}