aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2010-11-23 07:51:02 +0000
committerChris Lattner <sabre@nondot.org>2010-11-23 07:51:02 +0000
commit7ad97ffa631af6ad678c79b38341ac995f347ce9 (patch)
tree91682978a5bcc7469d1e8685bcb157952f68d574 /lib
parent02a8078b9de108b6d0c33f488ebf06cb826cf4b6 (diff)
give FileManager a 'FileSystemOptions' ivar, which will be used
to simplify a bunch of code in it. It should ultimately get inlined into FileManager. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@120007 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/Basic/FileManager.cpp14
-rw-r--r--lib/Frontend/ASTUnit.cpp6
-rw-r--r--lib/Frontend/CompilerInstance.cpp2
-rw-r--r--lib/Frontend/CompilerInvocation.cpp2
4 files changed, 12 insertions, 12 deletions
diff --git a/lib/Basic/FileManager.cpp b/lib/Basic/FileManager.cpp
index c8515a356b..6b356b87d5 100644
--- a/lib/Basic/FileManager.cpp
+++ b/lib/Basic/FileManager.cpp
@@ -142,8 +142,9 @@ public:
// 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 @@ const DirectoryEntry *FileManager::getDirectory(llvm::StringRef Filename,
// 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 @@ const FileEntry *FileManager::getFile(llvm::StringRef Filename,
// 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 @@ FileManager::getVirtualFile(llvm::StringRef Filename, off_t Size,
// 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 @@ getBufferForFile(llvm::StringRef Filename,
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);
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp
index d590d6966f..cbcb08b6fe 100644
--- a/lib/Frontend/ASTUnit.cpp
+++ b/lib/Frontend/ASTUnit.cpp
@@ -492,7 +492,7 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename,
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 @@ bool ASTUnit::Parse(llvm::MemoryBuffer *OverrideMainBuffer) {
// 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 @@ llvm::MemoryBuffer *ASTUnit::getMainBufferWithPrecompiledPreamble(
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(),
diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp
index 67552747d4..06917706be 100644
--- a/lib/Frontend/CompilerInstance.cpp
+++ b/lib/Frontend/CompilerInstance.cpp
@@ -148,7 +148,7 @@ CompilerInstance::createDiagnostics(const DiagnosticOptions &Opts,
// File Manager
void CompilerInstance::createFileManager() {
- FileMgr.reset(new FileManager());
+ FileMgr.reset(new FileManager(getFileSystemOpts()));
}
// Source Manager
diff --git a/lib/Frontend/CompilerInvocation.cpp b/lib/Frontend/CompilerInvocation.cpp
index b1d6adb94b..b0c30361dd 100644
--- a/lib/Frontend/CompilerInvocation.cpp
+++ b/lib/Frontend/CompilerInvocation.cpp
@@ -1563,7 +1563,7 @@ void CompilerInvocation::CreateFromArgs(CompilerInvocation &Res,
// 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);