aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Frontend/HTMLDiagnostics.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2009-07-27 22:13:39 +0000
committerTed Kremenek <kremenek@apple.com>2009-07-27 22:13:39 +0000
commit04ade6f1cb05d6ab893d6724a08a9108adabc6bb (patch)
treec651ba6169c66f8e13de45663514b65f4a932695 /clang/lib/Frontend/HTMLDiagnostics.cpp
parent5cc54863ce5f160c215597ec6da43d938885d48d (diff)
downloadllvm-04ade6f1cb05d6ab893d6724a08a9108adabc6bb.zip
llvm-04ade6f1cb05d6ab893d6724a08a9108adabc6bb.tar.gz
llvm-04ade6f1cb05d6ab893d6724a08a9108adabc6bb.tar.bz2
(1) Enable PlistDiagnostics to take an option "PathDiagnosticClientFactory"
object that it can use to forward PathDiagnostics for further processing. Along with this feature, the PlistDiagnostics object logs which files are created by the forwarding of the PathDiagnostics. (2) Create a new PathDiagnosticClientFactory object for HTMLDiagnostics, allowing other PathDiagnosticClients to forward PathDiagnostics through an opaque interface. (3) Create a "plist-html" diagnostics option in AnalysisConsumer to allow the logging of HTML files created in a hybrid Plist+HTML diagnostic client. llvm-svn: 77264
Diffstat (limited to 'clang/lib/Frontend/HTMLDiagnostics.cpp')
-rw-r--r--clang/lib/Frontend/HTMLDiagnostics.cpp56
1 files changed, 48 insertions, 8 deletions
diff --git a/clang/lib/Frontend/HTMLDiagnostics.cpp b/clang/lib/Frontend/HTMLDiagnostics.cpp
index 9cfe0b2..160da7c 100644
--- a/clang/lib/Frontend/HTMLDiagnostics.cpp
+++ b/clang/lib/Frontend/HTMLDiagnostics.cpp
@@ -39,9 +39,11 @@ class VISIBILITY_HIDDEN HTMLDiagnostics : public PathDiagnosticClient {
llvm::sys::Path Directory, FilePrefix;
bool createdDir, noDir;
Preprocessor* PP;
- std::vector<const PathDiagnostic*> BatchedDiags;
+ std::vector<const PathDiagnostic*> BatchedDiags;
+ llvm::SmallVectorImpl<std::string> *FilesMade;
public:
- HTMLDiagnostics(const std::string& prefix, Preprocessor* pp);
+ HTMLDiagnostics(const std::string& prefix, Preprocessor* pp,
+ llvm::SmallVectorImpl<std::string> *filesMade = 0);
virtual ~HTMLDiagnostics();
@@ -65,9 +67,10 @@ public:
} // end anonymous namespace
-HTMLDiagnostics::HTMLDiagnostics(const std::string& prefix, Preprocessor* pp)
+HTMLDiagnostics::HTMLDiagnostics(const std::string& prefix, Preprocessor* pp,
+ llvm::SmallVectorImpl<std::string>* filesMade)
: Directory(prefix), FilePrefix(prefix), createdDir(false), noDir(false),
- PP(pp) {
+ PP(pp), FilesMade(filesMade) {
// All html files begin with "report"
FilePrefix.appendComponent("report");
@@ -75,8 +78,43 @@ HTMLDiagnostics::HTMLDiagnostics(const std::string& prefix, Preprocessor* pp)
PathDiagnosticClient*
clang::CreateHTMLDiagnosticClient(const std::string& prefix, Preprocessor* PP,
- PreprocessorFactory*) {
- return new HTMLDiagnostics(prefix, PP);
+ PreprocessorFactory*,
+ llvm::SmallVectorImpl<std::string>* FilesMade)
+{
+ return new HTMLDiagnostics(prefix, PP, FilesMade);
+}
+
+//===----------------------------------------------------------------------===//
+// Factory for HTMLDiagnosticClients
+//===----------------------------------------------------------------------===//
+
+namespace {
+class VISIBILITY_HIDDEN HTMLDiagnosticsFactory
+ : public PathDiagnosticClientFactory {
+
+ std::string Prefix;
+ Preprocessor *PP;
+public:
+ HTMLDiagnosticsFactory(const std::string& prefix, Preprocessor* pp)
+ : Prefix(prefix), PP(pp) {}
+
+ virtual ~HTMLDiagnosticsFactory() {}
+
+ const char *getName() const { return "HTMLDiagnostics"; }
+
+ PathDiagnosticClient*
+ createPathDiagnosticClient(llvm::SmallVectorImpl<std::string> *FilesMade) {
+
+ return new HTMLDiagnostics(Prefix, PP, FilesMade);
+ }
+};
+} // end anonymous namespace
+
+PathDiagnosticClientFactory*
+clang::CreateHTMLDiagnosticClientFactory(const std::string& prefix,
+ Preprocessor* PP,
+ PreprocessorFactory*) {
+ return new HTMLDiagnosticsFactory(prefix, PP);
}
//===----------------------------------------------------------------------===//
@@ -317,12 +355,14 @@ void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D) {
llvm::cerr << "warning: could not create file '" << F.toString() << "'\n";
return;
}
+
+ if (FilesMade)
+ FilesMade->push_back(H.getLast());
}
// Emit the HTML to disk.
-
for (RewriteBuffer::iterator I = Buf->begin(), E = Buf->end(); I!=E; ++I)
- os << *I;
+ os << *I;
}
void HTMLDiagnostics::HandlePiece(Rewriter& R, FileID BugFileID,