16 #include "llvm/ADT/StringSet.h"
17 #include "llvm/ADT/iterator_range.h"
18 #include "llvm/Support/FileSystem.h"
19 #include "llvm/Support/Path.h"
20 #include "llvm/Support/raw_ostream.h"
22 using namespace clang;
29 std::error_code copyToRoot(StringRef Src);
32 : Collector(Collector) {}
33 bool needsInputFileVisitation()
override {
return true; }
34 bool needsSystemInputFileVisitation()
override {
return true; }
35 bool visitInputFile(StringRef Filename,
bool IsSystem,
36 bool IsOverridden)
override;
41 R.
addListener(llvm::make_unique<ModuleDependencyListener>(*
this));
49 llvm::sys::path::append(Dest,
"vfs.yaml");
52 llvm::raw_fd_ostream OS(Dest, EC, llvm::sys::fs::F_Text);
60 std::error_code ModuleDependencyListener::copyToRoot(StringRef Src) {
61 using namespace llvm::sys;
65 fs::make_absolute(AbsoluteSrc);
67 path::native(AbsoluteSrc);
74 path::append(Dest, path::relative_path(AbsoluteSrc));
77 if (std::error_code EC = fs::create_directories(path::parent_path(Dest),
80 if (std::error_code EC = fs::copy_file(AbsoluteSrc, Dest))
83 Collector.addFileMapping(AbsoluteSrc, Dest);
84 return std::error_code();
87 bool ModuleDependencyListener::visitInputFile(StringRef Filename,
bool IsSystem,
89 if (Collector.insertSeen(Filename))
90 if (copyToRoot(Filename))
91 Collector.setHasErrors();
static bool removeDotPaths(SmallVectorImpl< char > &Path)
Remove any './' components from a path.
void write(llvm::raw_ostream &OS)
void attachToASTReader(ASTReader &R)
void addListener(std::unique_ptr< ASTReaderListener > L)
Add an AST callback listener.
Reads an AST files chain containing the contents of a translation unit.
Abstract interface for callback invocations by the ASTReader.