aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-11-14 03:24:39 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-11-14 03:24:39 +0000
commitf79dced038c63572965c016b969cfa870670d16e (patch)
treecc36cdef25ae39796f6544ee4a6bf6cfa6892b28
parentba69b3c1050447db3c91a41ff25ce8cd29d9b021 (diff)
Switch -verify implementation to use VerifyDiagnosticClient.
- Not tested, but -verify with multiple inputs should work now. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@88750 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Frontend/CompilerInstance.cpp15
-rw-r--r--tools/clang-cc/clang-cc.cpp19
2 files changed, 14 insertions, 20 deletions
diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp
index 0352c45460..2877c63a4e 100644
--- a/lib/Frontend/CompilerInstance.cpp
+++ b/lib/Frontend/CompilerInstance.cpp
@@ -20,8 +20,8 @@
#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"
@@ -114,13 +114,12 @@ Diagnostic *CompilerInstance::createDiagnostics(const DiagnosticOptions &Opts,
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);
diff --git a/tools/clang-cc/clang-cc.cpp b/tools/clang-cc/clang-cc.cpp
index 6ae474289a..c153ef5246 100644
--- a/tools/clang-cc/clang-cc.cpp
+++ b/tools/clang-cc/clang-cc.cpp
@@ -37,6 +37,7 @@
#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"
@@ -532,10 +533,6 @@ static void ProcessInputFile(CompilerInstance &CI, const std::string &InFile,
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();
@@ -734,12 +731,6 @@ int main(int argc, char **argv) {
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;
@@ -785,9 +776,13 @@ int main(int argc, char **argv) {
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.