diff options
author | Douglas Gregor <dgregor@apple.com> | 2010-02-19 00:40:40 +0000 |
---|---|---|
committer | Douglas Gregor <dgregor@apple.com> | 2010-02-19 00:40:40 +0000 |
commit | 70127c1dcf66d1d01fd8423c1dc858e9baba714b (patch) | |
tree | a75265208011ab20203b6674cb55b76b112dd509 /clang/lib/Basic/Diagnostic.cpp | |
parent | d2d9252f35673f3a6c49ee302e8c735dea02eefe (diff) | |
download | bcm5719-llvm-70127c1dcf66d1d01fd8423c1dc858e9baba714b.tar.gz bcm5719-llvm-70127c1dcf66d1d01fd8423c1dc858e9baba714b.zip |
Use a little binary header in serialized diagnostics to help the deserializer skip over noise in the stream
llvm-svn: 96641
Diffstat (limited to 'clang/lib/Basic/Diagnostic.cpp')
-rw-r--r-- | clang/lib/Basic/Diagnostic.cpp | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp index c5c9ca7484e..f7ec873e4c1 100644 --- a/clang/lib/Basic/Diagnostic.cpp +++ b/clang/lib/Basic/Diagnostic.cpp @@ -978,6 +978,9 @@ void StoredDiagnostic::Serialize(llvm::raw_ostream &OS) const { 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 @@ static bool ReadSourceLocation(FileManager &FM, SourceManager &SM, 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) |