summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-10-11 22:02:06 +0000
committerDouglas Gregor <dgregor@apple.com>2010-10-11 22:02:06 +0000
commit4e0f15a4a247abfcc53563815ce799d2ad45c786 (patch)
tree5a2f800be5b5e6ad6f7a679de3c14e28f425343e /clang/lib/Basic
parentd42340ecfdcd378f4e6c5f8968a7e5c194b10d6b (diff)
downloadbcm5719-llvm-4e0f15a4a247abfcc53563815ce799d2ad45c786.tar.gz
bcm5719-llvm-4e0f15a4a247abfcc53563815ce799d2ad45c786.zip
Eliminate -fdiagnostics-binary and all of the infrastructure for
emitting diagnostics in a binary form to be consumed by libclang, since libclang no longer does any of its work out-of-process, making this code dead. Besides, this stuff never worked at 100% anyway. llvm-svn: 116250
Diffstat (limited to 'clang/lib/Basic')
-rw-r--r--clang/lib/Basic/Diagnostic.cpp245
1 files changed, 0 insertions, 245 deletions
diff --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp
index d8095f4f6d5..6430b7ec1c8 100644
--- a/clang/lib/Basic/Diagnostic.cpp
+++ b/clang/lib/Basic/Diagnostic.cpp
@@ -1065,251 +1065,6 @@ StoredDiagnostic::StoredDiagnostic(Diagnostic::Level Level,
StoredDiagnostic::~StoredDiagnostic() { }
-static void WriteUnsigned(llvm::raw_ostream &OS, unsigned Value) {
- OS.write((const char *)&Value, sizeof(unsigned));
-}
-
-static void WriteString(llvm::raw_ostream &OS, llvm::StringRef String) {
- WriteUnsigned(OS, String.size());
- OS.write(String.data(), String.size());
-}
-
-static void WriteSourceLocation(llvm::raw_ostream &OS,
- SourceManager *SM,
- SourceLocation Location) {
- if (!SM || Location.isInvalid()) {
- // If we don't have a source manager or this location is invalid,
- // just write an invalid location.
- WriteUnsigned(OS, 0);
- WriteUnsigned(OS, 0);
- WriteUnsigned(OS, 0);
- return;
- }
-
- Location = SM->getInstantiationLoc(Location);
- std::pair<FileID, unsigned> Decomposed = SM->getDecomposedLoc(Location);
-
- const FileEntry *FE = SM->getFileEntryForID(Decomposed.first);
- if (FE)
- WriteString(OS, FE->getName());
- else {
- // Fallback to using the buffer name when there is no entry.
- WriteString(OS, SM->getBuffer(Decomposed.first)->getBufferIdentifier());
- }
-
- WriteUnsigned(OS, SM->getLineNumber(Decomposed.first, Decomposed.second));
- WriteUnsigned(OS, SM->getColumnNumber(Decomposed.first, Decomposed.second));
-}
-
-void StoredDiagnostic::Serialize(llvm::raw_ostream &OS) const {
- SourceManager *SM = 0;
- 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());
-
- // Write the diagnostic message.
- llvm::SmallString<64> Message;
- WriteString(OS, getMessage());
-
- // Count the number of ranges that don't point into macros, since
- // only simple file ranges serialize well.
- unsigned NumNonMacroRanges = 0;
- for (range_iterator R = range_begin(), REnd = range_end(); R != REnd; ++R) {
- if (R->getBegin().isMacroID() || R->getEnd().isMacroID())
- continue;
-
- ++NumNonMacroRanges;
- }
-
- // Write the ranges.
- WriteUnsigned(OS, NumNonMacroRanges);
- if (NumNonMacroRanges) {
- for (range_iterator R = range_begin(), REnd = range_end(); R != REnd; ++R) {
- if (R->getBegin().isMacroID() || R->getEnd().isMacroID())
- continue;
-
- WriteSourceLocation(OS, SM, R->getBegin());
- WriteSourceLocation(OS, SM, R->getEnd());
- WriteUnsigned(OS, R->isTokenRange());
- }
- }
-
- // Determine if all of the fix-its involve rewrites with simple file
- // locations (not in macro instantiations). If so, we can write
- // fix-it information.
- unsigned NumFixIts = 0;
- for (fixit_iterator F = fixit_begin(), FEnd = fixit_end(); F != FEnd; ++F) {
- if (F->RemoveRange.isValid() &&
- (F->RemoveRange.getBegin().isMacroID() ||
- F->RemoveRange.getEnd().isMacroID())) {
- NumFixIts = 0;
- break;
- }
-
- ++NumFixIts;
- }
-
- // Write the fix-its.
- WriteUnsigned(OS, NumFixIts);
- for (fixit_iterator F = fixit_begin(), FEnd = fixit_end(); F != FEnd; ++F) {
- WriteSourceLocation(OS, SM, F->RemoveRange.getBegin());
- WriteSourceLocation(OS, SM, F->RemoveRange.getEnd());
- WriteUnsigned(OS, F->RemoveRange.isTokenRange());
- WriteString(OS, F->CodeToInsert);
- }
-}
-
-static bool ReadUnsigned(const char *&Memory, const char *MemoryEnd,
- unsigned &Value) {
- if (Memory + sizeof(unsigned) > MemoryEnd)
- return true;
-
- memmove(&Value, Memory, sizeof(unsigned));
- Memory += sizeof(unsigned);
- return false;
-}
-
-static bool ReadSourceLocation(FileManager &FM, SourceManager &SM,
- const char *&Memory, const char *MemoryEnd,
- SourceLocation &Location) {
- // Read the filename.
- unsigned FileNameLen = 0;
- if (ReadUnsigned(Memory, MemoryEnd, FileNameLen) ||
- Memory + FileNameLen > MemoryEnd)
- return true;
-
- llvm::StringRef FileName(Memory, FileNameLen);
- Memory += FileNameLen;
-
- // Read the line, column.
- unsigned Line = 0, Column = 0;
- if (ReadUnsigned(Memory, MemoryEnd, Line) ||
- ReadUnsigned(Memory, MemoryEnd, Column))
- return true;
-
- if (FileName.empty()) {
- Location = SourceLocation();
- return false;
- }
-
- const FileEntry *File = FM.getFile(FileName);
- if (!File)
- return true;
-
- // Make sure that this file has an entry in the source manager.
- if (!SM.hasFileInfo(File))
- SM.createFileID(File, SourceLocation(), SrcMgr::C_User);
-
- Location = SM.getLocation(File, Line, Column);
- return false;
-}
-
-StoredDiagnostic
-StoredDiagnostic::Deserialize(FileManager &FM, SourceManager &SM,
- const char *&Memory, const char *MemoryEnd) {
- 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)
- return StoredDiagnostic();
-
- // Read the source location.
- SourceLocation Location;
- if (ReadSourceLocation(FM, SM, Memory, MemoryEnd, Location))
- return StoredDiagnostic();
-
- // Read the diagnostic text.
- if (Memory == MemoryEnd)
- return StoredDiagnostic();
-
- unsigned MessageLen = 0;
- if (ReadUnsigned(Memory, MemoryEnd, MessageLen) ||
- Memory + MessageLen > MemoryEnd)
- return StoredDiagnostic();
-
- llvm::StringRef Message(Memory, MessageLen);
- Memory += MessageLen;
-
-
- // At this point, we have enough information to form a diagnostic. Do so.
- StoredDiagnostic Diag;
- Diag.Level = (Diagnostic::Level)Level;
- Diag.Loc = FullSourceLoc(Location, SM);
- Diag.Message = Message;
- if (Memory == MemoryEnd)
- return Diag;
-
- // Read the source ranges.
- unsigned NumSourceRanges = 0;
- if (ReadUnsigned(Memory, MemoryEnd, NumSourceRanges))
- return Diag;
- for (unsigned I = 0; I != NumSourceRanges; ++I) {
- SourceLocation Begin, End;
- unsigned IsTokenRange;
- if (ReadSourceLocation(FM, SM, Memory, MemoryEnd, Begin) ||
- ReadSourceLocation(FM, SM, Memory, MemoryEnd, End) ||
- ReadUnsigned(Memory, MemoryEnd, IsTokenRange))
- return Diag;
-
- Diag.Ranges.push_back(CharSourceRange(SourceRange(Begin, End),
- IsTokenRange));
- }
-
- // Read the fix-it hints.
- unsigned NumFixIts = 0;
- if (ReadUnsigned(Memory, MemoryEnd, NumFixIts))
- return Diag;
- for (unsigned I = 0; I != NumFixIts; ++I) {
- SourceLocation RemoveBegin, RemoveEnd;
- unsigned InsertLen = 0, RemoveIsTokenRange;
- if (ReadSourceLocation(FM, SM, Memory, MemoryEnd, RemoveBegin) ||
- ReadSourceLocation(FM, SM, Memory, MemoryEnd, RemoveEnd) ||
- ReadUnsigned(Memory, MemoryEnd, RemoveIsTokenRange) ||
- ReadUnsigned(Memory, MemoryEnd, InsertLen) ||
- Memory + InsertLen > MemoryEnd) {
- Diag.FixIts.clear();
- return Diag;
- }
-
- FixItHint Hint;
- Hint.RemoveRange = CharSourceRange(SourceRange(RemoveBegin, RemoveEnd),
- RemoveIsTokenRange);
- Hint.CodeToInsert.assign(Memory, Memory + InsertLen);
- Memory += InsertLen;
- Diag.FixIts.push_back(Hint);
- }
-
- return Diag;
-}
-
/// IncludeInDiagnosticCounts - This method (whose default implementation
/// returns true) indicates whether the diagnostics handled by this
/// DiagnosticClient should be included in the number of diagnostics
OpenPOWER on IntegriCloud