[cfe-commits] r96641 - /cfe/trunk/lib/Basic/Diagnostic.cpp
Douglas Gregor
dgregor at apple.com
Thu Feb 18 16:40:40 PST 2010
Author: dgregor
Date: Thu Feb 18 18:40:40 2010
New Revision: 96641
URL: http://llvm.org/viewvc/llvm-project?rev=96641&view=rev
Log:
Use a little binary header in serialized diagnostics to help the deserializer skip over noise in the stream
Modified:
cfe/trunk/lib/Basic/Diagnostic.cpp
Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=96641&r1=96640&r2=96641&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Thu Feb 18 18:40:40 2010
@@ -978,6 +978,9 @@
if (getLocation().isValid())
SM = &const_cast<SourceManager &>(getLocation().getManager());
+ // Write a short header to help identify diagnostics.
+ OS << (char)0x06 << (char)0x07;
+
// Write the diagnostic level and location.
WriteUnsigned(OS, (unsigned)Level);
WriteSourceLocation(OS, SM, getLocation());
@@ -1086,9 +1089,29 @@
StoredDiagnostic
StoredDiagnostic::Deserialize(FileManager &FM, SourceManager &SM,
const char *&Memory, const char *MemoryEnd) {
- if (Memory == MemoryEnd)
- return StoredDiagnostic();
-
+ while (true) {
+ if (Memory == MemoryEnd)
+ return StoredDiagnostic();
+
+ if (*Memory != 0x06) {
+ ++Memory;
+ continue;
+ }
+
+ ++Memory;
+ if (Memory == MemoryEnd)
+ return StoredDiagnostic();
+
+ if (*Memory != 0x07) {
+ ++Memory;
+ continue;
+ }
+
+ // We found the header. We're done.
+ ++Memory;
+ break;
+ }
+
// Read the severity level.
unsigned Level = 0;
if (ReadUnsigned(Memory, MemoryEnd, Level) || Level > Diagnostic::Fatal)
More information about the cfe-commits
mailing list