本文整理汇总了C++中llvm::ArrayRef::front方法的典型用法代码示例。如果您正苦于以下问题:C++ ArrayRef::front方法的具体用法?C++ ArrayRef::front怎么用?C++ ArrayRef::front使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm::ArrayRef
的用法示例。
在下文中一共展示了ArrayRef::front方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: while
static Variable::RangeList
MakeRangeList(const PdbIndex &index, const LocalVariableAddrRange &range,
llvm::ArrayRef<LocalVariableAddrGap> gaps) {
lldb::addr_t start =
index.MakeVirtualAddress(range.ISectStart, range.OffsetStart);
lldb::addr_t end = start + range.Range;
Variable::RangeList result;
while (!gaps.empty()) {
const LocalVariableAddrGap &gap = gaps.front();
lldb::addr_t size = gap.GapStartOffset - start;
result.Append(start, size);
start += gap.Range;
gaps = gaps.drop_front();
}
result.Append(start, end - start);
return result;
}
示例2: parse
void BuildSystemInvocation::parse(llvm::ArrayRef<std::string> args,
llvm::SourceMgr& sourceMgr) {
auto error = [&](const Twine &message) {
sourceMgr.PrintMessage(llvm::SMLoc{}, llvm::SourceMgr::DK_Error, message);
hadErrors = true;
};
while (!args.empty()) {
const auto& option = args.front();
args = args.slice(1);
if (option == "-") {
for (const auto& arg: args) {
positionalArgs.push_back(arg);
}
break;
}
if (!option.empty() && option[0] != '-') {
positionalArgs.push_back(option);
continue;
}
if (option == "--help") {
showUsage = true;
break;
} else if (option == "--version") {
showVersion = true;
break;
} else if (option == "--no-db") {
dbPath = "";
} else if (option == "--db") {
if (args.empty()) {
error("missing argument to '" + option + "'");
break;
}
dbPath = args[0];
args = args.slice(1);
} else if (option == "-C" || option == "--chdir") {
if (args.empty()) {
error("missing argument to '" + option + "'");
break;
}
chdirPath = args[0];
args = args.slice(1);
} else if (option == "-f") {
if (args.empty()) {
error("missing argument to '" + option + "'");
break;
}
buildFilePath = args[0];
args = args.slice(1);
} else if (option == "--serial") {
useSerialBuild = true;
} else if (option == "-v" || option == "--verbose") {
showVerboseStatus = true;
} else if (option == "--trace") {
if (args.empty()) {
error("missing argument to '" + option + "'");
break;
}
traceFilePath = args[0];
args = args.slice(1);
} else {
error("invalid option '" + option + "'");
break;
}
}
}
示例3: execute
llvm::Error AllTUsToolExecutor::execute(
llvm::ArrayRef<
std::pair<std::unique_ptr<FrontendActionFactory>, ArgumentsAdjuster>>
Actions) {
if (Actions.empty())
return make_string_error("No action to execute.");
if (Actions.size() != 1)
return make_string_error(
"Only support executing exactly 1 action at this point.");
std::string ErrorMsg;
std::mutex TUMutex;
auto AppendError = [&](llvm::Twine Err) {
std::unique_lock<std::mutex> LockGuard(TUMutex);
ErrorMsg += Err.str();
};
auto Log = [&](llvm::Twine Msg) {
std::unique_lock<std::mutex> LockGuard(TUMutex);
llvm::errs() << Msg.str() << "\n";
};
std::vector<std::string> Files;
llvm::Regex RegexFilter(Filter);
for (const auto& File : Compilations.getAllFiles()) {
if (RegexFilter.match(File))
Files.push_back(File);
}
// Add a counter to track the progress.
const std::string TotalNumStr = std::to_string(Files.size());
unsigned Counter = 0;
auto Count = [&]() {
std::unique_lock<std::mutex> LockGuard(TUMutex);
return ++Counter;
};
auto &Action = Actions.front();
{
llvm::ThreadPool Pool(ThreadCount == 0 ? llvm::hardware_concurrency()
: ThreadCount);
llvm::SmallString<128> InitialWorkingDir;
if (auto EC = llvm::sys::fs::current_path(InitialWorkingDir)) {
InitialWorkingDir = "";
llvm::errs() << "Error while getting current working directory: "
<< EC.message() << "\n";
}
for (std::string File : Files) {
Pool.async(
[&](std::string Path) {
Log("[" + std::to_string(Count()) + "/" + TotalNumStr +
"] Processing file " + Path);
ClangTool Tool(Compilations, {Path});
Tool.appendArgumentsAdjuster(Action.second);
Tool.appendArgumentsAdjuster(getDefaultArgumentsAdjusters());
for (const auto &FileAndContent : OverlayFiles)
Tool.mapVirtualFile(FileAndContent.first(),
FileAndContent.second);
// Do not restore working dir from multiple threads to avoid races.
Tool.setRestoreWorkingDir(false);
if (Tool.run(Action.first.get()))
AppendError(llvm::Twine("Failed to run action on ") + Path +
"\n");
},
File);
}
// Make sure all tasks have finished before resetting the working directory.
Pool.wait();
if (!InitialWorkingDir.empty()) {
if (auto EC = llvm::sys::fs::set_current_path(InitialWorkingDir))
llvm::errs() << "Error while restoring working directory: "
<< EC.message() << "\n";
}
}
if (!ErrorMsg.empty())
return make_string_error(ErrorMsg);
return llvm::Error::success();
}
示例4: desugarCatchBlocks
StatementPtr desugarCatchBlocks(llvm::ArrayRef<CatchPtr> catchBlocks,
CompilerState* cst) {
assert(!catchBlocks.empty());
Location firstCatchLocation = catchBlocks.front()->location;
IdentifierPtr expVar = Identifier::get("%exp", firstCatchLocation);
CallPtr activeException = new Call(primitive_expr_activeException(cst), new ExprList());
activeException->location = firstCatchLocation;
BindingPtr expBinding =
new Binding(VAR,
identVtoFormalV(vector<IdentifierPtr>(1, expVar)),
new ExprList(activeException.ptr()));
expBinding->location = firstCatchLocation;
bool lastWasAny = false;
IfPtr lastIf;
StatementPtr result;
for (size_t i = 0; i < catchBlocks.size(); ++i) {
CatchPtr x = catchBlocks[i];
if (lastWasAny)
error(x, "unreachable catch block");
if (x->exceptionType.ptr()) {
ExprListPtr asTypeArgs = new ExprList(x->exceptionType);
ExprPtr expVarName = new NameRef(expVar);
expVarName->location = x->exceptionVar->location;
asTypeArgs->add(expVarName);
CallPtr cond = new Call(operator_expr_exceptionIsP(cst), asTypeArgs);
cond->location = x->exceptionType->location;
BlockPtr block = new Block();
block->location = x->location;
vector<IdentifierPtr> identifiers;
makeExceptionVars(identifiers, x);
CallPtr getter = new Call(operator_expr_exceptionAs(cst), asTypeArgs);
getter->location = x->exceptionVar->location;
BindingPtr binding =
new Binding(VAR,
identVtoFormalV(identifiers),
new ExprList(getter.ptr()));
binding->location = x->exceptionVar->location;
BindingPtr exceptionVarForRethrow =
new Binding(REF,
identVtoFormalV(vector<IdentifierPtr>(1, Identifier::get("%exception", x->location))),
new ExprList(new NameRef(Identifier::get(x->exceptionVar->str, x->location))));
exceptionVarForRethrow->location = x->exceptionVar->location;
block->statements.push_back(binding.ptr());
block->statements.push_back(exceptionVarForRethrow.ptr());
block->statements.push_back(x->body);
IfPtr ifStatement = new If(cond.ptr(), block.ptr());
ifStatement->location = x->location;
if (!result)
result = ifStatement.ptr();
if (lastIf.ptr())
lastIf->elsePart = ifStatement.ptr();
lastIf = ifStatement;
}
else {
BlockPtr block = new Block();
block->location = x->location;
vector<IdentifierPtr> identifiers;
makeExceptionVars(identifiers, x);
ExprListPtr asAnyArgs = new ExprList(new NameRef(expVar));
CallPtr getter = new Call(operator_expr_exceptionAsAny(cst),
asAnyArgs);
getter->location = x->exceptionVar->location;
BindingPtr binding =
new Binding(VAR,
identVtoFormalV(identifiers),
new ExprList(getter.ptr()));
binding->location = x->exceptionVar->location;
BindingPtr exceptionVarForRethrow =
new Binding(REF,
identVtoFormalV(vector<IdentifierPtr>(1, Identifier::get("%exception", x->location))),
new ExprList(new NameRef(Identifier::get(x->exceptionVar->str, x->location))));
exceptionVarForRethrow->location = x->exceptionVar->location;
block->statements.push_back(binding.ptr());
block->statements.push_back(exceptionVarForRethrow.ptr());
block->statements.push_back(x->body);
if (!result)
result = block.ptr();
if (lastIf.ptr())
lastIf->elsePart = block.ptr();
lastWasAny = true;
lastIf = NULL;
}
}
assert(result.ptr());
if (!lastWasAny) {
//.........这里部分代码省略.........