本文整理汇总了C++中llvm::cl::opt::size方法的典型用法代码示例。如果您正苦于以下问题:C++ opt::size方法的具体用法?C++ opt::size怎么用?C++ opt::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类llvm::cl::opt
的用法示例。
在下文中一共展示了opt::size方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readInOutGraph
void readInOutGraph(Graph& graph) {
using namespace Galois::Graph;
if (symmetricGraph) {
Galois::Graph::readGraph(graph, filename);
} else if (transposeGraphName.size()) {
Galois::Graph::readGraph(graph, filename, transposeGraphName);
} else {
GALOIS_DIE("Graph type not supported");
}
}
示例2: main
int main(int argc, char **argv) {
INITIALIZE_LLVM(argc, argv);
llvm::cl::ParseCommandLineOptions(argc, argv, "Swift LLVM IR Generator\n");
if (PrintStats)
llvm::EnableStatistics();
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);
Invocation.setFrameworkSearchPaths(FrameworkPaths);
// 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 (!Target.empty())
Invocation.setTargetTriple(Target);
if (!ResourceDir.empty())
Invocation.setRuntimeResourcePath(ResourceDir);
// Set the module cache path. If not passed in we use the default swift module
// cache.
Invocation.getClangImporterOptions().ModuleCachePath = ModuleCachePath;
Invocation.setParseStdlib();
// Setup the language options
auto &LangOpts = Invocation.getLangOptions();
LangOpts.DisableAvailabilityChecking = true;
LangOpts.EnableAccessControl = false;
LangOpts.EnableObjCAttrRequiresFoundation = false;
LangOpts.EnableObjCInterop = LangOpts.Target.isOSDarwin();
// Setup the SIL Options.
SILOptions &SILOpts = Invocation.getSILOptions();
SILOpts.AssumeUnqualifiedOwnershipWhenParsing =
AssumeUnqualifiedOwnershipWhenParsing;
// Setup the IRGen Options.
IRGenOptions &Opts = Invocation.getIRGenOptions();
Opts.MainInputFilename = InputFilename;
Opts.OutputFilenames.push_back(OutputFilename);
Opts.OutputKind = OutputKind;
// 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 {
const StringRef Name = ModuleName.size() ? StringRef(ModuleName) : "main";
Invocation.setModuleName(Name);
Invocation.setInputKind(InputFileKind::IFK_SIL);
}
CompilerInstance CI;
PrintingDiagnosticConsumer PrintDiags;
CI.addDiagnosticConsumer(&PrintDiags);
if (!PerformWMO) {
auto &FrontendOpts = Invocation.getFrontendOptions();
if (!InputFilename.empty() && InputFilename != "-") {
FrontendOpts.PrimaryInput =
SelectedInput(FrontendOpts.InputFilenames.size());
} else {
FrontendOpts.PrimaryInput = SelectedInput(
FrontendOpts.InputBuffers.size(), SelectedInput::InputKind::Buffer);
}
}
if (CI.setup(Invocation))
return 1;
CI.performSema();
//.........这里部分代码省略.........
示例3: 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(
//.........这里部分代码省略.........