本文整理汇总了C++中llvm::cl::list类的典型用法代码示例。如果您正苦于以下问题:C++ list类的具体用法?C++ list怎么用?C++ list使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了list类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: if
static std::string
GetBitsSetting()
{
std::string bits = YGAS_OBJFMT_BITS;
// Walk through bits_32 and bits_64 in parallel, ordering by command line
// argument position.
unsigned int bits32_pos = 0, bits32_num = 0;
unsigned int bits64_pos = 0, bits64_num = 0;
for (;;)
{
if (bits32_num < bits_32.size())
bits32_pos = bits_32.getPosition(bits32_num);
else
bits32_pos = 0;
if (bits64_num < bits_64.size())
bits64_pos = bits_64.getPosition(bits64_num);
else
bits64_pos = 0;
if (bits32_pos != 0 && (bits64_pos == 0 || bits32_pos < bits64_pos))
{
// Handle bits32 option
++bits32_num;
bits = "32";
}
else if (bits64_pos != 0 &&
(bits32_pos == 0 || bits64_pos < bits32_pos))
{
// Handle bits64 option
++bits64_num;
bits = "64";
}
else
break; // we're done with the list
}
return bits;
}
开发者ID:8l,项目名称:yasm-nextgen,代码行数:38,代码来源:ygas.cpp
示例2: main
int main(int argc, char **argv) {
INITIALIZE_LLVM(argc, argv);
llvm::cl::ParseCommandLineOptions(argc, argv, "Swift SIL Extractor\n");
CompilerInvocation Invocation;
Invocation.setMainExecutablePath(llvm::sys::fs::getMainExecutable(
argv[0], reinterpret_cast<void *>(&anchorForGetMainExecutable)));
// Give the context the list of search paths to use for modules.
Invocation.setImportSearchPaths(ImportPaths);
// Set the SDK path and target if given.
if (SDKPath.getNumOccurrences() == 0) {
const char *SDKROOT = getenv("SDKROOT");
if (SDKROOT)
SDKPath = SDKROOT;
}
if (!SDKPath.empty())
Invocation.setSDKPath(SDKPath);
if (!Triple.empty())
Invocation.setTargetTriple(Triple);
if (!ResourceDir.empty())
Invocation.setRuntimeResourcePath(ResourceDir);
Invocation.getClangImporterOptions().ModuleCachePath = ModuleCachePath;
Invocation.setParseStdlib();
Invocation.getLangOptions().DisableAvailabilityChecking = true;
Invocation.getLangOptions().EnableAccessControl = false;
Invocation.getLangOptions().EnableObjCAttrRequiresFoundation = false;
// Load the input file.
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> FileBufOrErr =
llvm::MemoryBuffer::getFileOrSTDIN(InputFilename);
if (!FileBufOrErr) {
fprintf(stderr, "Error! Failed to open file: %s\n", InputFilename.c_str());
exit(-1);
}
// If it looks like we have an AST, set the source file kind to SIL and the
// name of the module to the file's name.
Invocation.addInputBuffer(FileBufOrErr.get().get());
serialization::ExtendedValidationInfo extendedInfo;
auto result = serialization::validateSerializedAST(
FileBufOrErr.get()->getBuffer(), &extendedInfo);
bool HasSerializedAST = result.status == serialization::Status::Valid;
if (HasSerializedAST) {
const StringRef Stem = ModuleName.size()
? StringRef(ModuleName)
: llvm::sys::path::stem(InputFilename);
Invocation.setModuleName(Stem);
Invocation.setInputKind(InputFileKind::IFK_Swift_Library);
} else {
Invocation.setModuleName("main");
Invocation.setInputKind(InputFileKind::IFK_SIL);
}
SILOptions &SILOpts = Invocation.getSILOptions();
SILOpts.AssumeUnqualifiedOwnershipWhenParsing =
AssumeUnqualifiedOwnershipWhenParsing;
CompilerInstance CI;
PrintingDiagnosticConsumer PrintDiags;
CI.addDiagnosticConsumer(&PrintDiags);
if (CI.setup(Invocation))
return 1;
CI.performSema();
// If parsing produced an error, don't run any passes.
if (CI.getASTContext().hadError())
return 1;
// Load the SIL if we have a module. We have to do this after SILParse
// creating the unfortunate double if statement.
if (HasSerializedAST) {
assert(!CI.hasSILModule() &&
"performSema() should not create a SILModule.");
CI.setSILModule(
SILModule::createEmptyModule(CI.getMainModule(), CI.getSILOptions()));
std::unique_ptr<SerializedSILLoader> SL = SerializedSILLoader::create(
CI.getASTContext(), CI.getSILModule(), nullptr);
if (extendedInfo.isSIB())
SL->getAllForModule(CI.getMainModule()->getName(), nullptr);
else
SL->getAll();
}
if (CommandLineFunctionNames.empty() && FunctionNameFile.empty())
return CI.getASTContext().hadError();
// For efficient usage, we separate our names into two separate sorted
// lists, one of managled names, and one of unmangled names.
std::vector<std::string> Names;
getFunctionNames(Names);
// First partition our function names into mangled/demangled arrays.
auto FirstDemangledName = std::partition(
//.........这里部分代码省略.........
开发者ID:apple,项目名称:swift,代码行数:101,代码来源:SILFunctionExtractor.cpp
示例3: 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
}
开发者ID:realincubus,项目名称:clang-refactor,代码行数:99,代码来源:ClangModernize.cpp
示例4: main
int main(int argc, char *argv[]) {
llvm::cl::SetVersionPrinter(PrintVersion);
llvm::cl::ParseCommandLineOptions(argc, argv, "CFG to LLVM");
auto context = llvm::make_unique<llvm::LLVMContext>();
if (OS.empty()) {
if (ListSupported || ListUnsupported) {
OS = "linux"; // just need something
}
else {
std::cerr << "-os must be specified" << std::endl;
return EXIT_FAILURE;
}
}
if (!(ListSupported || ListUnsupported || ListCFGFunctions) && EntryPoints.empty()) {
std::cerr
<< "-entrypoint must be specified" << std::endl;
return EXIT_FAILURE;
}
if (!InitArch(context.get(), OS, Arch)) {
std::cerr
<< "Cannot initialize for arch " << Arch
<< " and OS " << OS << std::endl;
return EXIT_FAILURE;
}
auto M = CreateModule(context.get());
if (!M) {
return EXIT_FAILURE;
}
auto triple = M->getTargetTriple();
if (ListSupported || ListUnsupported) {
ListArchSupportedInstructions(triple, llvm::outs(), ListSupported, ListUnsupported);
return EXIT_SUCCESS;
}
if (InputFilename.empty()) {
std::cerr
<< "Must specify an input file." << std::endl;
return EXIT_FAILURE;
}
//reproduce NativeModule from CFG input argument
try {
std::unique_ptr<NativeModule> mod(ReadProtoBuf(InputFilename));
if (!mod) {
std::cerr << "Unable to read module from CFG" << std::endl;
return EXIT_FAILURE;
}
if (ListCFGFunctions) {
PrintCFGFunctionList(mod.get(), Arch);
return EXIT_SUCCESS;
}
//make sure the entry point list is correct before we start lifting the code
const std::vector<NativeEntrySymbol> &module_entry_points = mod->getEntryPoints();
for (const auto &entry_point : EntryPoints) {
auto it = std::find_if(
module_entry_points.begin(),
module_entry_points.end(),
[&entry_point](const NativeEntrySymbol &symbol) -> bool {
return (symbol.getName() == entry_point);
}
);
if (it == module_entry_points.end()) {
std::cerr << "The following entry point could not be found: \"" << entry_point << "\". Aborting..." << std::endl;
return EXIT_FAILURE;
}
}
//now, convert it to an LLVM module
ArchInitAttachDetach(M);
if (!LiftCodeIntoModule(mod.get(), M)) {
std::cerr << "Failure to convert to LLVM module!" << std::endl;
return EXIT_FAILURE;
}
std::set<VA> entry_point_pcs;
for (const auto &entry_point_name : EntryPoints) {
auto entry_pc = FindSymbolInModule(mod.get(), entry_point_name);
assert(entry_pc != static_cast<VA>( -1));
std::cerr << "Adding entry point: " << entry_point_name << std::endl
<< entry_point_name << " is implemented by sub_" << std::hex
<< entry_pc << std::endl;
if ( !ArchAddEntryPointDriver(M, entry_point_name, entry_pc)) {
return EXIT_FAILURE;
}
//.........这里部分代码省略.........
开发者ID:kumarak,项目名称:mcsema,代码行数:101,代码来源:Lift.cpp
示例5: 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])
//.........这里部分代码省略.........
开发者ID:zhongxingzhi,项目名称:clang-refactor,代码行数:101,代码来源:ClangModernize.cpp
示例6: main
/**
Most of the main program is pieced together from examples on the web. We are doing the following.
-# Creating lists of include directories, defines, and input files from the command line arguments.
-# Initializing the compiler to read C++ code, and setting the compiler to think we are creating
code for the default target architecture.
-# Creating the necessary source and file managers as well as the preprocessor.
-# Adding search directories and creating #define statements for -D command line arguments.
-# Telling clang to use our ICGASTConsumer as an ASTConsumer.
-# Parse the input file.
*/
int main( int argc , char * argv[] ) {
#if (__clang_major__ >= 6) || ((__clang_major__ == 3) && (__clang_minor__ >= 5))
clang::TargetOptions to;
#elif (__clang_major__ == 3) && (__clang_minor__ >= 3)
clang::TargetOptions * to = new clang::TargetOptions() ;
#else
clang::TargetOptions to;
#endif
clang::CompilerInstance ci;
/* Gather all of the command line arguments into lists of include directories, defines, and input files.
All other arguments will be ignored. */
llvm::cl::SetVersionPrinter(ICG_version) ;
llvm::cl::ParseCommandLineOptions(argc , argv) ;
if ( ! validAttributesVersion(attr_version) ) {
return -1 ;
}
/*
if ( show_units ) {
list_units() ;
return 0 ;
}
*/
if ( input_file_names.empty() ) {
std::cerr << "No header file specified" << std::endl ;
return 1 ;
}
ci.createDiagnostics();
clang::DiagnosticOptions & diago = ci.getDiagnosticOpts() ;
diago.ShowColors = 1 ;
ci.getDiagnostics().setIgnoreAllWarnings(true) ;
#if ( GCC_MAJOR == 4 ) && ( GCC_MINOR <= 2 )
ci.getDiagnostics().setSuppressAllDiagnostics() ;
#endif
// Set all of the defaults to c++
clang::CompilerInvocation::setLangDefaults(ci.getLangOpts() , clang::IK_CXX) ;
ci.getLangOpts().CXXExceptions = true ;
// Activate C++11 parsing
ci.getLangOpts().CPlusPlus11 = true ;
// Set the default target architecture
#if (__clang_major__ >= 6) || (__clang_major__ == 3) && (__clang_minor__ >= 5)
to.Triple = llvm::sys::getDefaultTargetTriple();
#elif (__clang_major__ == 3) && (__clang_minor__ >= 3)
to->Triple = llvm::sys::getDefaultTargetTriple();
#else
to.Triple = llvm::sys::getDefaultTargetTriple();
#endif
#if (__clang_major__ >= 6) || (__clang_major__ == 3) && (__clang_minor__ >= 5)
std::shared_ptr<clang::TargetOptions> shared_to = std::make_shared<clang::TargetOptions>(to) ;
clang::TargetInfo *pti = clang::TargetInfo::CreateTargetInfo(ci.getDiagnostics(), shared_to);
#else
clang::TargetInfo *pti = clang::TargetInfo::CreateTargetInfo(ci.getDiagnostics(), to);
#endif
ci.setTarget(pti);
// Create all of the necessary managers.
ci.createFileManager();
ci.createSourceManager(ci.getFileManager());
#if (__clang_major__ >= 6) || (__clang_major__ == 3) && (__clang_minor__ >= 5)
ci.createPreprocessor(clang::TU_Complete);
#else
ci.createPreprocessor();
#endif
clang::HeaderSearch & hs = ci.getPreprocessor().getHeaderSearchInfo() ;
clang::HeaderSearchOptions & hso = ci.getHeaderSearchOpts() ;
clang::Preprocessor & pp = ci.getPreprocessor() ;
// Add all of the include directories to the preprocessor
HeaderSearchDirs hsd(hs , hso , pp, sim_services_flag) ;
hsd.addSearchDirs ( include_dirs ) ;
// Tell the preprocessor to use its default predefines
clang::PreprocessorOptions & ppo = ci.getPreprocessorOpts() ;
ppo.UsePredefines = true;
#if (__clang_major__ == 3) && (__clang_minor__ >= 8)
pp.getBuiltinInfo().initializeBuiltins(pp.getIdentifierTable(), pp.getLangOpts());
#else
//.........这里部分代码省略.........
开发者ID:E-LLP,项目名称:trick,代码行数:101,代码来源:main.cpp
示例7: 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;
}
开发者ID:PeterJohnson,项目名称:yasm-nextgen,代码行数:73,代码来源:yobjdump.cpp
示例8: 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;
}
开发者ID:dongAxis,项目名称:clang-700.0.72,代码行数:33,代码来源:ModuleMapChecker.cpp
示例9: main
int main(int argc, char **argv) {
llvm::cl::ParseCommandLineOptions(argc, argv, "clang-wpa");
FileManager FileMgr;
std::vector<ASTUnit*> ASTUnits;
if (InputFilenames.empty())
return 0;
DiagnosticOptions DiagOpts;
llvm::IntrusiveRefCntPtr<Diagnostic> Diags
= CompilerInstance::createDiagnostics(DiagOpts, argc, argv);
for (unsigned i = 0, e = InputFilenames.size(); i != e; ++i) {
const std::string &InFile = InputFilenames[i];
llvm::OwningPtr<ASTUnit> AST(ASTUnit::LoadFromPCHFile(InFile, Diags));
if (!AST)
return 1;
ASTUnits.push_back(AST.take());
}
llvm::OwningPtr<CallGraph> CG;
CG.reset(new CallGraph());
for (unsigned i = 0, e = ASTUnits.size(); i != e; ++i)
CG->addTU(ASTUnits[i]->getASTContext());
CG->ViewCallGraph();
}
开发者ID:jhoush,项目名称:dist-clang,代码行数:28,代码来源:clang-wpa.cpp
示例10: main
int main(int argc, char* argv[])
{
llvm::cl::ParseCommandLineOptions(argc, argv, " globalcollect\n"
" This collects and prints global variables found in C programs.");
if (!IgnoredParams.empty()) {
cerr << "Ignoring the following parameters:";
copy(IgnoredParams.begin(), IgnoredParams.end(),
ostream_iterator<string>(cerr, " "));
}
// Create Preprocessor object
PPContext context;
// Add header search directories (C only, no C++ or ObjC)
InitHeaderSearch init(context.headers);
// user headers
for (int i = 0; i < I_dirs.size(); ++i) {
cerr << "adding " << I_dirs[i] << endl;
init.AddPath(I_dirs[i], InitHeaderSearch::Angled, false, true, false);
}
init.AddDefaultSystemIncludePaths(context.opts);
init.Realize();
// Add defines passed in through parameters
vector<char> predefineBuffer;
for (int i = 0; i < D_macros.size(); ++i) {
cerr << "defining " << D_macros[i] << endl;
::DefineBuiltinMacro(predefineBuffer, D_macros[i].c_str());
}
predefineBuffer.push_back('\0');
context.pp.setPredefines(&predefineBuffer[0]);
// Add input file
const FileEntry* File = context.fm.getFile(InputFilename);
if (!File) {
cerr << "Failed to open \'" << InputFilename << "\'" << endl;
return EXIT_FAILURE;
}
context.sm.createMainFileID(File, SourceLocation());
// Parse it
cout << "<h2><code>" << InputFilename << "</code></h2>" << endl << endl;
cout << "<pre><code>";
MyASTConsumer c;
ParseAST(context.pp, &c);
cout << "</code></pre>" << endl << endl;
cout << endl;
unsigned NumDiagnostics = context.diags.getNumDiagnostics();
if (NumDiagnostics)
fprintf(stderr, "%d diagnostic%s generated.\n", NumDiagnostics,
(NumDiagnostics == 1 ? "" : "s"));
}
开发者ID:nico,项目名称:clangtut,代码行数:60,代码来源:tut08_ast.cpp
示例11: 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);
}
开发者ID:8l,项目名称:yasm-nextgen,代码行数:58,代码来源:ygas.cpp
示例12: main
int main(int argc, const char **argv) {
void *MainAddr = (void*) (intptr_t) GetExecutablePath;
llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
std::string
resourcesPath = CompilerInvocation::GetResourcesPath(argv[0], MainAddr);
int optargc = 0;
for (; optargc != argc; ++optargc) {
if (StringRef(argv[optargc]) == "--args")
break;
}
llvm::cl::ParseCommandLineOptions(optargc, argv, "arcmt-test");
if (VerifyTransformedFiles) {
if (ResultFiles.empty()) {
llvm::cl::PrintHelpMessage();
return 1;
}
return verifyTransformedFiles(ResultFiles);
}
if (optargc == argc) {
llvm::cl::PrintHelpMessage();
return 1;
}
ArrayRef<const char*> Args(argv+optargc+1, argc-optargc-1);
if (CheckOnly)
return checkForMigration(resourcesPath, Args);
return performTransformations(resourcesPath, Args);
}
开发者ID:CSI-LLVM,项目名称:clang,代码行数:34,代码来源:arcmt-test.cpp
示例13: autoDetectFromDirectory
CompilationDatabase *autoDetectCompilations(std::string &ErrorMessage) {
// Auto-detect a compilation database from BuildPath.
if (BuildPath.getNumOccurrences() > 0)
return CompilationDatabase::autoDetectFromDirectory(BuildPath,
ErrorMessage);
// Try to auto-detect a compilation database from the first source.
if (!SourcePaths.empty()) {
if (CompilationDatabase *Compilations =
CompilationDatabase::autoDetectFromSource(SourcePaths[0],
ErrorMessage)) {
// FIXME: just pass SourcePaths[0] once getCompileCommands supports
// non-absolute paths.
SmallString<64> Path(SourcePaths[0]);
llvm::sys::fs::make_absolute(Path);
std::vector<CompileCommand> Commands =
Compilations->getCompileCommands(Path);
// Ignore a detected compilation database that doesn't contain source0
// since it is probably an unrelated compilation database.
if (!Commands.empty())
return Compilations;
}
// Reset ErrorMessage since a fix compilation database will be created if
// it fails to detect one from source.
ErrorMessage = "";
// If no compilation database can be detected from source then we create a
// fixed compilation database with c++11 support.
std::string CommandLine[] = { "-std=c++11" };
return new FixedCompilationDatabase(".", CommandLine);
}
ErrorMessage = "Could not determine sources to transform";
return 0;
}
开发者ID:zhongxingzhi,项目名称:clang-refactor,代码行数:33,代码来源:ClangModernize.cpp
示例14: processConfigFile
static void processConfigFile(const std::string &path)
{
oclint::option::ConfigFile config(path);
for (const oclint::option::RuleConfigurationPair &ruleConfig : config.ruleConfigurations())
{
consumeRuleConfiguration(ruleConfig.key(), ruleConfig.value());
}
for (const llvm::StringRef &rulePath : config.rulePaths())
{
argRulesPath.push_back(rulePath.str());
}
std::vector<std::string> enableRules;
for (auto rule : config.rules())
{
enableRules.push_back(rule.str());
}
filter.enableRules(enableRules.begin(), enableRules.end());
std::vector<std::string> disableRules;
for (auto rule : config.disableRules())
{
disableRules.push_back(rule.str());
}
filter.disableRules(disableRules.begin(), disableRules.end());
updateArgIfSet(argOutput, config.output());
updateArgIfSet(argReportType, config.reportType());
updateArgIfSet(argMaxP1, config.maxP1());
updateArgIfSet(argMaxP2, config.maxP2());
updateArgIfSet(argMaxP3, config.maxP3());
updateArgIfSet(argGlobalAnalysis, config.enableGlobalAnalysis());
updateArgIfSet(argClangChecker, config.clangChecker());
updateArgIfSet(argDuplications, config.allowDuplicatedViolations());
}
开发者ID:oclint,项目名称:oclint,代码行数:33,代码来源:Options.cpp
示例15: main
int main(int argc, char **argv) {
#if defined(__CYGWIN__)
// Cygwin clang 3.5.2 with '-O3' generates CRASHING BINARY,
// if main()'s first function call is passing argv[0].
std::rand();
#endif
llvm::cl::ParseCommandLineOptions(argc, argv);
swift::Demangle::DemangleOptions options;
options.SynthesizeSugarOnTypes = !DisableSugar;
if (Simplified)
options = swift::Demangle::DemangleOptions::SimplifiedUIDemangleOptions();
if (InputNames.empty()) {
CompactMode = true;
return demangleSTDIN(options);
} else {
swift::Demangle::Context DCtx;
for (llvm::StringRef name : InputNames) {
demangle(llvm::outs(), name, DCtx, options);
llvm::outs() << '\n';
}
return EXIT_SUCCESS;
}
}
开发者ID:Jnosh,项目名称:swift,代码行数:26,代码来源:swift-demangle.cpp
示例16: libPath
std::vector<std::string> oclint::option::rulesPath()
{
if (argRulesPath.size() > 0)
{
return argRulesPath;
}
std::string defaultRulePath = libPath() + "/oclint/rules";
std::vector<std::string> defaultRulesPath { defaultRulePath };
return defaultRulesPath;
}
开发者ID:oclint,项目名称:oclint,代码行数:10,代码来源:Options.cpp
示例17: 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());
}
开发者ID:oclint,项目名称:oclint,代码行数:19,代码来源:Options.cpp
示例18: main
int main(int argc, char** argv) {
llvm::cl::ParseCommandLineOptions(argc, argv);
graph.structureFromFile(inputfilename);
for (unsigned i = 0; i != statModeList.size(); ++i) {
switch (statModeList[i]) {
case summary: do_summary(); break;
case degrees: do_degrees(); break;
default: abort(); break;
}
}
return 0;
}
开发者ID:nikunjy,项目名称:parallelStuff,代码行数:14,代码来源:graph-stats.cpp
示例19: 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;
}
}
}
开发者ID:apple,项目名称:swift,代码行数:24,代码来源:SILFunctionExtractor.cpp
示例20: main
int main(int argc, char **argv) {
#if defined(__CYGWIN__)
// Cygwin clang 3.5.2 with '-O3' generates CRASHING BINARY,
// if main()'s first function call is passing argv[0].
std::rand();
#endif
llvm::cl::ParseCommandLineOptions(argc, argv);
swift::Demangle::DemangleOptions options;
options.SynthesizeSugarOnTypes = !DisableSugar;
if (Simplified)
options = swift::Demangle::DemangleOptions::SimplifiedUIDemangleOptions();
if (InputNames.empty()) {
CompactMode = true;
auto input = llvm::MemoryBuffer::getSTDIN();
if (!input) {
llvm::errs() << input.getError().message() << '\n';
return EXIT_FAILURE;
}
llvm::StringRef inputContents = input.get()->getBuffer();
// This doesn't handle Unicode symbols, but maybe that's okay.
llvm::Regex maybeSymbol("_T[_a-zA-Z0-9$]+");
llvm::SmallVector<llvm::StringRef, 1> matches;
while (maybeSymbol.match(inputContents, &matches)) {
llvm::outs() << substrBefore(inputContents, matches.front());
demangle(llvm::outs(), matches.front(), options);
inputContents = substrAfter(inputContents, matches.front());
}
llvm::outs() << inputContents;
} else {
for (llvm::StringRef name : InputNames) {
demangle(llvm::outs(), name, options);
llvm::outs() << '\n';
}
}
return EXIT_SUCCESS;
}
开发者ID:007Indian,项目名称:swift,代码行数:41,代码来源:swift-demangle.cpp
注:本文中的llvm::cl::list类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目 |
请发表评论