[cfe-commits] r120007 - in /cfe/trunk: include/clang/Basic/FileManager.h lib/Basic/FileManager.cpp lib/Frontend/ASTUnit.cpp lib/Frontend/CompilerInstance.cpp lib/Frontend/CompilerInvocation.cpp tools/libclang/CIndexCodeCompletion.cpp

Chris Lattner sabre at nondot.org
Mon Nov 22 23:51:03 PST 2010


Author: lattner
Date: Tue Nov 23 01:51:02 2010
New Revision: 120007

URL: http://llvm.org/viewvc/llvm-project?rev=120007&view=rev
Log:
give FileManager a 'FileSystemOptions' ivar, which will be used
to simplify a bunch of code in it.  It should ultimately get inlined
into FileManager.

Modified:
    cfe/trunk/include/clang/Basic/FileManager.h
    cfe/trunk/lib/Basic/FileManager.cpp
    cfe/trunk/lib/Frontend/ASTUnit.cpp
    cfe/trunk/lib/Frontend/CompilerInstance.cpp
    cfe/trunk/lib/Frontend/CompilerInvocation.cpp
    cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp

Modified: cfe/trunk/include/clang/Basic/FileManager.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/FileManager.h?rev=120007&r1=120006&r2=120007&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/FileManager.h (original)
+++ cfe/trunk/include/clang/Basic/FileManager.h Tue Nov 23 01:51:02 2010
@@ -141,7 +141,8 @@
 /// names (e.g. symlinked) will be treated as a single file.
 ///
 class FileManager {
-
+  const FileSystemOptions &FileSystemOpts;
+  
   class UniqueDirContainer;
   class UniqueFileContainer;
 
@@ -170,11 +171,10 @@
   // Caching.
   llvm::OwningPtr<StatSysCallCache> StatCache;
 
-  int stat_cached(const char* path, struct stat* buf,
-                  const FileSystemOptions &FileSystemOpts);
+  int stat_cached(const char* path, struct stat* buf);
 
 public:
-  FileManager();
+  FileManager(const FileSystemOptions &FileSystemOpts);
   ~FileManager();
 
   /// \brief Installs the provided StatSysCallCache object within

Modified: cfe/trunk/lib/Basic/FileManager.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/FileManager.cpp?rev=120007&r1=120006&r2=120007&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/FileManager.cpp (original)
+++ cfe/trunk/lib/Basic/FileManager.cpp Tue Nov 23 01:51:02 2010
@@ -142,8 +142,9 @@
 // Common logic.
 //===----------------------------------------------------------------------===//
 
-FileManager::FileManager()
-  : UniqueDirs(*new UniqueDirContainer),
+FileManager::FileManager(const FileSystemOptions &FSO)
+  : FileSystemOpts(FSO),
+    UniqueDirs(*new UniqueDirContainer),
     UniqueFiles(*new UniqueFileContainer),
     DirEntries(64), FileEntries(64), NextFileUID(0) {
   NumDirLookups = NumFileLookups = 0;
@@ -250,7 +251,7 @@
 
   // Check to see if the directory exists.
   struct stat StatBuf;
-  if (stat_cached(InterndDirName, &StatBuf, FileSystemOpts) ||   // Error stat'ing.
+  if (stat_cached(InterndDirName, &StatBuf) ||   // Error stat'ing.
       !S_ISDIR(StatBuf.st_mode))          // Not a directory?
     return 0;
 
@@ -309,7 +310,7 @@
   // Nope, there isn't.  Check to see if the file exists.
   struct stat StatBuf;
   //llvm::errs() << "STATING: " << Filename;
-  if (stat_cached(InterndFileName, &StatBuf, FileSystemOpts) ||   // Error stat'ing.
+  if (stat_cached(InterndFileName, &StatBuf) ||   // Error stat'ing.
         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";
@@ -375,7 +376,7 @@
   // newly-created file entry.
   const char *InterndFileName = NamedFileEnt.getKeyData();
   struct stat StatBuf;
-  if (!stat_cached(InterndFileName, &StatBuf, FileSystemOpts) &&
+  if (!stat_cached(InterndFileName, &StatBuf) &&
       !S_ISDIR(StatBuf.st_mode)) {
     llvm::sys::Path FilePath(InterndFileName);
     FilePath.makeAbsolute();
@@ -408,8 +409,7 @@
   return llvm::MemoryBuffer::getFile(FilePath.c_str(), ErrorStr, FileSize);
 }
 
-int FileManager::stat_cached(const char *path, struct stat *buf,
-                             const FileSystemOptions &FileSystemOpts) {
+int FileManager::stat_cached(const char *path, struct stat *buf) {
   if (FileSystemOpts.WorkingDir.empty())
     return StatCache.get() ? StatCache->stat(path, buf) : stat(path, buf);
 

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=120007&r1=120006&r2=120007&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Tue Nov 23 01:51:02 2010
@@ -492,7 +492,7 @@
   AST->CaptureDiagnostics = CaptureDiagnostics;
   AST->Diagnostics = Diags;
   AST->FileSystemOpts = FileSystemOpts;
-  AST->FileMgr.reset(new FileManager);
+  AST->FileMgr.reset(new FileManager(FileSystemOpts));
   AST->SourceMgr.reset(new SourceManager(AST->getDiagnostics(),
                                          AST->getFileManager(),
                                          AST->getFileSystemOpts()));
@@ -753,7 +753,7 @@
 
   // Configure the various subsystems.
   // FIXME: Should we retain the previous file manager?
-  FileMgr.reset(new FileManager);
+  FileMgr.reset(new FileManager(Clang.getFileSystemOpts()));
   FileSystemOpts = Clang.getFileSystemOpts();
   SourceMgr.reset(new SourceManager(getDiagnostics(), *FileMgr, FileSystemOpts));
   TheSema.reset();
@@ -1245,7 +1245,7 @@
   TopLevelDeclsInPreamble.clear();
   
   // Create a file manager object to provide access to and cache the filesystem.
-  Clang.setFileManager(new FileManager);
+  Clang.setFileManager(new FileManager(Clang.getFileSystemOpts()));
   
   // Create the source manager.
   Clang.setSourceManager(new SourceManager(getDiagnostics(),

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=120007&r1=120006&r2=120007&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Tue Nov 23 01:51:02 2010
@@ -148,7 +148,7 @@
 // File Manager
 
 void CompilerInstance::createFileManager() {
-  FileMgr.reset(new FileManager());
+  FileMgr.reset(new FileManager(getFileSystemOpts()));
 }
 
 // Source Manager

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=120007&r1=120006&r2=120007&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Nov 23 01:51:02 2010
@@ -1563,7 +1563,7 @@
   // PCH file and find the original header name. Remove the need to do that in
   // ParsePreprocessorArgs and remove the FileManager & FileSystemOptions
   // parameters from the function and the "FileManager.h" #include.
-  FileManager FileMgr;
+  FileManager FileMgr(Res.getFileSystemOpts());
   ParsePreprocessorArgs(Res.getPreprocessorOpts(), *Args,
                         FileMgr, Res.getFileSystemOpts(), Diags);
   ParsePreprocessorOutputArgs(Res.getPreprocessorOutputOpts(), *Args);

Modified: cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp?rev=120007&r1=120006&r2=120007&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexCodeCompletion.cpp Tue Nov 23 01:51:02 2010
@@ -247,7 +247,8 @@
   /// with the code-completion results.
   std::vector<llvm::sys::Path> TemporaryFiles;
 
-  /// \brief Temporary buffers that will be deleted once we have finished with the code-completion results.
+  /// \brief Temporary buffers that will be deleted once we have finished with
+  /// the code-completion results.
   llvm::SmallVector<const llvm::MemoryBuffer *, 1> TemporaryBuffers;
 };
 
@@ -261,6 +262,7 @@
   : CXCodeCompleteResults(),
     Diag(new Diagnostic(
                    llvm::IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs))),
+    FileMgr(FileSystemOpts),
     SourceMgr(*Diag, FileMgr, FileSystemOpts) { 
   if (getenv("LIBCLANG_OBJTRACKING")) {
     ++CodeCompletionResultObjects;





More information about the cfe-commits mailing list