• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ SMDiagnostic类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中SMDiagnostic的典型用法代码示例。如果您正苦于以下问题:C++ SMDiagnostic类的具体用法?C++ SMDiagnostic怎么用?C++ SMDiagnostic使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了SMDiagnostic类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: main

int
main(int argc, char **argv)
{
	LLVMContext &context = getGlobalContext();
	SMDiagnostic err;
	std::unique_ptr<Module> m = parseIRFile("-", err, context);
	if (!m) {
		err.print(argv[0], errs());
		return 1;
	}

	for (auto &v : m->getGlobalList()) {
		if (v.hasLocalLinkage() && v.hasUnnamedAddr())
			v.setName("");
	}
	for (auto &f : m->getFunctionList()) {
		for (auto &a : f.getArgumentList())
			a.setName("");
		for (auto &b : f.getBasicBlockList()) {
			b.setName("");
			for (auto &i : b.getInstList())
				i.setName("");
		}
	}

	outs() << *m;
	return 0;
}
开发者ID:eldesh,项目名称:smlsharp,代码行数:28,代码来源:anonymize.cpp


示例2: main

int main(int argc, char **argv) {
  if (argc < 2) {
    errs() << "Usage: " << argv[0] << " <IR file>\n";
    return 1;
  }

  // Parse the input LLVM IR file into a module.
  SMDiagnostic Err;
  std::unique_ptr<Module> Mod(parseIRFile(argv[1], Err, getGlobalContext()));
  if (!Mod) {
    Err.print(argv[0], errs());
    return 1;
  }

  // Create a function declarations for _tidx, _tidy, _tidz
  FunctionType *TidFuncTy =
      FunctionType::get(Type::getInt32Ty(Mod->getContext()), false);
  Function *Tidx = Function::Create(TidFuncTy, GlobalValue::InternalLinkage,
                                    "_tidx", Mod.get());
  Function *Tidy = Function::Create(TidFuncTy, GlobalValue::InternalLinkage,
                                    "_tidy", Mod.get());
  Function *Tidz = Function::Create(TidFuncTy, GlobalValue::InternalLinkage,
                                    "_tidz", Mod.get());

  // Create a pass manager and fill it with the passes we want to run.
  PassManager PM;
  PM.add(new ReplaceThreadIdxRefs(Tidx, Tidy, Tidz));
  PM.run(*Mod);

  outs() << "Dumping the module after the pass has run:\n";
  Mod->dump();

  return 0;
}
开发者ID:CarterTsai,项目名称:llvm-clang-samples,代码行数:34,代码来源:replace_threadidx_with_call.cpp


示例3: main

int
main (int argc, char **argv) {
  // This boilerplate provides convenient stack traces and clean LLVM exit
  // handling. It also initializes the built in support for convenient
  // command line option handling.
  sys::PrintStackTraceOnErrorSignal();
  llvm::PrettyStackTraceProgram X(argc, argv);
  llvm_shutdown_obj shutdown;
  cl::ParseCommandLineOptions(argc, argv);

  // Construct an IR file from the filename passed on the command line.
  SMDiagnostic err;
  LLVMContext &context = getGlobalContext();
  unique_ptr<Module> module = parseIRFile(inPath.getValue(), err, context);

  if (!module.get()) {
    errs() << "Error reading bitcode file: " << inPath << "\n";
    err.print(argv[0], errs());
    return -1;
  }

  if (AnalysisType::DYNAMIC == analysisType) {
    prepareLinkingPaths(StringRef(argv[0]));
    instrumentForDynamicCount(*module);
  } else {
    countStaticCalls(*module);
  }

  return 0;
}
开发者ID:pb2bee,项目名称:llvm-demo,代码行数:30,代码来源:main.cpp


示例4: main

int
main (int argc, char **argv, const char **env) {
  // This boilerplate provides convenient stack traces and clean LLVM exit
  // handling. It also initializes the built in support for convenient
  // command line option handling.
  sys::PrintStackTraceOnErrorSignal();
  llvm::PrettyStackTraceProgram X{argc, argv};
  llvm_shutdown_obj shutdown;
  cl::ParseCommandLineOptions(argc, argv);

  // Construct an IR file from the filename passed on the command line.
  LLVMContext &context = getGlobalContext();
  SMDiagnostic err;
  unique_ptr<Module> module = parseIRFile(inPath.getValue(), err, context);

  if (!module.get()) {
    errs() << "Error reading bitcode file.\n";
    err.print(argv[0], errs());
    return -1;
  }

  // Build up all of the passes that we want to run on the module.
  PassManager pm;
  pm.add(new callgraphs::CallGraphPass);
  pm.add(new callgraphs::WeightedCallGraphPass);
  pm.add(new CallGraphPrinter<callgraphs::WeightedCallGraphPass>(outs()));
  pm.run(*module);

  return 0;
}
开发者ID:nsumner,项目名称:callgrapher-template,代码行数:30,代码来源:main.cpp


示例5: main

int main(int argc, char **argv, char * const *envp) {
  sys::PrintStackTraceOnErrorSignal();
  PrettyStackTraceProgram X(argc, argv);

  LLVMContext &Context = getGlobalContext();
  atexit(llvm_shutdown);  

  // If we have a native target, initialize it to ensure it is linked in and
  // usable by the JIT.
  InitializeNativeTarget();
  InitializeNativeTargetAsmPrinter();
  InitializeNativeTargetAsmParser();

  cl::ParseCommandLineOptions(argc, argv,
                              "llvm interpreter & dynamic compiler\n");

  // Load the bitcode...
  SMDiagnostic Err;
  std::unique_ptr<Module> Owner = parseIRFile(InputFile, Err, Context);
  Module *Mod = Owner.get();
  if (!Mod) {
    Err.print(argv[0], errs());
    return 1;
  }

  //Mod->dump();
  return runOrcLazyJIT(std::move(Owner), argc, argv);
  //return 0;
}
开发者ID:seanogden,项目名称:multi-jit,代码行数:29,代码来源:main.cpp


示例6: main

int main(int argc, char **argv) {
  LLVMContext &Context = getGlobalContext();
  SMDiagnostic Err;
  cl::ParseCommandLineOptions(argc, argv, "LLVM module splitter\n");

  std::unique_ptr<Module> M = parseIRFile(InputFilename, Err, Context);

  if (!M) {
    Err.print(argv[0], errs());
    return 1;
  }

  unsigned I = 0;
  SplitModule(std::move(M), NumOutputs, [&](std::unique_ptr<Module> MPart) {
    std::error_code EC;
    std::unique_ptr<tool_output_file> Out(new tool_output_file(
        OutputFilename + utostr(I++), EC, sys::fs::F_None));
    if (EC) {
      errs() << EC.message() << '\n';
      exit(1);
    }

    verifyModule(*MPart);
    WriteBitcodeToFile(MPart.get(), Out->os());

    // Declare success.
    Out->keep();
  }, PreserveLocals);

  return 0;
}
开发者ID:AlexDenisov,项目名称:llvm,代码行数:31,代码来源:llvm-split.cpp


示例7: main

int main(int argc, char **argv) {
  InitLLVM X(argc, argv);
  LLVMContext Context;
  cl::ParseCommandLineOptions(argc, argv, "llvm .ll -> .bc assembler\n");

  // Parse the file now...
  SMDiagnostic Err;
  std::unique_ptr<Module> M = parseAssemblyFile(
      InputFilename, Err, Context, nullptr, !DisableVerify, ClDataLayout);
  if (!M.get()) {
    Err.print(argv[0], errs());
    return 1;
  }

  if (!DisableVerify) {
    std::string ErrorStr;
    raw_string_ostream OS(ErrorStr);
    if (verifyModule(*M.get(), &OS)) {
      errs() << argv[0]
             << ": assembly parsed, but does not verify as correct!\n";
      errs() << OS.str();
      return 1;
    }
  }

  if (DumpAsm)
    errs() << "Here's the assembly:\n" << *M.get();

  if (!DisableOutput)
    WriteOutputFile(M.get());

  return 0;
}
开发者ID:crabtw,项目名称:llvm,代码行数:33,代码来源:llvm-as.cpp


示例8: JIT

  IR JIT(IR code)
  {
    SMDiagnostic errors;
    string parser_errors;
    ParseAssemblyString(code.assembly.c_str(),master.Program,errors,Context);
	if(master.debug)
	{
	  cerr << "Code:\n" << code.assembly << endl;
	}
    llvm::Function* entryfn = master.Engine->FindFunctionNamed("entry");
    if(entryfn == NULL)
      nerror("ERROR: Couldn't find program entry point.");
    if(!errors.getMessage().empty())
    {
      entryfn->eraseFromParent();
      nerror("IR Parsed with errors: ",errors.getMessage(),"\nCode: \n",code.assembly);
    }
    if(verifyModule(*master.Program,ReturnStatusAction,&parser_errors))
    {
      entryfn->eraseFromParent();
      nerror("IR Parser Error: ",parser_errors);
    }
    master.Passes.run(*master.Program);
	if(master.debug)
	{
	  cerr << "\nIR:" << endl;
	  master.Program->dump();
	}
    return code;
  }
开发者ID:Arcterus,项目名称:Hylas-Lisp,代码行数:30,代码来源:hylas.cpp


示例9: Buffer

/// ParseInputFile - Given a bitcode or assembly input filename, parse and
/// return it, or return null if not possible.
///
Module *llvm::ParseInputFile(const std::string &Filename,
                             LLVMContext& Ctxt) {
  std::auto_ptr<MemoryBuffer> Buffer(MemoryBuffer::getFileOrSTDIN(Filename));
  Module *Result = 0;
  if (Buffer.get())
    Result = ParseBitcodeFile(Buffer.get(), Ctxt);
  
  SMDiagnostic Err;
  if (!Result && !(Result = ParseAssemblyFile(Filename, Err, Ctxt))) {
    Err.Print("bugpoint", errs()); 
    Result = 0;
  }
  
  // If we don't have an override triple, use the first one to configure
  // bugpoint, or use the host triple if none provided.
  if (Result) {
    if (TargetTriple.getTriple().empty()) {
      Triple TheTriple(Result->getTargetTriple());

      if (TheTriple.getTriple().empty())
        TheTriple.setTriple(sys::getHostTriple());
        
      TargetTriple.setTriple(TheTriple.getTriple());
    }

    Result->setTargetTriple(TargetTriple.getTriple());  // override the triple
  }
  return Result;
}
开发者ID:Killfrra,项目名称:llvm-kernel,代码行数:32,代码来源:BugDriver.cpp


示例10: TheTriple

std::unique_ptr<Module> llvm::parseInputFile(StringRef Filename,
                                             LLVMContext &Ctxt) {
  SMDiagnostic Err;
  std::unique_ptr<Module> Result = parseIRFile(Filename, Err, Ctxt);
  if (!Result) {
    Err.print("bugpoint", errs());
    return Result;
  }

  if (verifyModule(*Result, &errs())) {
    errs() << "bugpoint: " << Filename << ": error: input module is broken!\n";
    return std::unique_ptr<Module>();
  }

  // If we don't have an override triple, use the first one to configure
  // bugpoint, or use the host triple if none provided.
  if (TargetTriple.getTriple().empty()) {
    Triple TheTriple(Result->getTargetTriple());

    if (TheTriple.getTriple().empty())
      TheTriple.setTriple(sys::getDefaultTargetTriple());

    TargetTriple.setTriple(TheTriple.getTriple());
  }

  Result->setTargetTriple(TargetTriple.getTriple()); // override the triple
  return Result;
}
开发者ID:BNieuwenhuizen,项目名称:llvm,代码行数:28,代码来源:BugDriver.cpp


示例11: mainFunction

CodeGenContext::CodeGenContext():
  mainFunction(0),
  builder(getGlobalContext())
{
  module = new Module("main", getGlobalContext());
  linker=new llvm::Linker("phc", module);

  char * externLibDir=getenv(PHC_ROOT_ENV);
  if(externLibDir==0){
    std::cout<<"Need Enviroment Variable "<<PHC_ROOT_ENV<<"\n";
    return;
  }
  std::cout << "Parse print function\n";
  SMDiagnostic Err;
  std::string dir(externLibDir, strlen(externLibDir));
  std::string filename("/extern/print.s");
  filename = dir + filename;
  libs = llvm::ParseIRFile(filename.c_str(), Err, getGlobalContext());
  std::cout << "Status: " << Err.getMessage() << "\n";
  if (libs == 0) {
    std::cout << "Error: cannot parse module " << filename << "\n";
    return;
  }

  std::cout << "Link print function\n";
  std::string errorMsg;
  linker->LinkModules(module, libs, llvm::Linker::DestroySource, &errorMsg);
  std::cout << "Status: " << errorMsg << "\n";

}
开发者ID:desaic,项目名称:PhysLang,代码行数:30,代码来源:codegen.cpp


示例12: main

int main(int argc, char **argv)
{
  using namespace llvm;

  std::cout << "hello_world_ir: " << std::endl;
  std::cout << std::endl;
  std::cout << hello_world_ir << std::endl;
  std::cout << std::endl;

  InitializeNativeTarget();

  LLVMContext context;
  SMDiagnostic error;

  Module *m = ParseIR(MemoryBuffer::getMemBuffer(StringRef(hello_world_ir)), error, context);
  if(!m)
  {
    error.print(argv[0], errs());
  }

  ExecutionEngine *ee = ExecutionEngine::create(m);

  Function *func = ee->FindFunctionNamed("hello_world");

  typedef void (*fcn_ptr)();
  fcn_ptr hello_world = reinterpret_cast<fcn_ptr>(ee->getPointerToFunction(func));
  hello_world();
  delete ee;

  return 0;
}
开发者ID:jaredhoberock,项目名称:llvm,代码行数:31,代码来源:ir_jit_hello_world.cpp


示例13: main

int main(int argc, char **argv) {
  LLVMContext &Context = getGlobalContext();
  SMDiagnostic Err;
  cl::ParseCommandLineOptions(argc, argv, "PNaCl Bitcode ABI checker\n");

  OwningPtr<Module> Mod(
      NaClParseIRFile(InputFilename, InputFileFormat, Err, Context));
  if (Mod.get() == 0) {
    Err.print(argv[0], errs());
    return 1;
  }
  PNaClABIErrorReporter ABIErrorReporter;
  ABIErrorReporter.setNonFatal();
  bool ErrorsFound = false;

  OwningPtr<ModulePass> ModuleChecker(
      createPNaClABIVerifyModulePass(&ABIErrorReporter));
  ModuleChecker->doInitialization(*Mod);
  ModuleChecker->runOnModule(*Mod);
  ErrorsFound |= CheckABIVerifyErrors(ABIErrorReporter, "Module");

  OwningPtr<FunctionPassManager> PM(new FunctionPassManager(&*Mod));
  PM->add(new DataLayout(&*Mod));
  PM->add(createPNaClABIVerifyFunctionsPass(&ABIErrorReporter));

  PM->doInitialization();
  for (Module::iterator I = Mod->begin(), E = Mod->end(); I != E; ++I) {
    PM->run(*I);
    ErrorsFound |=
        CheckABIVerifyErrors(ABIErrorReporter, "Function " + I->getName());
  }
  PM->doFinalization();

  return ErrorsFound ? 1 : 0;
}
开发者ID:davidbrazdil,项目名称:minsfi-llvm,代码行数:35,代码来源:pnacl-abicheck.cpp


示例14: main

int main(int argc, char *argv[])
{
  // Parse command line arguments
  cl::ParseCommandLineOptions(argc, argv, "SPIR Encoder");

  // Load bitcode module from file
  SMDiagnostic ErrInfo;
  LLVMContext& Context = getGlobalContext();
  Module *Input = ParseIRFile(InputFilename, ErrInfo, Context);
  if (!Input)
  {
    raw_os_ostream StdErr(cerr);
    ErrInfo.print(argv[0], StdErr);
    return 1;
  }

  // Open output file
  string ErrStr;
  raw_fd_ostream Output(OutputFilename.c_str(), ErrStr, sys::fs::F_None);
  if (!ErrStr.empty())
  {
    cerr << ErrStr << endl;
    return 1;
  }

  // Output re-encoded module
  SPIR::WriteBitcodeToFile_SPIR(Input, Output);

  return 0;
}
开发者ID:KhronosGroup,项目名称:SPIR-Tools,代码行数:30,代码来源:SpirEncoder.cpp


示例15: srcMgrDiagHandler

/// srcMgrDiagHandler - This callback is invoked when the SourceMgr for an
/// inline asm has an error in it.  diagInfo is a pointer to the SrcMgrDiagInfo
/// struct above.
static void srcMgrDiagHandler(const SMDiagnostic &Diag, void *diagInfo) {
  AsmPrinter::SrcMgrDiagInfo *DiagInfo =
      static_cast<AsmPrinter::SrcMgrDiagInfo *>(diagInfo);
  assert(DiagInfo && "Diagnostic context not passed down?");

  // Look up a LocInfo for the buffer this diagnostic is coming from.
  unsigned BufNum = DiagInfo->SrcMgr.FindBufferContainingLoc(Diag.getLoc());
  const MDNode *LocInfo = nullptr;
  if (BufNum > 0 && BufNum <= DiagInfo->LocInfos.size())
    LocInfo = DiagInfo->LocInfos[BufNum-1];

  // If the inline asm had metadata associated with it, pull out a location
  // cookie corresponding to which line the error occurred on.
  unsigned LocCookie = 0;
  if (LocInfo) {
    unsigned ErrorLine = Diag.getLineNo()-1;
    if (ErrorLine >= LocInfo->getNumOperands())
      ErrorLine = 0;

    if (LocInfo->getNumOperands() != 0)
      if (const ConstantInt *CI =
              mdconst::dyn_extract<ConstantInt>(LocInfo->getOperand(ErrorLine)))
        LocCookie = CI->getZExtValue();
  }

  DiagInfo->DiagHandler(Diag, DiagInfo->DiagContext, LocCookie);
}
开发者ID:jbush001,项目名称:NyuziToolchain,代码行数:30,代码来源:AsmPrinterInlineAsm.cpp


示例16: ParseIRFile

/// Reads a module from a file.  On error, messages are written to stderr
/// and null is returned.
static Module *ReadModule(LLVMContext &Context, StringRef Name) {
  SMDiagnostic Diag;
  Module *M = ParseIRFile(Name, Diag, Context);
  if (!M)
    Diag.Print("llvmdiff", errs());
  return M;
}
开发者ID:5432935,项目名称:crossbridge,代码行数:9,代码来源:llvm-diff.cpp


示例17: DEBUG

std::unique_ptr<Module> TempFile::readAssembly(LLVMContext &Context) const {
    DEBUG(dbgs() << " - read assembly\n");
    SMDiagnostic Err;
    std::unique_ptr<Module> M = parseAssemblyFile(Filename, Err, Context);
    if (!M.get())
        Err.print("verify-uselistorder", errs());
    return M;
}
开发者ID:shepmaster,项目名称:llvm,代码行数:8,代码来源:verify-uselistorder.cpp


示例18: readModule

/// Reads a module from a file.  On error, messages are written to stderr
/// and null is returned.
static std::unique_ptr<Module> readModule(LLVMContext &Context,
        StringRef Name) {
    SMDiagnostic Diag;
    std::unique_ptr<Module> M = parseIRFile(Name, Diag, Context);
    if (!M)
        Diag.print("llvm-diff", errs());
    return M;
}
开发者ID:cyrilmagsuci,项目名称:freebsd,代码行数:10,代码来源:llvm-diff.cpp


示例19: ParseIRFile

Module *LoadModule(StringRef Filename, LLVMContext& Context) {
  SMDiagnostic Err;
  Module *M = ParseIRFile(Filename, Err, Context);

  if (M == nullptr) {
    Err.print(Argv0, errs());
  }
  return M;
}
开发者ID:dansanduleac,项目名称:assertions,代码行数:9,代码来源:main.cpp


示例20: LLVMRustParseAssemblyFile

extern "C" LLVMModuleRef LLVMRustParseAssemblyFile(const char *Filename) {
  SMDiagnostic d;
  Module *m = ParseAssemblyFile(Filename, d, getGlobalContext());
  if (m) {
    return wrap(m);
  } else {
    LLVMRustError = d.getMessage().str().c_str();
    return NULL;
  }
}
开发者ID:1100110,项目名称:rust,代码行数:10,代码来源:RustWrapper.cpp



注:本文中的SMDiagnostic类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ SMESHDS_Mesh类代码示例发布时间:2022-05-31
下一篇:
C++ SMDS_NodeIteratorPtr类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap