コード例 #1
0
ファイル: CodeGenAction.cpp プロジェクト: oyeniyi-wale/clang
void BackendConsumer::OptimizationRemarkHandler(
    const llvm::DiagnosticInfoOptimizationRemark &D) {
  // Optimization remarks are active only if the -Rpass flag has a regular
  // expression that matches the name of the pass name in \p D.
  if (CodeGenOpts.OptimizationRemarkPattern &&
      CodeGenOpts.OptimizationRemarkPattern->match(D.getPassName()))
    EmitOptimizationMessage(D, diag::remark_fe_backend_optimization_remark);
}
コード例 #2
0
ファイル: CodeGenAction.cpp プロジェクト: ujhpc/clang
void BackendConsumer::OptimizationRemarkHandler(
    const llvm::DiagnosticInfoOptimizationRemark &D) {
  // We only support remarks.
  assert(D.getSeverity() == llvm::DS_Remark);

  // Optimization remarks are active only if -Rpass=regexp is given and the
  // regular expression pattern in 'regexp' matches the name of the pass
  // name in \p D.
  if (CodeGenOpts.OptimizationRemarkPattern &&
      CodeGenOpts.OptimizationRemarkPattern->match(D.getPassName())) {
    SourceManager &SourceMgr = Context->getSourceManager();
    FileManager &FileMgr = SourceMgr.getFileManager();
    StringRef Filename;
    unsigned Line, Column;
    D.getLocation(&Filename, &Line, &Column);
    SourceLocation Loc;
    const FileEntry *FE = FileMgr.getFile(Filename);
    if (FE && Line > 0) {
      // If -gcolumn-info was not used, Column will be 0. This upsets the
      // source manager, so if Column is not set, set it to 1.
      if (Column == 0)
        Column = 1;
      Loc = SourceMgr.translateFileLineCol(FE, Line, Column);
    }
    Diags.Report(Loc, diag::remark_fe_backend_optimization_remark)
        << AddFlagValue(D.getPassName()) << D.getMsg().str();

    if (Line == 0)
      // If we could not extract a source location for the diagnostic,
      // inform the user how they can get source locations back.
      //
      // FIXME: We should really be generating !srcloc annotations when
      // -Rpass is used. !srcloc annotations need to be emitted in
      // approximately the same spots as !dbg nodes.
      Diags.Report(diag::note_fe_backend_optimization_remark_missing_loc);
    else if (Loc.isInvalid())
      // If we were not able to translate the file:line:col information
      // back to a SourceLocation, at least emit a note stating that
      // we could not translate this location. This can happen in the
      // case of #line directives.
      Diags.Report(diag::note_fe_backend_optimization_remark_invalid_loc)
        << Filename << Line << Column;
  }
}