summaryrefslogtreecommitdiffstats
path: root/tools/libclang/CXLoadedDiagnostic.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 /tools/libclang/CXLoadedDiagnostic.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 'tools/libclang/CXLoadedDiagnostic.cpp')
-rw-r--r--tools/libclang/CXLoadedDiagnostic.cpp22
1 files changed, 14 insertions, 8 deletions
diff --git a/tools/libclang/CXLoadedDiagnostic.cpp b/tools/libclang/CXLoadedDiagnostic.cpp
index e82ff95da1..86db08b123 100644
--- a/tools/libclang/CXLoadedDiagnostic.cpp
+++ b/tools/libclang/CXLoadedDiagnostic.cpp
@@ -67,13 +67,19 @@ CXLoadedDiagnostic::~CXLoadedDiagnostic() {}
//===----------------------------------------------------------------------===//
CXDiagnosticSeverity CXLoadedDiagnostic::getSeverity() const {
- // FIXME: possibly refactor with logic in CXStoredDiagnostic.
- switch (severity) {
- case DiagnosticsEngine::Ignored: return CXDiagnostic_Ignored;
- case DiagnosticsEngine::Note: return CXDiagnostic_Note;
- case DiagnosticsEngine::Warning: return CXDiagnostic_Warning;
- case DiagnosticsEngine::Error: return CXDiagnostic_Error;
- case DiagnosticsEngine::Fatal: return CXDiagnostic_Fatal;
+ // FIXME: Fail more softly if the diagnostic level is unknown?
+ assert(severity == static_cast<serialized_diags::Level>(severity) &&
+ "unknown serialized diagnostic level");
+
+ switch (static_cast<serialized_diags::Level>(severity)) {
+#define CASE(X) case serialized_diags::X: return CXDiagnostic_##X;
+ CASE(Ignored)
+ CASE(Note)
+ CASE(Warning)
+ CASE(Error)
+ CASE(Fatal)
+ CASE(Remark)
+#undef CASE
}
llvm_unreachable("Invalid diagnostic level");
@@ -175,7 +181,7 @@ void CXLoadedDiagnostic::decodeLocation(CXSourceLocation location,
// Deserialize diagnostics.
//===----------------------------------------------------------------------===//
-enum { MaxSupportedVersion = 1 };
+enum { MaxSupportedVersion = 2 };
typedef SmallVector<uint64_t, 64> RecordData;
enum LoadResult { Failure = 1, Success = 0 };
enum StreamResult { Read_EndOfStream,