summaryrefslogtreecommitdiffstats
path: root/clang/lib/Basic/VirtualFileSystem.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/Basic/VirtualFileSystem.cpp')
-rw-r--r--clang/lib/Basic/VirtualFileSystem.cpp27
1 files changed, 10 insertions, 17 deletions
diff --git a/clang/lib/Basic/VirtualFileSystem.cpp b/clang/lib/Basic/VirtualFileSystem.cpp
index 04383dbb878..6e55d2e7d78 100644
--- a/clang/lib/Basic/VirtualFileSystem.cpp
+++ b/clang/lib/Basic/VirtualFileSystem.cpp
@@ -10,6 +10,7 @@
//===----------------------------------------------------------------------===//
#include "clang/Basic/VirtualFileSystem.h"
+#include "clang/Basic/FileManager.h"
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/ADT/StringExtras.h"
@@ -482,7 +483,7 @@ InMemoryFileSystem::InMemoryFileSystem()
InMemoryFileSystem::~InMemoryFileSystem() {}
-StringRef InMemoryFileSystem::toString() const {
+std::string InMemoryFileSystem::toString() const {
return Root->toString(/*Indent=*/0);
}
@@ -496,17 +497,14 @@ void InMemoryFileSystem::addFile(const Twine &P, time_t ModificationTime,
assert(!EC);
(void)EC;
+ FileManager::removeDotPaths(Path, /*RemoveDotDot=*/true);
+ if (Path.empty())
+ return;
+
detail::InMemoryDirectory *Dir = Root.get();
auto I = llvm::sys::path::begin(Path), E = llvm::sys::path::end(Path);
while (true) {
StringRef Name = *I;
- // Skip over ".".
- // FIXME: Also handle "..".
- if (Name == ".") {
- ++I;
- continue;
- }
-
detail::InMemoryNode *Node = Dir->getChild(Name);
++I;
if (!Node) {
@@ -558,17 +556,12 @@ lookupInMemoryNode(const InMemoryFileSystem &FS, detail::InMemoryDirectory *Dir,
assert(!EC);
(void)EC;
+ FileManager::removeDotPaths(Path, /*RemoveDotDot=*/true);
+ if (Path.empty())
+ return Dir;
+
auto I = llvm::sys::path::begin(Path), E = llvm::sys::path::end(Path);
while (true) {
- // Skip over ".".
- // FIXME: Also handle "..".
- if (*I == ".") {
- ++I;
- if (I == E)
- return Dir;
- continue;
- }
-
detail::InMemoryNode *Node = Dir->getChild(*I);
++I;
if (!Node)
OpenPOWER on IntegriCloud