本文整理汇总了C++中llvm::ArrayRef::size方法的典型用法代码示例。如果您正苦于以下问题:C++ ArrayRef::size方法的具体用法?C++ ArrayRef::size怎么用?C++ ArrayRef::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm::ArrayRef
的用法示例。
在下文中一共展示了ArrayRef::size方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: matchTempness
static bool matchTempness(CodePtr code,
llvm::ArrayRef<ValueTempness> argsTempness,
bool callByName,
vector<ValueTempness> &tempnessKey,
vector<uint8_t> &forwardedRValueFlags)
{
llvm::ArrayRef<FormalArgPtr> fargs = code->formalArgs;
if (code->hasVarArg)
assert(fargs.size()-1 <= argsTempness.size());
else
assert(fargs.size() == argsTempness.size());
tempnessKey.clear();
forwardedRValueFlags.clear();
unsigned varArgSize = argsTempness.size()-fargs.size()+1;
for (unsigned i = 0, j = 0; i < fargs.size(); ++i) {
if (callByName && (fargs[i]->tempness == TEMPNESS_FORWARD)) {
error(fargs[i], "forwarded arguments are not allowed "
"in call-by-name procedures");
}
if (fargs[i]->varArg) {
for (; j < varArgSize; ++j) {
if (!tempnessMatches(argsTempness[i+j], fargs[i]->tempness))
return false;
tempnessKey.push_back(
tempnessKeyItem(fargs[i]->tempness,
argsTempness[i+j]));
bool forwardedRValue =
(fargs[i]->tempness == TEMPNESS_FORWARD) &&
(argsTempness[i+j] == TEMPNESS_RVALUE);
forwardedRValueFlags.push_back(forwardedRValue);
}
--j;
} else {
if (!tempnessMatches(argsTempness[i+j], fargs[i]->tempness))
return false;
tempnessKey.push_back(
tempnessKeyItem(fargs[i]->tempness,
argsTempness[i+j]));
bool forwardedRValue =
(fargs[i]->tempness == TEMPNESS_FORWARD) &&
(argsTempness[i+j] == TEMPNESS_RVALUE);
forwardedRValueFlags.push_back(forwardedRValue);
}
}
return true;
}
示例3:
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);
}
示例4: getProcedureMonoTypes
void getProcedureMonoTypes(ProcedureMono &mono, EnvPtr env,
llvm::ArrayRef<FormalArgPtr> formalArgs, bool hasVarArg)
{
if (mono.monoState == Procedure_NoOverloads && !hasVarArg)
{
assert(mono.monoTypes.empty());
mono.monoState = Procedure_MonoOverload;
for (size_t i = 0; i < formalArgs.size(); ++i) {
if (formalArgs[i]->type == NULL)
goto poly;
LocationContext loc(formalArgs[i]->type->location);
PatternPtr argPattern =
evaluateOnePattern(formalArgs[i]->type, env);
ObjectPtr argTypeObj = derefDeep(argPattern);
if (argTypeObj == NULL)
goto poly;
TypePtr argType;
if (!staticToType(argTypeObj, argType))
error(formalArgs[i], "expecting a type");
mono.monoTypes.push_back(argType);
}
} else
goto poly;
return;
poly:
mono.monoTypes.clear();
mono.monoState = Procedure_PolyOverload;
return;
}
示例5: SetInferior
bool TestClient::SetInferior(llvm::ArrayRef<std::string> inferior_args) {
std::stringstream command;
command << "A";
for (size_t i = 0; i < inferior_args.size(); i++) {
if (i > 0)
command << ',';
std::string hex_encoded = toHex(inferior_args[i]);
command << hex_encoded.size() << ',' << i << ',' << hex_encoded;
}
if (!SendMessage(command.str()))
return false;
if (!SendMessage("qLaunchSuccess"))
return false;
std::string response;
if (!SendMessage("qProcessInfo", response))
return false;
auto create_or_error = ProcessInfo::Create(response);
if (auto create_error = create_or_error.takeError()) {
GTEST_LOG_(ERROR) << toString(std::move(create_error));
return false;
}
m_process_info = *create_or_error;
return true;
}
示例6: constructCompileCommands
static void constructCompileCommands(
CompileCommandPairs &compileCommands,
const clang::tooling::CompilationDatabase &compilationDatabase,
llvm::ArrayRef<std::string> sourcePaths)
{
for (unsigned pathIndex = 0, pathEnd = sourcePaths.size(); pathIndex != pathEnd; pathIndex++)
{
llvm::SmallString<1024> filePath(clang::tooling::getAbsolutePath(sourcePaths[pathIndex]));
std::vector<clang::tooling::CompileCommand> compileCmdsForFile =
compilationDatabase.getCompileCommands(filePath.str());
if (!compileCmdsForFile.empty())
{
for (int commandsIndex = 0, commandsEnd = compileCmdsForFile.size();
commandsIndex != commandsEnd; commandsIndex++)
{
compileCommands.push_back(
std::make_pair(filePath.str(), compileCmdsForFile[commandsIndex]));
}
}
/* - this needs to be collected and the gathered information will be printed eventually
- not here
else
{
DEBUG({
llvm::dbgs() << "Skipping " << filePath << ". Command line not found.\n";
});
}
*/
}
}
示例7: flatten
void flatten(llvm::ArrayRef<AST_stmt*> roots, std::vector<AST*>& output, bool expand_scopes) {
FlattenVisitor visitor(&output, expand_scopes);
for (int i = 0; i < roots.size(); i++) {
roots[i]->accept(&visitor);
}
}
示例8: 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;
}
示例9: printNameList
void printNameList(llvm::raw_ostream &out, llvm::ArrayRef<ObjectPtr> x)
{
for (unsigned i = 0; i < x.size(); ++i) {
if (i != 0)
out << ", ";
printName(out, x[i]);
}
}
示例10: printNameList
void printNameList(llvm::raw_ostream &out, llvm::ArrayRef<TypePtr> x)
{
for (size_t i = 0; i < x.size(); ++i) {
if (i != 0)
out << ", ";
printName(out, x[i].ptr());
}
}
示例11: writeRefs
void writeRefs(const SymbolID &ID, llvm::ArrayRef<Ref> Refs,
const StringTableOut &Strings, llvm::raw_ostream &OS) {
OS << ID.raw();
writeVar(Refs.size(), OS);
for (const auto &Ref : Refs) {
OS.write(static_cast<unsigned char>(Ref.Kind));
writeLocation(Ref.Location, Strings, OS);
}
}
示例12:
// Linux Proc Status
// it's stored as an ascii string in the file
llvm::Optional<LinuxProcStatus>
LinuxProcStatus::Parse(llvm::ArrayRef<uint8_t> &data) {
LinuxProcStatus result;
result.proc_status =
llvm::StringRef(reinterpret_cast<const char *>(data.data()), data.size());
data = data.drop_front(data.size());
llvm::SmallVector<llvm::StringRef, 0> lines;
result.proc_status.split(lines, '\n', 42);
// /proc/$pid/status has 41 lines, but why not use 42?
for (auto line : lines) {
if (line.consume_front("Pid:")) {
line = line.trim();
if (!line.getAsInteger(10, result.pid))
return result;
}
}
return llvm::None;
}
示例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: 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);
}
示例15: 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;
}
}
}