diff options
| author | Ted Kremenek <kremenek@apple.com> | 2008-03-27 06:17:42 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2008-03-27 06:17:42 +0000 |
| commit | 6efb0266238c6dd944e19002b4a8921abcb80c0a (patch) | |
| tree | 86c2ee46e8956c227e7a8c6e9fbaf0cfa55782c1 /clang/Driver/clang.cpp | |
| parent | 710714c365064fa4db37fdede433b6c82da9461d (diff) | |
| download | bcm5719-llvm-6efb0266238c6dd944e19002b4a8921abcb80c0a.tar.gz bcm5719-llvm-6efb0266238c6dd944e19002b4a8921abcb80c0a.zip | |
Added "HTMLDiagnostic", a generic DiagnosticClient (that also implements PathDiagnostic)
so that all diagnostics can be piped to HTML files instead of as text diagnostics using --html-diags.
llvm-svn: 48865
Diffstat (limited to 'clang/Driver/clang.cpp')
| -rw-r--r-- | clang/Driver/clang.cpp | 49 |
1 files changed, 33 insertions, 16 deletions
diff --git a/clang/Driver/clang.cpp b/clang/Driver/clang.cpp index 2e54dd94c1d..2bf99f8eafb 100644 --- a/clang/Driver/clang.cpp +++ b/clang/Driver/clang.cpp @@ -26,6 +26,8 @@ #include "ASTConsumers.h" #include "TextDiagnosticBuffer.h" #include "TextDiagnosticPrinter.h" +#include "HTMLDiagnostics.h" +#include "clang/Analysis/PathDiagnostic.h" #include "clang/AST/TranslationUnit.h" #include "clang/CodeGen/ModuleBuilder.h" #include "clang/Sema/ParseAST.h" @@ -138,6 +140,7 @@ ProgAction(llvm::cl::desc("Choose output type:"), llvm::cl::ZeroOrMore, "Playground for the code rewriter"), clEnumValN(HTMLTest, "html-test", "Playground for the HTML displayer"), + clEnumValEnd)); @@ -150,6 +153,11 @@ static llvm::cl::opt<bool> VerifyDiagnostics("verify", llvm::cl::desc("Verify emitted diagnostics and warnings.")); +static llvm::cl::opt<std::string> +HTMLDiag("html-diags", + llvm::cl::desc("Generate HTML to report diagnostics"), + llvm::cl::value_desc("HTML directory")); + //===----------------------------------------------------------------------===// // Language Options //===----------------------------------------------------------------------===// @@ -1058,8 +1066,7 @@ static ASTConsumer* CreateASTConsumer(const std::string& InFile, /// ProcessInputFile - Process a single input file with the specified state. /// -static void ProcessInputFile(Preprocessor &PP, const std::string &InFile, - TextDiagnostics &OurDiagnosticClient) { +static void ProcessInputFile(Preprocessor &PP, const std::string &InFile) { ASTConsumer* Consumer = NULL; bool ClearSourceMgr = false; @@ -1255,19 +1262,29 @@ int main(int argc, char **argv) { // Create the diagnostic client for reporting errors or for // implementing -verify. - std::auto_ptr<TextDiagnostics> DiagClient; - if (!VerifyDiagnostics) { - // Print diagnostics to stderr by default. - DiagClient.reset(new TextDiagnosticPrinter()); - } else { - // When checking diagnostics, just buffer them up. - DiagClient.reset(new TextDiagnosticBuffer()); - - if (InputFilenames.size() != 1) { - fprintf(stderr, - "-verify only works on single input files for now.\n"); - return 1; + std::auto_ptr<DiagnosticClient> DiagClient; + TextDiagnostics* TextDiagClient = NULL; + + if (!HTMLDiag.empty()) { + DiagClient.reset(CreateHTMLDiagnosticClient(HTMLDiag)); + } + else { // Use Text diagnostics. + if (!VerifyDiagnostics) { + // Print diagnostics to stderr by default. + TextDiagClient = new TextDiagnosticPrinter(); + } else { + // When checking diagnostics, just buffer them up. + TextDiagClient = new TextDiagnosticBuffer(); + + if (InputFilenames.size() != 1) { + fprintf(stderr, + "-verify only works on single input files for now.\n"); + return 1; + } } + + assert (TextDiagClient); + DiagClient.reset(TextDiagClient); } // Configure our handling of diagnostics. @@ -1312,7 +1329,7 @@ int main(int argc, char **argv) { // Process the -I options and set them in the HeaderInfo. HeaderSearch HeaderInfo(FileMgr); - DiagClient->setHeaderSearch(HeaderInfo); + if (TextDiagClient) TextDiagClient->setHeaderSearch(HeaderInfo); InitializeIncludePaths(argv[0], HeaderInfo, FileMgr, LangInfo); // Set up the preprocessor with these options. @@ -1322,7 +1339,7 @@ int main(int argc, char **argv) { if (!InitializePreprocessor(PP, InFile, PredefineBuffer)) continue; - ProcessInputFile(PP, InFile, *DiagClient); + ProcessInputFile(PP, InFile); HeaderInfo.ClearFileInfo(); if (Stats) |

