Example #1
0
void DiagnosticsEngine::Report(const StoredDiagnostic &storedDiag) {
    assert(CurDiagID == ~0U && "Multiple diagnostics in flight at once!");

    CurDiagLoc = storedDiag.getLocation();
    CurDiagID = storedDiag.getID();
    NumDiagArgs = 0;

    DiagRanges.clear();
    DiagRanges.reserve(storedDiag.range_size());
    for (StoredDiagnostic::range_iterator
            RI = storedDiag.range_begin(),
            RE = storedDiag.range_end(); RI != RE; ++RI)
        DiagRanges.push_back(*RI);

    DiagFixItHints.clear();
    DiagFixItHints.reserve(storedDiag.fixit_size());
    for (StoredDiagnostic::fixit_iterator
            FI = storedDiag.fixit_begin(),
            FE = storedDiag.fixit_end(); FI != FE; ++FI)
        DiagFixItHints.push_back(*FI);

    assert(Client && "DiagnosticConsumer not set!");
    Level DiagLevel = storedDiag.getLevel();
    Diagnostic Info(this, storedDiag.getMessage());
    Client->HandleDiagnostic(DiagLevel, Info);
    if (Client->IncludeInDiagnosticCounts()) {
        if (DiagLevel == DiagnosticsEngine::Warning)
            ++NumWarnings;
    }

    CurDiagID = ~0U;
}
Example #2
0
void Diagnostic::Report(const StoredDiagnostic &storedDiag) {
    assert(CurDiagID == ~0U && "Multiple diagnostics in flight at once!");

    CurDiagLoc = storedDiag.getLocation();
    CurDiagID = storedDiag.getID();
    NumDiagArgs = 0;

    NumDiagRanges = storedDiag.range_size();
    assert(NumDiagRanges < sizeof(DiagRanges)/sizeof(DiagRanges[0]) &&
           "Too many arguments to diagnostic!");
    unsigned i = 0;
    for (StoredDiagnostic::range_iterator
            RI = storedDiag.range_begin(),
            RE = storedDiag.range_end(); RI != RE; ++RI)
        DiagRanges[i++] = *RI;

    NumFixItHints = storedDiag.fixit_size();
    assert(NumFixItHints < Diagnostic::MaxFixItHints && "Too many fix-it hints!");
    i = 0;
    for (StoredDiagnostic::fixit_iterator
            FI = storedDiag.fixit_begin(),
            FE = storedDiag.fixit_end(); FI != FE; ++FI)
        FixItHints[i++] = *FI;

    assert(Client && "DiagnosticClient not set!");
    Level DiagLevel = storedDiag.getLevel();
    DiagnosticInfo Info(this, storedDiag.getMessage());
    Client->HandleDiagnostic(DiagLevel, Info);
    if (Client->IncludeInDiagnosticCounts()) {
        if (DiagLevel == Diagnostic::Warning)
            ++NumWarnings;
    }

    CurDiagID = ~0U;
}
Example #3
0
void DiagnosticRenderer::emitStoredDiagnostic(StoredDiagnostic &Diag) {
  emitDiagnostic(Diag.getLocation(), Diag.getLevel(), Diag.getMessage(),
                 Diag.getRanges(), Diag.getFixIts(),
                 Diag.getLocation().isValid() ? &Diag.getLocation().getManager()
                                              : 0,
                 &Diag);
}
Example #4
0
void DiagnosticsEngine::Report(const StoredDiagnostic &storedDiag) {
  assert(CurDiagID == ~0U && "Multiple diagnostics in flight at once!");

  CurDiagLoc = storedDiag.getLocation();
  CurDiagID = storedDiag.getID();
  NumDiagArgs = 0;

  DiagRanges.clear();
  DiagRanges.append(storedDiag.range_begin(), storedDiag.range_end());

  DiagFixItHints.clear();
  DiagFixItHints.append(storedDiag.fixit_begin(), storedDiag.fixit_end());

  assert(Client && "DiagnosticConsumer not set!");
  Level DiagLevel = storedDiag.getLevel();
  Diagnostic Info(this, storedDiag.getMessage());
  Client->HandleDiagnostic(DiagLevel, Info);
  if (Client->IncludeInDiagnosticCounts()) {
    if (DiagLevel == DiagnosticsEngine::Warning)
      ++NumWarnings;
  }

  CurDiagID = ~0U;
}
ASTUnit::StandaloneDiagnostic
TranslationUnitManager::MakeStandaloneDiagnostic(ASTUnit* tu,
                         const StoredDiagnostic &InDiag) {
  ASTUnit::StandaloneDiagnostic OutDiag;
  const LangOptions& LangOpts = tu->getASTContext().getLangOpts();
  OutDiag.ID = InDiag.getID();
  OutDiag.Level = InDiag.getLevel();
  OutDiag.Message = InDiag.getMessage();
  OutDiag.LocOffset = 0;
  if (InDiag.getLocation().isInvalid())
    return OutDiag;
  const SourceManager &SM = InDiag.getLocation().getManager();
  SourceLocation FileLoc = SM.getFileLoc(InDiag.getLocation());
  OutDiag.Filename = SM.getFilename(FileLoc);
  if (OutDiag.Filename.empty())
    return OutDiag;
  OutDiag.LocOffset = SM.getFileOffset(FileLoc);
  for (const CharSourceRange &Range : InDiag.getRanges())
    OutDiag.Ranges.push_back(makeStandaloneRange(Range, SM, LangOpts));
  for (const FixItHint &FixIt : InDiag.getFixIts())
    OutDiag.FixIts.push_back(makeStandaloneFixIt(SM, LangOpts, FixIt));

  return OutDiag;
}