本文整理汇总了C++中llvm::cl::list::begin方法的典型用法代码示例。如果您正苦于以下问题:C++ list::begin方法的具体用法?C++ list::begin怎么用?C++ list::begin使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm::cl::list
的用法示例。
在下文中一共展示了list::begin方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: collectFileSystemHeaders
// Collect file system header files.
// This function scans the file system for header files,
// starting at the directory of the module.map file,
// optionally filtering out all but the files covered by
// the include path options.
// Returns true if no errors.
bool ModuleMapChecker::collectFileSystemHeaders() {
// Get directory containing the module.map file.
// Might be relative to current directory, absolute, or empty.
ModuleMapDirectory = getDirectoryFromPath(ModuleMapPath);
// If no include paths specified, we do the whole tree starting
// at the module.map directory.
if (IncludePaths.size() == 0) {
if (!collectFileSystemHeaders(StringRef("")))
return false;
} else {
// Otherwise we only look at the sub-trees specified by the
// include paths.
for (std::vector<std::string>::const_iterator I = IncludePaths.begin(),
E = IncludePaths.end();
I != E; ++I) {
if (!collectFileSystemHeaders(*I))
return false;
}
}
// Sort it, because different file systems might order the file differently.
std::sort(FileSystemHeaders.begin(), FileSystemHeaders.end());
return true;
}
示例2: llvm_manager
// main function
int
main(int argc, char* argv[])
{
llvm::llvm_shutdown_obj llvm_manager(false);
cl::SetVersionPrinter(&PrintVersion);
cl::ParseCommandLineOptions(argc, argv, "", true);
// Handle special exiting options
if (show_license)
{
for (std::size_t i=0; i<sizeof(license_msg)/sizeof(license_msg[0]); i++)
llvm::outs() << license_msg[i] << '\n';
return EXIT_SUCCESS;
}
DiagnosticOptions diag_opts;
diag_opts.ShowOptionNames = 1;
diag_opts.ShowSourceRanges = 1;
TextDiagnosticPrinter diag_printer(llvm::errs(), diag_opts);
IntrusiveRefCntPtr<DiagnosticIDs> diagids(new DiagnosticIDs);
DiagnosticsEngine diags(diagids, &diag_printer, false);
FileSystemOptions opts;
FileManager file_mgr(opts);
SourceManager source_mgr(diags, file_mgr);
diags.setSourceManager(&source_mgr);
diag_printer.setPrefix("ygas");
for (std::vector<std::string>::const_iterator i=unknown_options.begin(),
end=unknown_options.end(); i != end; ++i)
{
diags.Report(diag::warn_unknown_command_line_option) << *i;
}
// Load standard modules
if (!LoadStandardPlugins())
{
diags.Report(diag::fatal_standard_modules);
return EXIT_FAILURE;
}
#ifndef BUILD_STATIC
// Load plugins
for (std::vector<std::string>::const_iterator i=plugin_names.begin(),
end=plugin_names.end(); i != end; ++i)
{
if (!LoadPlugin(*i))
diags.Report(diag::warn_plugin_load) << *i;
}
#endif
// Default to stdin if no filename specified.
if (in_filename.empty())
in_filename = "-";
return do_assemble(source_mgr, diags);
}
示例3: preserveWorkingPath
void oclint::option::process(const char *argv)
{
preserveWorkingPath();
preserveExecutablePath(argv);
processConfigFiles();
for (unsigned i = 0; i < argRuleConfiguration.size(); ++i)
{
std::string configuration = argRuleConfiguration[i];
int indexOfSeparator = configuration.find_last_of("=");
std::string key = configuration.substr(0, indexOfSeparator);
std::string value = configuration.substr(indexOfSeparator + 1,
configuration.size() - indexOfSeparator - 1);
consumeRuleConfiguration(key, value);
}
filter.enableRules(argEnabledRules.begin(), argEnabledRules.end());
filter.disableRules(argDisabledRules.begin(), argDisabledRules.end());
}
示例4: doPrintBefore
static bool doPrintBefore(SILTransform *T, SILFunction *F) {
if (!SILPrintOnlyFun.empty() && F && F->getName() != SILPrintOnlyFun)
return false;
if (!SILPrintOnlyFuns.empty() && F &&
F->getName().find(SILPrintOnlyFuns, 0) == StringRef::npos)
return false;
auto MatchFun = [&](const std::string &Str) -> bool {
return T->getName().find(Str) != StringRef::npos;
};
if (SILPrintBefore.end() !=
std::find_if(SILPrintBefore.begin(), SILPrintBefore.end(), MatchFun))
return true;
if (SILPrintAround.end() !=
std::find_if(SILPrintAround.begin(), SILPrintAround.end(), MatchFun))
return true;
return false;
}
示例5: getFunctionNames
static void getFunctionNames(std::vector<std::string> &Names) {
std::copy(CommandLineFunctionNames.begin(), CommandLineFunctionNames.end(),
std::back_inserter(Names));
if (!FunctionNameFile.empty()) {
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileBufOrErr =
llvm::MemoryBuffer::getFileOrSTDIN(FunctionNameFile);
if (!FileBufOrErr) {
fprintf(stderr, "Error! Failed to open file: %s\n",
InputFilename.c_str());
exit(-1);
}
StringRef Buffer = FileBufOrErr.get()->getBuffer();
while (!Buffer.empty()) {
StringRef Token, NewBuffer;
std::tie(Token, NewBuffer) = llvm::getToken(Buffer, "\n");
if (Token.empty()) {
break;
}
Names.push_back(Token);
Buffer = NewBuffer;
}
}
}
示例6: assembler
static int
do_assemble(SourceManager& source_mgr, DiagnosticsEngine& diags)
{
// Apply warning settings
ApplyWarningSettings(diags);
// Determine objfmt_bits based on -32 and -64 options
std::string objfmt_bits = GetBitsSetting();
FileManager& file_mgr = source_mgr.getFileManager();
Assembler assembler("x86", YGAS_OBJFMT_BASE + objfmt_bits, diags,
dump_object);
HeaderSearch headers(file_mgr);
if (diags.hasFatalErrorOccurred())
return EXIT_FAILURE;
// Set object filename if specified.
if (!obj_filename.empty())
assembler.setObjectFilename(obj_filename);
// Set parser.
assembler.setParser("gas", diags);
if (diags.hasFatalErrorOccurred())
return EXIT_FAILURE;
// Set debug format to dwarf2pass if it's legal for this object format.
if (assembler.isOkDebugFormat("dwarf2pass"))
{
assembler.setDebugFormat("dwarf2pass", diags);
if (diags.hasFatalErrorOccurred())
return EXIT_FAILURE;
}
// open the input file or STDIN (for filename of "-")
if (in_filename == "-")
{
OwningPtr<MemoryBuffer> my_stdin;
if (llvm::error_code err = MemoryBuffer::getSTDIN(my_stdin))
{
diags.Report(SourceLocation(), diag::fatal_file_open)
<< in_filename << err.message();
return EXIT_FAILURE;
}
source_mgr.createMainFileIDForMemBuffer(my_stdin.take());
}
else
{
const FileEntry* in = file_mgr.getFile(in_filename);
if (!in)
{
diags.Report(SourceLocation(), diag::fatal_file_open)
<< in_filename;
return EXIT_FAILURE;
}
source_mgr.createMainFileID(in);
}
// Initialize the object.
if (!assembler.InitObject(source_mgr, diags))
return EXIT_FAILURE;
// Configure object per command line parameters.
ConfigureObject(*assembler.getObject());
// Predefine symbols.
for (std::vector<std::string>::const_iterator i=defsym.begin(),
end=defsym.end(); i != end; ++i)
{
StringRef str(*i);
size_t equalpos = str.find('=');
if (equalpos == StringRef::npos)
{
diags.Report(diag::fatal_bad_defsym) << str;
continue;
}
StringRef name = str.slice(0, equalpos);
StringRef vstr = str.slice(equalpos+1, StringRef::npos);
IntNum value;
if (!vstr.empty())
{
// determine radix
unsigned int radix;
if (vstr[0] == '0' && vstr.size() > 1 &&
(vstr[1] == 'x' || vstr[1] == 'X'))
{
vstr = vstr.substr(2);
radix = 16;
}
else if (vstr[0] == '0')
{
vstr = vstr.substr(1);
radix = 8;
}
else
radix = 10;
// check validity
//.........这里部分代码省略.........
示例7: main
int main(int argc, const char **argv) {
llvm::sys::PrintStackTraceOnErrorSignal();
Transforms TransformManager;
ReplacementHandling ReplacementHandler;
TransformManager.registerTransforms();
// Hide all options we don't define ourselves. Move pre-defined 'help',
// 'help-list', and 'version' to our general category.
llvm::StringMap<cl::Option*> Options;
cl::getRegisteredOptions(Options);
const cl::OptionCategory **CategoryEnd =
VisibleCategories + llvm::array_lengthof(VisibleCategories);
for (llvm::StringMap<cl::Option *>::iterator I = Options.begin(),
E = Options.end();
I != E; ++I) {
if (I->first() == "help" || I->first() == "version" ||
I->first() == "help-list")
I->second->setCategory(GeneralCategory);
else if (std::find(VisibleCategories, CategoryEnd, I->second->Category) ==
CategoryEnd)
I->second->setHiddenFlag(cl::ReallyHidden);
}
cl::SetVersionPrinter(&printVersion);
// Parse options and generate compilations.
std::unique_ptr<CompilationDatabase> Compilations(
FixedCompilationDatabase::loadFromCommandLine(argc, argv));
cl::ParseCommandLineOptions(argc, argv);
// Populate the ModifiableFiles structure.
GlobalOptions.ModifiableFiles.readListFromString(IncludePaths, ExcludePaths);
GlobalOptions.ModifiableFiles.readListFromFile(IncludeFromFile,
ExcludeFromFile);
if (!Compilations) {
std::string ErrorMessage;
Compilations.reset(autoDetectCompilations(ErrorMessage));
if (!Compilations) {
llvm::errs() << llvm::sys::path::filename(argv[0]) << ": " << ErrorMessage
<< "\n";
return 1;
}
}
// Populate source files.
std::vector<std::string> Sources;
if (!SourcePaths.empty()) {
// Use only files that are not explicitly excluded.
std::remove_copy_if(SourcePaths.begin(), SourcePaths.end(),
std::back_inserter(Sources),
isFileExplicitlyExcludedPredicate);
} else {
if (GlobalOptions.ModifiableFiles.isIncludeListEmpty()) {
llvm::errs() << llvm::sys::path::filename(argv[0])
<< ": Use -include to indicate which files of "
<< "the compilatiion database to transform.\n";
return 1;
}
// Use source paths from the compilation database.
// We only transform files that are explicitly included.
Sources = Compilations->getAllFiles();
std::vector<std::string>::iterator E = std::remove_if(
Sources.begin(), Sources.end(), isFileNotIncludedPredicate);
Sources.erase(E, Sources.end());
}
// check if line ranges are just applyed to single files
if ( !LineRanges.empty() && Sources.size() > 1 ){
llvm::errs() << "error: -line can only be used for single file.\n";
return 1;
}
// add the line ranges to the sources
if ( !LineRanges.empty() ){
}
if (Sources.empty()) {
llvm::errs() << llvm::sys::path::filename(argv[0])
<< ": Could not determine sources to transform.\n";
return 1;
}
// Enable timming.
GlobalOptions.EnableTiming = TimingDirectoryName.getNumOccurrences() > 0;
bool CmdSwitchError = false;
CompilerVersions RequiredVersions =
handleSupportedCompilers(argv[0], CmdSwitchError);
if (CmdSwitchError)
return 1;
TransformManager.createSelectedTransforms(GlobalOptions, RequiredVersions);
if (TransformManager.begin() == TransformManager.end()) {
if (SupportedCompilers.empty())
llvm::errs() << llvm::sys::path::filename(argv[0])
<< ": no selected transforms\n";
else
llvm::errs() << llvm::sys::path::filename(argv[0])
//.........这里部分代码省略.........
示例8: llvm_manager
int
main(int argc, char* argv[])
{
llvm::llvm_shutdown_obj llvm_manager(false);
cl::SetVersionPrinter(&PrintVersion);
cl::ParseCommandLineOptions(argc, argv);
if (show_help)
cl::PrintHelpMessage();
if (show_license)
{
for (std::size_t i=0; i<sizeof(license_msg)/sizeof(license_msg[0]); i++)
llvm::outs() << license_msg[i] << '\n';
return EXIT_SUCCESS;
}
if (show_info)
{
llvm::outs() << full_version << '\n';
list_module<yasm::ObjectFormatModule>();
return EXIT_SUCCESS;
}
yasm::OffsetDiagnosticPrinter diag_printer(llvm::errs());
yasm::Diagnostic diags(&diag_printer);
yasm::SourceManager source_mgr(diags);
diags.setSourceManager(&source_mgr);
diag_printer.setPrefix("yobjdump");
// Load standard modules
if (!yasm::LoadStandardPlugins())
{
diags.Report(yasm::diag::fatal_standard_modules);
return EXIT_FAILURE;
}
if (show_all_headers)
{
show_file_headers = true;
show_section_headers = true;
show_private_headers = true;
show_relocs = true;
show_symbols = true;
}
// Determine input filename and open input file.
if (in_filenames.empty())
{
diags.Report(yasm::diag::fatal_no_input_files);
return EXIT_FAILURE;
}
int retval = EXIT_SUCCESS;
for (std::vector<std::string>::const_iterator i=in_filenames.begin(),
end=in_filenames.end(); i != end; ++i)
{
try
{
if (DoDump(*i, source_mgr, diags) != EXIT_SUCCESS)
retval = EXIT_FAILURE;
}
catch (std::out_of_range& err)
{
llvm::errs() << *i << ": "
<< "out of range error while reading (corrupt file?)\n";
retval = EXIT_FAILURE;
}
}
return retval;
}
示例9: main
int main(int argc, const char **argv) {
llvm::sys::PrintStackTraceOnErrorSignal();
Transforms TransformManager;
ReplacementHandling ReplacementHandler;
TransformManager.registerTransforms();
// Hide all options we don't define ourselves. Move pre-defined 'help',
// 'help-list', and 'version' to our general category.
llvm::StringMap<cl::Option*> Options;
cl::getRegisteredOptions(Options);
const cl::OptionCategory **CategoryEnd =
VisibleCategories + llvm::array_lengthof(VisibleCategories);
for (llvm::StringMap<cl::Option *>::iterator I = Options.begin(),
E = Options.end();
I != E; ++I) {
if (I->first() == "help" || I->first() == "version" ||
I->first() == "help-list")
I->second->setCategory(GeneralCategory);
else if (std::find(VisibleCategories, CategoryEnd, I->second->Category) ==
CategoryEnd)
I->second->setHiddenFlag(cl::ReallyHidden);
}
cl::SetVersionPrinter(&printVersion);
// Parse options and generate compilations.
std::unique_ptr<CompilationDatabase> Compilations(
FixedCompilationDatabase::loadFromCommandLine(argc, argv));
cl::ParseCommandLineOptions(argc, argv);
// Populate the ModifiableFiles structure.
GlobalOptions.ModifiableFiles.readListFromString(IncludePaths, ExcludePaths);
GlobalOptions.ModifiableFiles.readListFromFile(IncludeFromFile,
ExcludeFromFile);
if (!Compilations) {
std::string ErrorMessage;
Compilations = autoDetectCompilations(ErrorMessage);
if (!Compilations) {
llvm::errs() << llvm::sys::path::filename(argv[0]) << ": " << ErrorMessage
<< "\n";
return 1;
}
}
// Populate source files.
std::vector<std::string> Sources;
if (!SourcePaths.empty()) {
// Use only files that are not explicitly excluded.
std::remove_copy_if(SourcePaths.begin(), SourcePaths.end(),
std::back_inserter(Sources),
isFileExplicitlyExcludedPredicate);
} else {
if (GlobalOptions.ModifiableFiles.isIncludeListEmpty()) {
llvm::errs() << llvm::sys::path::filename(argv[0])
<< ": Use -include to indicate which files of "
<< "the compilatiion database to transform.\n";
return 1;
}
// Use source paths from the compilation database.
// We only transform files that are explicitly included.
Sources = Compilations->getAllFiles();
std::vector<std::string>::iterator E = std::remove_if(
Sources.begin(), Sources.end(), isFileNotIncludedPredicate);
Sources.erase(E, Sources.end());
}
// check if line ranges are just applyed to single files
if ( !LineRanges.empty() && Sources.size() > 1 ) {
llvm::errs() << "error: -line can only be used for single file.\n";
return 1;
}
// add the line ranges to the sources
if ( !LineRanges.empty() ) {
}
std::string filename;
int line_begin, column_begin;
int line_end, column_end;
if ( Target.getNumOccurrences() ) {
// TODO parse the target data
std::stringstream sstr(Target);
char separator;
sstr >>
line_begin >> separator >>
column_begin >> separator >>
line_end >> separator >>
column_end >> separator >> filename;
llvm::errs() << filename << " " << line_begin << "-" <<
column_begin << ":" << line_end << "-" << column_end << "\n";
// store it in the Transform object
}