[cfe-commits] r120013 - in /cfe/trunk: include/clang/Basic/FileManager.h include/clang/Frontend/ASTUnit.h lib/Basic/FileManager.cpp lib/Frontend/ASTUnit.cpp lib/Serialization/ASTReader.cpp

Chris Lattner sabre at nondot.org
Tue Nov 23 01:19:42 PST 2010


Author: lattner
Date: Tue Nov 23 03:19:42 2010
New Revision: 120013

URL: http://llvm.org/viewvc/llvm-project?rev=120013&view=rev
Log:
tidy up.  Split FileManager::getBufferForFile into
two copies, since they are fundamentally different
operations and the StringRef one should go away
(it shouldn't be part of FileManager at least).

Remove some dead arguments.

Modified:
    cfe/trunk/include/clang/Basic/FileManager.h
    cfe/trunk/include/clang/Frontend/ASTUnit.h
    cfe/trunk/lib/Basic/FileManager.cpp
    cfe/trunk/lib/Frontend/ASTUnit.cpp
    cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/Basic/FileManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=120013&r1=120012&r2=120013&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/FileManager.h (original)
+++ cfe/trunk/include/clang/Basic/FileManager.h Tue Nov 23 03:19:42 2010
@@ -171,7 +171,7 @@
   // Caching.
   llvm::OwningPtr<StatSysCallCache> StatCache;
 
-  int stat_cached(const char* path, struct stat* buf);
+  int stat_cached(const char *path, struct stat *buf);
 
 public:
   FileManager(const FileSystemOptions &FileSystemOpts);
@@ -212,12 +212,9 @@
   /// \brief Open the specified file as a MemoryBuffer, returning a new
   /// MemoryBuffer if successful, otherwise returning null.
   llvm::MemoryBuffer *getBufferForFile(const FileEntry *Entry,
-                                       std::string *ErrorStr = 0) {
-    return getBufferForFile(Entry->getName(), ErrorStr, Entry->getSize());
-  }
+                                       std::string *ErrorStr = 0);
   llvm::MemoryBuffer *getBufferForFile(llvm::StringRef Filename,
-                                       std::string *ErrorStr = 0,
-                                       int64_t FileSize = -1);
+                                       std::string *ErrorStr = 0);
 
   /// \brief If path is not absolute and FileSystemOptions set the working
   /// directory, the path is modified to be relative to the given

Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=120013&r1=120012&r2=120013&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Tue Nov 23 03:19:42 2010
@@ -462,8 +462,7 @@
   }
 
   llvm::MemoryBuffer *getBufferForFile(llvm::StringRef Filename,
-                                       std::string *ErrorStr = 0,
-                                       int64_t FileSize = -1);
+                                       std::string *ErrorStr = 0);
 
   /// \brief Whether this AST represents a complete translation unit.
   ///

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=120013&r1=120012&r2=120013&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Tue Nov 23 03:19:42 2010
@@ -307,7 +307,7 @@
   struct stat StatBuf;
   //llvm::errs() << "STATING: " << Filename;
   if (stat_cached(InterndFileName, &StatBuf) ||   // Error stat'ing.
-        S_ISDIR(StatBuf.st_mode)) {           // A directory?
+      S_ISDIR(StatBuf.st_mode)) {                 // A directory?
     // If this file doesn't exist, we leave a null in FileEntries for this path.
     //llvm::errs() << ": Not existing\n";
     return 0;
@@ -389,17 +389,25 @@
   path = NewPath;
 }
 
-
+llvm::MemoryBuffer *FileManager::
+getBufferForFile(const FileEntry *Entry, std::string *ErrorStr) {
+  llvm::StringRef Filename = Entry->getName();
+  if (FileSystemOpts.WorkingDir.empty())
+    return llvm::MemoryBuffer::getFile(Filename, ErrorStr);
+  
+  llvm::sys::Path FilePath(Filename);
+  FixupRelativePath(FilePath, FileSystemOpts);
+  return llvm::MemoryBuffer::getFile(FilePath.c_str(), ErrorStr);
+}
 
 llvm::MemoryBuffer *FileManager::
-getBufferForFile(llvm::StringRef Filename,
-                 std::string *ErrorStr, int64_t FileSize) {
+getBufferForFile(llvm::StringRef Filename, std::string *ErrorStr) {
   if (FileSystemOpts.WorkingDir.empty())
-    return llvm::MemoryBuffer::getFile(Filename, ErrorStr, FileSize);
+    return llvm::MemoryBuffer::getFile(Filename, ErrorStr);
   
   llvm::sys::Path FilePath(Filename);
   FixupRelativePath(FilePath, FileSystemOpts);
-  return llvm::MemoryBuffer::getFile(FilePath.c_str(), ErrorStr, FileSize);
+  return llvm::MemoryBuffer::getFile(FilePath.c_str(), ErrorStr);
 }
 
 int FileManager::stat_cached(const char *path, struct stat *buf) {

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=120013&r1=120012&r2=120013&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Tue Nov 23 03:19:42 2010
@@ -456,10 +456,9 @@
 }
 
 llvm::MemoryBuffer *ASTUnit::getBufferForFile(llvm::StringRef Filename,
-                                              std::string *ErrorStr,
-                                              int64_t FileSize) {
+                                              std::string *ErrorStr) {
   assert(FileMgr);
-  return FileMgr->getBufferForFile(Filename, ErrorStr, FileSize);
+  return FileMgr->getBufferForFile(Filename, ErrorStr);
 }
 
 /// \brief Configure the diagnostics object for use with ASTUnit.

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=120013&r1=120012&r2=120013&view=diff
==============================================================================
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Nov 23 03:19:42 2010
@@ -1262,9 +1262,8 @@
       return Failure;
     }
 
-    FileID FID = SourceMgr.createFileID(File,
-                                       ReadSourceLocation(*F, Record[1]),
-                                       (SrcMgr::CharacteristicKind)Record[2],
+    FileID FID = SourceMgr.createFileID(File, ReadSourceLocation(*F, Record[1]),
+                                        (SrcMgr::CharacteristicKind)Record[2],
                                         ID, Record[0]);
     if (Record[3])
       const_cast<SrcMgr::FileInfo&>(SourceMgr.getSLocEntry(FID).getFile())





More information about the cfe-commits mailing list