summaryrefslogtreecommitdiffstats
path: root/lib/Frontend/SerializedDiagnosticPrinter.cpp
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2014-03-03 18:29:52 +0000
committerJordan Rose <jordan_rose@apple.com>2014-03-03 18:29:52 +0000
commit4c271d41690f16f970d4c88abd70729c3c1d6fb6 (patch)
treeffd361f230f3366ab13698e7eabb7d1fdf1c47aa /lib/Frontend/SerializedDiagnosticPrinter.cpp
parent7a9b46c6c7524cc381adbdeaac7f33c928239043 (diff)
Serialized diagnostic severity levels should be stable.
Serialized diagnostics were accidentally using the AST diagnostic level values rather than a dedicated stable enum, so the addition of "remark" broke the reading of existing serialized diagnostics files. I've added a .dia file generated from Xcode 5's Clang to make sure we don't break this in the future. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@202733 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/SerializedDiagnosticPrinter.cpp')
-rw-r--r--lib/Frontend/SerializedDiagnosticPrinter.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/Frontend/SerializedDiagnosticPrinter.cpp b/lib/Frontend/SerializedDiagnosticPrinter.cpp
index 6514321f22..bed52b5361 100644
--- a/lib/Frontend/SerializedDiagnosticPrinter.cpp
+++ b/lib/Frontend/SerializedDiagnosticPrinter.cpp
@@ -174,7 +174,7 @@ private:
const SourceManager &SM);
/// \brief The version of the diagnostics file.
- enum { Version = 1 };
+ enum { Version = 2 };
/// \brief Language options, which can differ from one clone of this client
/// to another.
@@ -566,6 +566,21 @@ void SDiagsWriter::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel,
&Info);
}
+static serialized_diags::Level getStableLevel(DiagnosticsEngine::Level Level) {
+ switch (Level) {
+#define CASE(X) case DiagnosticsEngine::X: return serialized_diags::X;
+ CASE(Ignored)
+ CASE(Note)
+ CASE(Remark)
+ CASE(Warning)
+ CASE(Error)
+ CASE(Fatal)
+#undef CASE
+ }
+
+ llvm_unreachable("invalid diagnostic level");
+}
+
void SDiagsWriter::EmitDiagnosticMessage(SourceLocation Loc,
PresumedLoc PLoc,
DiagnosticsEngine::Level Level,
@@ -579,7 +594,7 @@ void SDiagsWriter::EmitDiagnosticMessage(SourceLocation Loc,
// Emit the RECORD_DIAG record.
Record.clear();
Record.push_back(RECORD_DIAG);
- Record.push_back(Level);
+ Record.push_back(getStableLevel(Level));
AddLocToRecord(Loc, SM, PLoc, Record);
if (const Diagnostic *Info = D.dyn_cast<const Diagnostic*>()) {