#include "clang/Frontend/ChainedDiagnosticClient.h"
#include "clang/Frontend/PCHReader.h"
#include "clang/Frontend/FrontendDiagnostic.h"
-#include "clang/Frontend/TextDiagnosticBuffer.h"
#include "clang/Frontend/TextDiagnosticPrinter.h"
+#include "clang/Frontend/VerifyDiagnosticsClient.h"
#include "clang/Frontend/Utils.h"
#include "clang/Sema/CodeCompleteConsumer.h"
#include "llvm/LLVMContext.h"
int Argc, char **Argv) {
// Create the diagnostic client for reporting errors or for
// implementing -verify.
- llvm::OwningPtr<DiagnosticClient> DiagClient;
- if (Opts.VerifyDiagnostics) {
- // When checking diagnostics, just buffer them up.
- DiagClient.reset(new TextDiagnosticBuffer());
- } else {
- DiagClient.reset(new TextDiagnosticPrinter(llvm::errs(), Opts));
- }
+ llvm::OwningPtr<DiagnosticClient> DiagClient(
+ new TextDiagnosticPrinter(llvm::errs(), Opts));
+
+ // Chain in -verify checker, if requested.
+ if (Opts.VerifyDiagnostics)
+ DiagClient.reset(new VerifyDiagnosticsClient(DiagClient.take()));
if (!Opts.DumpBuildInformation.empty())
SetUpBuildDumpLog(Opts, Argc, Argv, DiagClient);
#include "clang/Frontend/PreprocessorOptions.h"
#include "clang/Frontend/PreprocessorOutputOptions.h"
#include "clang/Frontend/Utils.h"
+#include "clang/Frontend/VerifyDiagnosticsClient.h"
#include "clang/Lex/HeaderSearch.h"
#include "clang/Lex/LexDiagnostic.h"
#include "clang/Parse/Parser.h"
CI.setASTContext(0);
}
- if (CI.getDiagnosticOpts().VerifyDiagnostics)
- if (CheckDiagnostics(PP))
- exit(1);
-
if (FEOpts.ShowStats) {
fprintf(stderr, "\nSTATISTICS FOR '%s':\n", InFile.c_str());
PP.PrintStats();
if (Clang.getFrontendOpts().ShowTimers)
ClangFrontendTimer = new llvm::Timer("Clang front-end time");
- if (Clang.getDiagnosticOpts().VerifyDiagnostics &&
- Clang.getFrontendOpts().Inputs.size() > 1) {
- fprintf(stderr, "-verify only works on single input files.\n");
- return 1;
- }
-
// C++ visualization?
if (!Clang.getFrontendOpts().ViewClassInheritance.empty())
ProgAction = InheritanceView;
delete ClangFrontendTimer;
- // If verifying diagnostics and we reached here, all is well.
+ // Return the appropriate status when verifying diagnostics.
+ //
+ // FIXME: If we could make getNumErrors() do the right thing, we wouldn't need
+ // this.
if (Clang.getDiagnosticOpts().VerifyDiagnostics)
- return 0;
+ return static_cast<VerifyDiagnosticsClient&>(
+ Clang.getDiagnosticClient()).HadErrors();
// Managed static deconstruction. Useful for making things like
// -time-passes usable.