[cfe-commits] r88750 - in /cfe/trunk: lib/Frontend/CompilerInstance.cpp tools/clang-cc/clang-cc.cpp
Daniel Dunbar
daniel at zuster.org
Fri Nov 13 19:24:39 PST 2009
Author: ddunbar
Date: Fri Nov 13 21:24:39 2009
New Revision: 88750
URL: http://llvm.org/viewvc/llvm-project?rev=88750&view=rev
Log:
Switch -verify implementation to use VerifyDiagnosticClient.
- Not tested, but -verify with multiple inputs should work now.
Modified:
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/tools/clang-cc/clang-cc.cpp
Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=88750&r1=88749&r2=88750&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Fri Nov 13 21:24:39 2009
@@ -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 @@
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);
Modified: cfe/trunk/tools/clang-cc/clang-cc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/clang-cc/clang-cc.cpp?rev=88750&r1=88749&r2=88750&view=diff
==============================================================================
--- cfe/trunk/tools/clang-cc/clang-cc.cpp (original)
+++ cfe/trunk/tools/clang-cc/clang-cc.cpp Fri Nov 13 21:24:39 2009
@@ -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 @@
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 @@
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 @@
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.
More information about the cfe-commits
mailing list