diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-11-03 22:45:23 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2010-11-03 22:45:23 +0000 |
commit | 389db16c63eec6ecfa9b235155252d8da766e94e (patch) | |
tree | fee8c776b8591a09c1387bcc7dd3bd1bccb14e7e /lib/Frontend/InitHeaderSearch.cpp | |
parent | f1410802d1c9e7ff72b2818ad91fd85283abc6bf (diff) |
Implement -working-directory.
When -working-directory is passed in command line, file paths are resolved relative to the specified directory.
This helps both when using libclang (where we can't require the user to actually change the working directory)
and to help reproduce test cases when the reproduction work comes along.
--FileSystemOptions is introduced which controls how file system operations are performed (currently it just contains
the working directory value if set).
--FileSystemOptions are passed around to various interfaces that perform file operations.
--Opening & reading the content of files should be done only through FileManager. This is useful in general since
file operations will be abstracted in the future for the reproduction mechanism.
FileSystemOptions is independent of FileManager so that we can have multiple translation units sharing the same
FileManager but with different FileSystemOptions.
Addresses rdar://8583824.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@118203 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/InitHeaderSearch.cpp')
-rw-r--r-- | lib/Frontend/InitHeaderSearch.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/Frontend/InitHeaderSearch.cpp b/lib/Frontend/InitHeaderSearch.cpp index 97157b3615..e47381e39d 100644 --- a/lib/Frontend/InitHeaderSearch.cpp +++ b/lib/Frontend/InitHeaderSearch.cpp @@ -99,6 +99,7 @@ void InitHeaderSearch::AddPath(const llvm::Twine &Path, bool IgnoreSysRoot) { assert(!Path.isTriviallyEmpty() && "can't handle empty path here"); FileManager &FM = Headers.getFileMgr(); + const FileSystemOptions &FSOpts = Headers.getFileSystemOpts(); // Compute the actual path, taking into consideration -isysroot. llvm::SmallString<256> MappedPathStr; @@ -125,7 +126,7 @@ void InitHeaderSearch::AddPath(const llvm::Twine &Path, // If the directory exists, add it. - if (const DirectoryEntry *DE = FM.getDirectory(MappedPath.str())) { + if (const DirectoryEntry *DE = FM.getDirectory(MappedPath.str(), FSOpts)) { IncludeGroup[Group].push_back(DirectoryLookup(DE, Type, isUserSupplied, isFramework)); return; @@ -134,7 +135,7 @@ void InitHeaderSearch::AddPath(const llvm::Twine &Path, // Check to see if this is an apple-style headermap (which are not allowed to // be frameworks). if (!isFramework) { - if (const FileEntry *FE = FM.getFile(MappedPath.str())) { + if (const FileEntry *FE = FM.getFile(MappedPath.str(), FSOpts)) { if (const HeaderMap *HM = Headers.CreateHeaderMap(FE)) { // It is a headermap, add it to the search path. IncludeGroup[Group].push_back(DirectoryLookup(HM, Type,isUserSupplied)); |