diff options
author | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2016-05-06 23:21:57 +0000 |
---|---|---|
committer | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2016-05-06 23:21:57 +0000 |
commit | b2e2e21b20ae00a47e931bdb66d2980453e2d717 (patch) | |
tree | 7c83eb19d7dbbbc7254f189841cc1a12d91bab49 /clang/lib/Basic/VirtualFileSystem.cpp | |
parent | f08417904dec10db8b45cdfbd5669b3fe1fce6cf (diff) | |
download | llvm-b2e2e21b20ae00a47e931bdb66d2980453e2d717.zip llvm-b2e2e21b20ae00a47e931bdb66d2980453e2d717.tar.gz llvm-b2e2e21b20ae00a47e931bdb66d2980453e2d717.tar.bz2 |
[VFS] Add dump methods to the VFS overlay tree
Useful when debugging issues within the VFS overlay.
llvm-svn: 268820
Diffstat (limited to 'clang/lib/Basic/VirtualFileSystem.cpp')
-rw-r--r-- | clang/lib/Basic/VirtualFileSystem.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/clang/lib/Basic/VirtualFileSystem.cpp b/clang/lib/Basic/VirtualFileSystem.cpp index be7a637..7cffabc 100644 --- a/clang/lib/Basic/VirtualFileSystem.cpp +++ b/clang/lib/Basic/VirtualFileSystem.cpp @@ -16,6 +16,7 @@ #include "llvm/ADT/StringExtras.h" #include "llvm/ADT/StringSet.h" #include "llvm/ADT/iterator_range.h" +#include "llvm/Support/Debug.h" #include "llvm/Support/Errc.h" #include "llvm/Support/MemoryBuffer.h" #include "llvm/Support/Path.h" @@ -920,6 +921,29 @@ public: return ExternalContentsPrefixDir; } +#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) +LLVM_DUMP_METHOD void dump() const { + for (const std::unique_ptr<Entry> &Root : Roots) + dumpEntry(Root.get()); + } + +LLVM_DUMP_METHOD void dumpEntry(Entry *E, int NumSpaces = 0) const { + StringRef Name = E->getName(); + for (int i = 0, e = NumSpaces; i < e; ++i) + dbgs() << " "; + dbgs() << "'" << Name.str().c_str() << "'" << "\n"; + + if (E->getKind() == EK_Directory) { + auto *DE = dyn_cast<RedirectingDirectoryEntry>(E); + assert(DE && "Should be a directory"); + + for (std::unique_ptr<Entry> &SubEntry : + llvm::make_range(DE->contents_begin(), DE->contents_end())) + dumpEntry(SubEntry.get(), NumSpaces+2); + } + } +#endif + }; /// \brief A helper class to hold the common YAML parsing state. |