diff options
author | Ted Kremenek <kremenek@apple.com> | 2008-04-22 16:15:03 +0000 |
---|---|---|
committer | Ted Kremenek <kremenek@apple.com> | 2008-04-22 16:15:03 +0000 |
commit | 5585114307b6ba4874546212cb6e5399cfff7ffb (patch) | |
tree | 78ae330d04a81719d4b7b155fdb9d753f9f0f37f /Driver/HTMLDiagnostics.cpp | |
parent | 5fc073fe3be1830c4479253b59ccd45eb5614c55 (diff) |
PathDiagnosticClients now retain ownership of passed PathDiagnostics, requiring
them to not be stack-allocated.
HTMLDiagnostics now batches PathDiagnostics before emitting HTML in its dtor.
This is a workaround for a problem when we trampled the Preprocessor state
when highlighting macros (sometimes resulting in an assertion failure).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50102 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/HTMLDiagnostics.cpp')
-rw-r--r-- | Driver/HTMLDiagnostics.cpp | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/Driver/HTMLDiagnostics.cpp b/Driver/HTMLDiagnostics.cpp index 2f1b6e3676..c850c05a58 100644 --- a/Driver/HTMLDiagnostics.cpp +++ b/Driver/HTMLDiagnostics.cpp @@ -39,18 +39,21 @@ class VISIBILITY_HIDDEN HTMLDiagnostics : public PathDiagnosticClient { bool createdDir, noDir; Preprocessor* PP; PreprocessorFactory* PPF; + std::vector<const PathDiagnostic*> BatchedDiags; public: HTMLDiagnostics(const std::string& prefix, Preprocessor* pp, PreprocessorFactory* ppf); - virtual ~HTMLDiagnostics() {} + virtual ~HTMLDiagnostics(); - virtual void HandlePathDiagnostic(const PathDiagnostic& D); + virtual void HandlePathDiagnostic(const PathDiagnostic* D); void HandlePiece(Rewriter& R, const PathDiagnosticPiece& P, unsigned num, unsigned max); void HighlightRange(Rewriter& R, SourceRange Range); + + void ReportDiag(const PathDiagnostic& D); }; } // end anonymous namespace @@ -75,10 +78,29 @@ clang::CreateHTMLDiagnosticClient(const std::string& prefix, Preprocessor* PP, // Report processing. //===----------------------------------------------------------------------===// -void HTMLDiagnostics::HandlePathDiagnostic(const PathDiagnostic& D) { - - if (D.empty()) +void HTMLDiagnostics::HandlePathDiagnostic(const PathDiagnostic* D) { + if (!D) + return; + + if (D->empty()) { + delete D; return; + } + + BatchedDiags.push_back(D); +} + +HTMLDiagnostics::~HTMLDiagnostics() { + + while (!BatchedDiags.empty()) { + const PathDiagnostic* D = BatchedDiags.back(); + BatchedDiags.pop_back(); + ReportDiag(*D); + delete D; + } +} + +void HTMLDiagnostics::ReportDiag(const PathDiagnostic& D) { // Create the HTML directory if it is missing. @@ -127,7 +149,13 @@ void HTMLDiagnostics::HandlePathDiagnostic(const PathDiagnostic& D) { // for example. if (PP) html::SyntaxHighlight(R, FileID, *PP); - if (PPF) html::HighlightMacros(R, FileID, *PPF); + + // FIXME: We eventually want to use PPF to create a fresh Preprocessor, + // once we have worked out the bugs. + // + // if (PPF) html::HighlightMacros(R, FileID, *PPF); + // + if (PP) html::HighlightMacros(R, FileID, *PP); // Get the full directory name of the analyzed file. |