diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-11-18 20:06:46 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-11-18 20:06:46 +0000 |
commit | f2224d89a6ae65a3839529e26d0f6d025d83d6bb (patch) | |
tree | 31801a351dd849d50a1922a2326db3c828d96ffb /lib/Frontend | |
parent | 33e4e70c8c0a17e0ccb7465d96556b077a68ecb1 (diff) |
Since multiple diagnostics can share one diagnostic client, have the client keeping track
of the total number of warnings/errors reported.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@119731 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend')
-rw-r--r-- | lib/Frontend/ASTMerge.cpp | 9 | ||||
-rw-r--r-- | lib/Frontend/ASTUnit.cpp | 3 | ||||
-rw-r--r-- | lib/Frontend/CompilerInstance.cpp | 7 | ||||
-rw-r--r-- | lib/Frontend/TextDiagnosticBuffer.cpp | 3 | ||||
-rw-r--r-- | lib/Frontend/TextDiagnosticPrinter.cpp | 3 |
5 files changed, 13 insertions, 12 deletions
diff --git a/lib/Frontend/ASTMerge.cpp b/lib/Frontend/ASTMerge.cpp index 7c8763d09d..d4ed8d3e03 100644 --- a/lib/Frontend/ASTMerge.cpp +++ b/lib/Frontend/ASTMerge.cpp @@ -69,15 +69,6 @@ void ASTMergeAction::ExecuteAction() { Importer.Import(*D); } - // Aggregate the number of warnings/errors from all diagnostics so - // that at CompilerInstance::ExecuteAction we can report the total numbers. - // FIXME: This is hacky, maybe keep track of total number of warnings/errors - // in DiagnosticClient and have CompilerInstance query that ? - CI.getDiagnostics().setNumWarnings(CI.getDiagnostics().getNumWarnings() + - Diags->getNumWarnings()); - CI.getDiagnostics().setNumErrors(CI.getDiagnostics().getNumErrors() + - Diags->getNumErrors()); - delete Unit; } diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp index fb93fca84a..3956cc23e3 100644 --- a/lib/Frontend/ASTUnit.cpp +++ b/lib/Frontend/ASTUnit.cpp @@ -440,6 +440,9 @@ public: void StoredDiagnosticClient::HandleDiagnostic(Diagnostic::Level Level, const DiagnosticInfo &Info) { + // Default implementation (Warnings/errors count). + DiagnosticClient::HandleDiagnostic(Level, Info); + StoredDiags.push_back(StoredDiagnostic(Level, Info)); } diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp index dafbef1824..152dd6d5b6 100644 --- a/lib/Frontend/CompilerInstance.cpp +++ b/lib/Frontend/CompilerInstance.cpp @@ -553,9 +553,10 @@ bool CompilerInstance::ExecuteAction(FrontendAction &Act) { } if (getDiagnosticOpts().ShowCarets) { - unsigned NumWarnings = getDiagnostics().getNumWarnings(); - unsigned NumErrors = getDiagnostics().getNumErrors() - - getDiagnostics().getNumErrorsSuppressed(); + // We can have multiple diagnostics sharing one diagnostic client. + // Get the total number of warnings/errors from the client. + unsigned NumWarnings = getDiagnostics().getClient()->getNumWarnings(); + unsigned NumErrors = getDiagnostics().getClient()->getNumErrors(); if (NumWarnings) OS << NumWarnings << " warning" << (NumWarnings == 1 ? "" : "s"); diff --git a/lib/Frontend/TextDiagnosticBuffer.cpp b/lib/Frontend/TextDiagnosticBuffer.cpp index fdf2ec8ccf..069c86de13 100644 --- a/lib/Frontend/TextDiagnosticBuffer.cpp +++ b/lib/Frontend/TextDiagnosticBuffer.cpp @@ -20,6 +20,9 @@ using namespace clang; /// void TextDiagnosticBuffer::HandleDiagnostic(Diagnostic::Level Level, const DiagnosticInfo &Info) { + // Default implementation (Warnings/errors count). + DiagnosticClient::HandleDiagnostic(Level, Info); + llvm::SmallString<100> Buf; Info.FormatDiagnostic(Buf); switch (Level) { diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp index 2528777cd8..200054ab11 100644 --- a/lib/Frontend/TextDiagnosticPrinter.cpp +++ b/lib/Frontend/TextDiagnosticPrinter.cpp @@ -764,6 +764,9 @@ static bool PrintWordWrapped(llvm::raw_ostream &OS, void TextDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level, const DiagnosticInfo &Info) { + // Default implementation (Warnings/errors count). + DiagnosticClient::HandleDiagnostic(Level, Info); + // Keeps track of the the starting position of the location // information (e.g., "foo.c:10:4:") that precedes the error // message. We use this information to determine how long the |