[cfe-commits] r117393 - in /cfe/trunk: include/clang/Basic/SourceManager.h lib/Basic/SourceManager.cpp

Dan Gohman gohman at apple.com
Tue Oct 26 13:47:28 PDT 2010


Author: djg
Date: Tue Oct 26 15:47:28 2010
New Revision: 117393

URL: http://llvm.org/viewvc/llvm-project?rev=117393&view=rev
Log:
getOrCreateContentCache never returns null, so overrideFileContents
doesn't need its return value.

Modified:
    cfe/trunk/include/clang/Basic/SourceManager.h
    cfe/trunk/lib/Basic/SourceManager.cpp

Modified: cfe/trunk/include/clang/Basic/SourceManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=117393&r1=117392&r2=117393&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/SourceManager.h (original)
+++ cfe/trunk/include/clang/Basic/SourceManager.h Tue Oct 26 15:47:28 2010
@@ -466,7 +466,7 @@
                       unsigned PreallocatedID = 0,
                       unsigned Offset = 0) {
     const SrcMgr::ContentCache *IR = getOrCreateContentCache(SourceFile);
-    if (IR == 0) return FileID();    // Error opening file?
+    assert(IR && "getOrCreateContentCache() cannot return NULL");
     return createFileID(IR, IncludePos, FileCharacter, PreallocatedID, Offset);
   }
 
@@ -516,9 +516,7 @@
   ///
   /// \param DoNotFree If true, then the buffer will not be freed when the
   /// source manager is destroyed.
-  ///
-  /// \returns true if an error occurred, false otherwise.
-  bool overrideFileContents(const FileEntry *SourceFile,
+  void overrideFileContents(const FileEntry *SourceFile,
                             const llvm::MemoryBuffer *Buffer,
                             bool DoNotFree = false);
 

Modified: cfe/trunk/lib/Basic/SourceManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=117393&r1=117392&r2=117393&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/SourceManager.cpp (original)
+++ cfe/trunk/lib/Basic/SourceManager.cpp Tue Oct 26 15:47:28 2010
@@ -525,15 +525,13 @@
   return IR->getBuffer(Diag, *this, SourceLocation(), Invalid);
 }
 
-bool SourceManager::overrideFileContents(const FileEntry *SourceFile,
+void SourceManager::overrideFileContents(const FileEntry *SourceFile,
                                          const llvm::MemoryBuffer *Buffer,
                                          bool DoNotFree) {
   const SrcMgr::ContentCache *IR = getOrCreateContentCache(SourceFile);
-  if (IR == 0)
-    return true;
+  assert(IR && "getOrCreateContentCache() cannot return NULL");
 
   const_cast<SrcMgr::ContentCache *>(IR)->replaceBuffer(Buffer, DoNotFree);
-  return false;
 }
 
 llvm::StringRef SourceManager::getBufferData(FileID FID, bool *Invalid) const {





More information about the cfe-commits mailing list