diff options
author | Ben Langmuir <blangmuir@apple.com> | 2014-03-04 22:34:50 +0000 |
---|---|---|
committer | Ben Langmuir <blangmuir@apple.com> | 2014-03-04 22:34:50 +0000 |
commit | a6f8ca8c5f62a79d319a00a4cb4b8bee6ddebc84 (patch) | |
tree | 8553f37d10e586fa9bee7b98ab42cd6308284360 /clang/lib/Basic/VirtualFileSystem.cpp | |
parent | 635631306fc8225c5cd34c0fb6bd960d3ea3f842 (diff) | |
download | llvm-a6f8ca8c5f62a79d319a00a4cb4b8bee6ddebc84.zip llvm-a6f8ca8c5f62a79d319a00a4cb4b8bee6ddebc84.tar.gz llvm-a6f8ca8c5f62a79d319a00a4cb4b8bee6ddebc84.tar.bz2 |
Support relative paths in VFSFromYAML
Use llvm::sys::fs::make_absolute to get an absolute path before
matching. Also, allow "." directories to enable testing. ".." is still
not supported, and will require crossing file system boundaries to
implement correctly.
llvm-svn: 202903
Diffstat (limited to 'clang/lib/Basic/VirtualFileSystem.cpp')
-rw-r--r-- | clang/lib/Basic/VirtualFileSystem.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/clang/lib/Basic/VirtualFileSystem.cpp b/clang/lib/Basic/VirtualFileSystem.cpp index 43b203a..dc0f52f 100644 --- a/clang/lib/Basic/VirtualFileSystem.cpp +++ b/clang/lib/Basic/VirtualFileSystem.cpp @@ -733,8 +733,12 @@ VFSFromYAML *VFSFromYAML::create(MemoryBuffer *Buffer, } ErrorOr<Entry *> VFSFromYAML::lookupPath(const Twine &Path_) { - SmallVector<char, 256> Storage; - StringRef Path = Path_.toNullTerminatedStringRef(Storage); + SmallString<256> Path; + Path_.toVector(Path); + + // Handle relative paths + if (error_code EC = sys::fs::make_absolute(Path)) + return EC; if (Path.empty()) return error_code(errc::invalid_argument, system_category()); @@ -753,7 +757,10 @@ ErrorOr<Entry *> VFSFromYAML::lookupPath(const Twine &Path_) { ErrorOr<Entry *> VFSFromYAML::lookupPath(sys::path::const_iterator Start, sys::path::const_iterator End, Entry *From) { - // FIXME: handle . and .. + if (Start->equals(".")) + ++Start; + + // FIXME: handle .. if (CaseSensitive ? !Start->equals(From->getName()) : !Start->equals_lower(From->getName())) // failure to match |