aboutsummaryrefslogtreecommitdiff
path: root/lib/Frontend/SerializedDiagnosticPrinter.cpp
diff options
context:
space:
mode:
authorTed Kremenek <kremenek@apple.com>2011-11-05 00:09:47 +0000
committerTed Kremenek <kremenek@apple.com>2011-11-05 00:09:47 +0000
commit59b61613ed3b835f869b0f6fa1db52b8c963c5e5 (patch)
treefc3ce6ea1572a066fe1cd1b7ad58b0a65e236231 /lib/Frontend/SerializedDiagnosticPrinter.cpp
parent28eac520cf4f95e81cb8d85ff34b96d96046d50d (diff)
Serialized diagnostics: serialize "notes" as sub diagnostics of warnings and errors.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143758 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/SerializedDiagnosticPrinter.cpp')
-rw-r--r--lib/Frontend/SerializedDiagnosticPrinter.cpp31
1 files changed, 27 insertions, 4 deletions
diff --git a/lib/Frontend/SerializedDiagnosticPrinter.cpp b/lib/Frontend/SerializedDiagnosticPrinter.cpp
index fba085eeaa..e6d4a4f15a 100644
--- a/lib/Frontend/SerializedDiagnosticPrinter.cpp
+++ b/lib/Frontend/SerializedDiagnosticPrinter.cpp
@@ -61,7 +61,7 @@ typedef llvm::SmallVectorImpl<uint64_t> RecordDataImpl;
class SDiagsWriter : public DiagnosticConsumer {
public:
SDiagsWriter(DiagnosticsEngine &diags, llvm::raw_ostream *os)
- : Stream(Buffer), OS(os), Diags(diags)
+ : Stream(Buffer), OS(os), Diags(diags), inNonNoteDiagnostic(false)
{
EmitPreamble();
};
@@ -121,6 +121,10 @@ private:
/// \brief The collection of files used.
llvm::DenseSet<FileID> Files;
+ /// \brief Flag indicating whether or not we are in the process of
+ /// emitting a non-note diagnostic.
+ bool inNonNoteDiagnostic;
+
enum BlockIDs {
/// \brief The DIAG block, which acts as a container around a diagnostic.
BLOCK_DIAG = llvm::bitc::FIRST_APPLICATION_BLOCKID,
@@ -135,7 +139,6 @@ private:
RECORD_CATEGORY,
RECORD_FILENAME
};
-
};
} // end anonymous namespace
@@ -264,7 +267,16 @@ void SDiagsWriter::EmitRawStringContents(llvm::StringRef str) {
void SDiagsWriter::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
const Diagnostic &Info) {
- BlockEnterExit DiagBlock(Stream, BLOCK_DIAG);
+ if (DiagLevel != DiagnosticsEngine::Note) {
+ if (inNonNoteDiagnostic) {
+ // We have encountered a non-note diagnostic. Finish up the previous
+ // diagnostic block before starting a new one.
+ Stream.ExitBlock();
+ }
+ inNonNoteDiagnostic = true;
+ }
+
+ Stream.EnterSubblock(BLOCK_DIAG, 3);
// Emit the RECORD_DIAG record.
Record.clear();
@@ -290,8 +302,13 @@ void SDiagsWriter::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
// FIXME: emit location
// FIXME: emit ranges
- // FIXME: emit notes
// FIXME: emit fixits
+
+ if (DiagLevel == DiagnosticsEngine::Note) {
+ // Notes currently cannot have child diagnostics. Complete the
+ // diagnostic now.
+ Stream.ExitBlock();
+ }
}
template <typename T>
@@ -350,6 +367,12 @@ void SDiagsWriter::EmitCategoriesAndFileNames() {
}
void SDiagsWriter::EndSourceFile() {
+ if (inNonNoteDiagnostic) {
+ // Finish off any diagnostics we were in the process of emitting.
+ Stream.ExitBlock();
+ inNonNoteDiagnostic = false;
+ }
+
EmitCategoriesAndFileNames();
// Write the generated bitstream to "Out".