Introduce a new BufferResult class to act as the return type of
SourceManager's getBuffer() (and similar) operations. This abstract
can be used to force callers to cope with errors in getBuffer(), such
as missing files and changed files. Fix a bunch of callers to use the
new interface.

Add some very basic checks for file consistency (file size,
modification time) into ContentCache::getBuffer(), although these
checks don't help much until we've updated the main callers (e.g.,
SourceManager::getSpelling()).



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@98585 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Frontend/TextDiagnosticPrinter.cpp b/lib/Frontend/TextDiagnosticPrinter.cpp
index 60c1f4b..2b243fa 100644
--- a/lib/Frontend/TextDiagnosticPrinter.cpp
+++ b/lib/Frontend/TextDiagnosticPrinter.cpp
@@ -330,9 +330,15 @@
   unsigned FileOffset = LocInfo.second;
 
   // Get information about the buffer it points into.
-  std::pair<const char*, const char*> BufferInfo = SM.getBufferData(FID);
+  llvm::StringRef ErrorFileName;
+  std::string ErrorStr;
+  std::pair<const char*, const char*> BufferInfo = SM.getBufferData(FID, 
+                                                                  ErrorFileName,
+                                                                    ErrorStr);
   const char *BufStart = BufferInfo.first;
-
+  if (!BufStart)
+    return;
+  
   unsigned ColNo = SM.getColumnNumber(FID, FileOffset);
   unsigned CaretEndColNo
     = ColNo + Lexer::MeasureTokenLength(Loc, SM, *LangOpts);