From 857953168467d789125a25b3c262d4140f16c01a Mon Sep 17 00:00:00 2001 From: Douglas Gregor Date: Mon, 22 Mar 2010 15:10:57 +0000 Subject: Introduce the notion of a single "delayed" diagnostic into the Diagnostic subsystem, which is used in the rare case where we find a serious problem (i.e., an inconsistency in the file system) while we're busy formatting another diagnostic. In this case, the delayed diagnostic will be emitted after we're done with the other diagnostic. This is only to be used for fatal conditions detected at very inconvenient times, where we can neither stop the current diagnostic in flight nor can we suppress the second error. llvm-svn: 99175 --- clang/lib/Basic/SourceManager.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'clang/lib/Basic/SourceManager.cpp') diff --git a/clang/lib/Basic/SourceManager.cpp b/clang/lib/Basic/SourceManager.cpp index c34f3e25439..27cb9bebde4 100644 --- a/clang/lib/Basic/SourceManager.cpp +++ b/clang/lib/Basic/SourceManager.cpp @@ -89,15 +89,26 @@ const llvm::MemoryBuffer *ContentCache::getBuffer(Diagnostic &Diag, char *Ptr = const_cast(Buffer.getPointer()->getBufferStart()); for (unsigned i = 0, e = Entry->getSize(); i != e; ++i) Ptr[i] = FillStr[i % FillStr.size()]; - Diag.Report(diag::err_cannot_open_file) - << Entry->getName() << ErrorStr; + + if (Diag.isDiagnosticInFlight()) + Diag.SetDelayedDiagnostic(diag::err_cannot_open_file, + Entry->getName(), ErrorStr); + else + Diag.Report(diag::err_cannot_open_file) + << Entry->getName() << ErrorStr; + Buffer.setInt(true); } else if (FileInfo.st_size != Entry->getSize() || FileInfo.st_mtime != Entry->getModificationTime()) { // Check that the file's size, modification time, and inode are // the same as in the file entry (which may have come from a // stat cache). - Diag.Report(diag::err_file_modified) << Entry->getName(); + if (Diag.isDiagnosticInFlight()) + Diag.SetDelayedDiagnostic(diag::err_file_modified, + Entry->getName()); + else + Diag.Report(diag::err_file_modified) << Entry->getName(); + Buffer.setInt(true); } } -- cgit v1.2.3