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

Anders Carlsson andersca at mac.com
Fri Mar 18 12:23:19 PDT 2011


Author: andersca
Date: Fri Mar 18 14:23:19 2011
New Revision: 127893

URL: http://llvm.org/viewvc/llvm-project?rev=127893&view=rev
Log:
Add FileManager::getNoncachedStatValue, which will resolve relative paths against the working directory specified in the file system options.

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

Modified: cfe/trunk/include/clang/Basic/FileManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=127893&r1=127892&r2=127893&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/FileManager.h (original)
+++ cfe/trunk/include/clang/Basic/FileManager.h Fri Mar 18 14:23:19 2011
@@ -195,6 +195,11 @@
   llvm::MemoryBuffer *getBufferForFile(llvm::StringRef Filename,
                                        std::string *ErrorStr = 0);
 
+  // getNoncachedStatValue - Will get the 'stat' information for the given path.
+  // If the path is relative, it will be resolved against the WorkingDir of the
+  // FileManager's FileSystemOptions.
+  bool getNoncachedStatValue(llvm::StringRef Path, struct stat &StatBuf);
+
   /// \brief If path is not absolute and FileSystemOptions set the working
   /// directory, the path is modified to be relative to the given
   /// working directory.

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=127893&r1=127892&r2=127893&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Fri Mar 18 14:23:19 2011
@@ -541,6 +541,14 @@
                                   StatCache.get());
 }
 
+bool FileManager::getNoncachedStatValue(llvm::StringRef Path, 
+                                        struct stat &StatBuf) {
+  llvm::SmallString<128> FilePath(Path);
+  FixupRelativePath(FilePath);
+
+  return ::stat(FilePath.c_str(), &StatBuf) != 0;
+}
+
 void FileManager::GetUniqueIDMapping(
                    llvm::SmallVectorImpl<const FileEntry *> &UIDToFiles) const {
   UIDToFiles.clear();





More information about the cfe-commits mailing list