本文整理汇总了C++中cl::opt::c_str方法的典型用法代码示例。如果您正苦于以下问题:C++ opt::c_str方法的具体用法?C++ opt::c_str怎么用?C++ opt::c_str使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类cl::opt
的用法示例。
在下文中一共展示了opt::c_str方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ModulePass
InternalizePass::InternalizePass(bool AllButMain)
: ModulePass(ID), AllButMain(AllButMain){
initializeInternalizePassPass(*PassRegistry::getPassRegistry());
if (!APIFile.empty()) // If a filename is specified, use it.
LoadFile(APIFile.c_str());
if (!APIList.empty()) // If a list is specified, use it as well.
ExternalNames.insert(APIList.begin(), APIList.end());
}
示例2: initFromString
// Helper function to handle -of, -od, etc.
static void initFromString(const char*& dest, const cl::opt<std::string>& src) {
dest = 0;
if (src.getNumOccurrences() != 0) {
if (src.empty())
error(Loc(), "Expected argument to '-%s'", src.ArgStr);
dest = mem.xstrdup(src.c_str());
}
}
示例3: ModulePass
InternalizePass::InternalizePass()
: ModulePass(ID) {
initializeInternalizePassPass(*PassRegistry::getPassRegistry());
if (!APIFile.empty()) // If a filename is specified, use it.
LoadFile(APIFile.c_str());
ExternalNames.insert(APIList.begin(), APIList.end());
DSONames.insert(DSOList.begin(), DSOList.end());
}
示例4: output
virtual bool
runOnModule(Module& M)
{
AliasAnalysis& aa = this->getAnalysis<AliasAnalysis>();
bool checked = false;
errs() << "GatherInterfacePass::runOnModule: " << M.getModuleIdentifier() << "\n";
if (!GatherInterfaceMain.empty()) {
checked = true;
for (cl::list<std::string>::const_iterator i = GatherInterfaceMain.begin(), e = GatherInterfaceMain.end();
i != e; ++i) {
Function* f = M.getFunction(*i);
if (f == NULL) {
errs() << "Function '" << *i << "' not found, skipping\n";
continue;
}
if (f->isDeclaration()) {
errs() << "Function '" << *i << "' is declaration, skipping\n";
continue;
}
errs() << "Gathering from: " << *f << "\n";
GatherInterface(*f, this->interface, &aa);
}
}
if (!GatherInterfaceEntry.empty()) {
checked = true;
ComponentInterface ci;
for (cl::list<std::string>::const_iterator i = GatherInterfaceEntry.begin(), e = GatherInterfaceEntry.end();
i != e; ++i) {
errs() << "Reading interface from '" << *i << "'...";
if (ci.readFromFile(*i)) {
errs() << "success\n";
} else {
errs() << "failed\n";
continue;
}
}
for (ComponentInterface::FunctionIterator i = ci.begin(), e = ci.end(); i != e; ++i) {
Function* f = M.getFunction(i->first());
if (f == NULL) continue;
if (!GatherInterface(*f, this->interface, &aa)) break;
}
}
if (!checked) {
GatherInterface(M, this->interface, &aa);
}
if (GatherInterfaceOutput != "") {
proto::ComponentInterface ci;
codeInto<ComponentInterface, proto::ComponentInterface> (
this->interface, ci);
std::ofstream output(GatherInterfaceOutput.c_str(), std::ios::binary);
assert(ci.SerializeToOstream(&output));
output.close();
}
return false;
}
示例5: DumpDebugInfoToFile
// search for a BlockString with a name of "hsa_dwarf_debug", this marks
// the beginning of a group of BlockNumerics which make up the elf container
//
// Input: any directive inside the debug section
// the debug section
// Returns: the directive following the matching BlockString (the beginning of
// the BlockNumerics), or the end directive of the section if no
// matching BlockString is found
//
static void DumpDebugInfoToFile( BrigContainer & c )
{
std::ofstream ofs( (const char*)(DebugInfoFilename.c_str()), std::ofstream::binary );
if ( ! ofs.is_open() || ofs.bad() )
std::cout << "Could not create output debug info file " << DebugInfoFilename << ", not dumping debug info\n";
else {
SRef data = c.debugInfo().payload();
ofs.write(data.begin, data.length());
}
}
示例6: runOnModule
bool EnforcingLandmarks::runOnModule(Module &M) {
if (EnforcingLandmarksFile == "") {
const static size_t len = sizeof(DEFAULT_ENFORCING_LANDMARK_FUNCS) /
sizeof(const char *[2]);
for (size_t i = 0; i < len; ++i) {
string func_name = DEFAULT_ENFORCING_LANDMARK_FUNCS[i][0];
string is_blocking = DEFAULT_ENFORCING_LANDMARK_FUNCS[i][1];
insert_enforcing_landmark_func(func_name, is_blocking);
}
} else {
ifstream fin(EnforcingLandmarksFile.c_str());
string func_name, is_blocking;
while (fin >> func_name >> is_blocking)
insert_enforcing_landmark_func(func_name, is_blocking);
}
// Mark any function call to landmark functions as enforcing landmarks.
for (Module::iterator f = M.begin(); f != M.end(); ++f) {
if (f->getName() == "MyMalloc")
continue;
if (f->getName() == "MyFree")
continue;
if (f->getName() == "MyFreeNow")
continue;
if (f->getName() == "maketree")
continue;
for (Function::iterator bb = f->begin(); bb != f->end(); ++bb) {
for (BasicBlock::iterator ins = bb->begin(); ins != bb->end(); ++ins) {
CallSite cs(ins);
if (cs.getInstruction()) {
if (Function *callee = cs.getCalledFunction()) {
StringRef callee_name = callee->getName();
if (enforcing_landmark_funcs.count(callee_name)) {
if (OnlyMain && callee_name != "pthread_self" &&
f->getName() != "main")
continue;
if (callee_name.startswith("pthread_mutex")
|| callee_name.startswith("pthread_cond")
|| callee_name.startswith("pthread_barrier")
|| callee_name.startswith("pthread_rwlock")
|| callee_name.startswith("pthread_spin")) {
if (rand() % 100 < PruningRate)
continue;
}
enforcing_landmarks.insert(ins);
}
}
}
}
}
}
return false;
}
示例7: main
int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv,
" llvm .bc -> .bc modular optimizer\n");
// Load the input module...
std::auto_ptr<Module> M(ParseBytecodeFile(InputFilename));
if (M.get() == 0) {
cerr << "bytecode didn't read correctly.\n";
return 1;
}
// Figure out what stream we are supposed to write to...
std::ostream *Out = &std::cout; // Default to printing to stdout...
if (OutputFilename != "") {
Out = new std::ofstream(OutputFilename.c_str());
if (!Out->good()) {
cerr << "Error opening " << OutputFilename << "!\n";
return 1;
}
}
//
PassManager Passes;
Passes.add(new DataLayout("embec", M.get()));
//Add passes
Passes.add(createCZeroUninitPtrPass());
/*
Passes.add(createABCPreProcessPass());
Passes.add(createArrayBoundsCheckPass());
Passes.add(createStackSafetyPass());
*/
Passes.add(createEmbeCFreeRemovalPass());
// Now that we have all of the passes ready, run them.
if (Passes.run(*M.get()))
cerr << "Program modified.\n";
(*Out) << M.get();
// WriteToC(M.get(), *Out, false);
return 0;
}
示例8: readNames
static void readNames(std::set<std::string>& names) {
std::ifstream msf(epaFile.c_str(), std::ifstream::in);
if (!msf.good())
errs() << "Failed to open file: " << epaFile << " (continuing anyway)\n";
while (msf.good()) {
std::string n;
msf >> n;
if (n.size()) {
names.insert(n);
// errs() << "Read " << n << "\n";
}
}
}
示例9: main
int main(int argc, char **argv) {
cl::ParseCommandLineOptions(argc, argv, "LLJVM Backend\n");
std::string err;
MemoryBuffer *buf = MemoryBuffer::getFileOrSTDIN(input, &err);
if(!buf) {
std::cerr << "Unable to open bitcode file: " << err << std::endl;
return 1;
}
Module *mod = ParseBitcodeFile(buf, getGlobalContext(), &err);
if(!mod) {
std::cerr << "Unable to parse bitcode file: " << err << std::endl;
return 1;
}
llvm::raw_fd_ostream *trace_stream(0);
if (!tracefile.empty()) {
if (debugLevel < 3) {
std::cerr << "May only specify a trace file if generating -g3 debugging information" << std::endl;
return 1;
}
err = "";
trace_stream = new llvm::raw_fd_ostream(tracefile.c_str(), err);
if (!err.empty()) {
std::cerr << "Unable to open tracefile " << tracefile << " : " << err << std::endl;
return 1;
}
}
PassManager pm;
TargetData td("e-p:32:32:32"
"-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64"
"-f32:32:32-f64:64:64");
pm.add(new TargetData(td));
pm.add(createVerifierPass());
pm.add(createGCLoweringPass());
// TODO: fix switch generation so the following pass is not needed
pm.add(createLowerSwitchPass());
pm.add(createIndVarSimplifyPass());
pm.add(createPromoteMemoryToRegisterPass()); //good
pm.add(createDeadStoreEliminationPass());
pm.add(createAggressiveDCEPass());
pm.add(createCFGSimplificationPass());
pm.add(new JVMWriter(&td, fouts(), classname
, sourcename, debugLevel, trace_stream));
pm.add(createGCInfoDeleter());
pm.run(*mod);
return 0;
}
示例10: main
int main(int argc, char * argv[]) {
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
LLVMContext &Context = getGlobalContext();
cl::ParseCommandLineOptions(argc, argv, "Anteater compiler\n");
SMDiagnostic Err;
// Load the input module...
std::auto_ptr<Module> M;
M.reset(ParseIRFile(InputFilename, Err, Context));
if (M.get() == 0) {
Err.Print(argv[0], errs());
return 1;
}
// Figure out what stream we are supposed to write to...
// FIXME: outs() is not binary!
raw_ostream *Out = &outs(); // Default to printing to stdout...
if (OutputFilename != "-") {
std::string ErrorInfo;
Out = new raw_fd_ostream(OutputFilename.c_str(), ErrorInfo,
raw_fd_ostream::F_Binary);
if (!ErrorInfo.empty()) {
errs() << ErrorInfo << '\n';
delete Out;
return 1;
}
}
PassManager Passes;
if (Backend == "yices") {
Passes.add(anteater::createXorEliminationPass(&Context));
Passes.add(anteater::createAnteaterInstructionNamerPass());
Passes.add(anteater::createYicesWriter(Out));
} else {
Passes.add(anteater::createAnteaterInstructionNamerPass());
Passes.add(anteater::createSMT12Writer(Out));
}
Passes.run(*M.get());
// Delete the raw_fd_ostream.
if (Out != &outs())
delete Out;
return 0;
}
示例11: main
//===----------------------------------------------------------------------===//
int main(int argc, char **argv) {
// Print a stack trace if we signal out.
sys::PrintStackTraceOnErrorSignal();
PrettyStackTraceProgram X(argc, argv);
llvm_shutdown_obj Y; // Call llvm_shutdown() on exit.
cl::ParseCommandLineOptions(argc, argv, "llvm coverage tool\n");
std::string ErrorInfo;
raw_fd_ostream OS(OutputFile.c_str(), ErrorInfo);
if (!ErrorInfo.empty())
errs() << ErrorInfo << "\n";
GCOVFile GF;
if (InputGCNO.empty())
errs() << " " << argv[0] << ": No gcov input file!\n";
OwningPtr<MemoryBuffer> GCNO_Buff;
if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputGCNO, GCNO_Buff)) {
errs() << InputGCNO << ": " << ec.message() << "\n";
return 1;
}
GCOVBuffer GCNO_GB(GCNO_Buff.get());
if (!GF.read(GCNO_GB)) {
errs() << "Invalid .gcno File!\n";
return 1;
}
if (!InputGCDA.empty()) {
OwningPtr<MemoryBuffer> GCDA_Buff;
if (error_code ec = MemoryBuffer::getFileOrSTDIN(InputGCDA, GCDA_Buff)) {
errs() << InputGCDA << ": " << ec.message() << "\n";
return 1;
}
GCOVBuffer GCDA_GB(GCDA_Buff.get());
if (!GF.read(GCDA_GB)) {
errs() << "Invalid .gcda File!\n";
return 1;
}
}
if (DumpGCOV)
GF.dump();
FileInfo FI;
GF.collectLineCounts(FI);
FI.print(OS, InputGCNO, InputGCDA);
return 0;
}
示例12: main
int main(int argc, char ** argv)
{
unsigned char * bytes;
unsigned byte_count;
std::auto_ptr<Module> M;
LLVMContext &Context = getGlobalContext();
SMDiagnostic Err;
cl::ParseCommandLineOptions(argc, argv, "llvm system compiler\n");
M.reset(ParseIRFile(InputFilename, Err, Context));
Module * mod = M.get();
radeon_llvm_compile(wrap(mod), &bytes, &byte_count, TargetGPUName.c_str(), 1);
}
示例13: runOnModule
bool PointToDrawer::runOnModule(Module &M) {
PointerAnalysis &PA = getAnalysis<PointerAnalysis>();
if (DotFileName != "") {
string ErrorInfo;
raw_fd_ostream DotFile(DotFileName.c_str(), ErrorInfo);
printToDot(DotFile);
}
if (ShouldPrintStat) {
PA.printStats(errs());
}
return false;
}
示例14: DisassembleOneInput
void DisassembleOneInput(const uint8_t *Data, size_t Size) {
char AssemblyText[AssemblyTextBufSize];
std::vector<uint8_t> DataCopy(Data, Data + Size);
LLVMDisasmContextRef Ctx = LLVMCreateDisasmCPUFeatures(
TripleName.c_str(), MCPU.c_str(), FeaturesStr.c_str(), nullptr, 0,
nullptr, nullptr);
assert(Ctx);
uint8_t *p = DataCopy.data();
unsigned Consumed;
unsigned InstructionsProcessed = 0;
do {
Consumed = LLVMDisasmInstruction(Ctx, p, Size, 0, AssemblyText,
AssemblyTextBufSize);
Size -= Consumed;
p += Consumed;
InstructionsProcessed ++;
if (InsnLimit != 0 && InstructionsProcessed < InsnLimit)
break;
} while (Consumed != 0);
LLVMDisasmDispose(Ctx);
}
示例15: getDefault
GCOVOptions GCOVOptions::getDefault() {
GCOVOptions Options;
Options.EmitNotes = true;
Options.EmitData = true;
Options.UseCfgChecksum = false;
Options.NoRedZone = false;
Options.FunctionNamesInData = true;
if (DefaultGCOVVersion.size() != 4) {
llvm::report_fatal_error(std::string("Invalid -default-gcov-version: ") +
DefaultGCOVVersion);
}
memcpy(Options.Version, DefaultGCOVVersion.c_str(), 4);
return Options;
}