17#include "llvm/Config/llvm-config.h"
18#include "llvm/Support/FileSystem.h"
19#include "llvm/Support/Path.h"
20#include "llvm/Support/raw_ostream.h"
27 ModuleDependencyCollector &Collector;
30 ModuleDependencyListener(ModuleDependencyCollector &Collector,
32 : Collector(Collector), FileMgr(FileMgr) {}
33 bool needsInputFileVisitation()
override {
return true; }
34 bool needsSystemInputFileVisitation()
override {
return true; }
35 bool visitInputFile(StringRef Filename,
bool IsSystem,
bool IsOverridden,
36 bool IsExplicitModule)
override {
39 if (
auto FE = FileMgr.getOptionalFileRef(Filename))
40 Filename = FE->getName();
41 Collector.addFile(Filename);
46struct ModuleDependencyPPCallbacks :
public PPCallbacks {
47 ModuleDependencyCollector &Collector;
49 ModuleDependencyPPCallbacks(ModuleDependencyCollector &Collector,
51 : Collector(Collector), SM(SM) {}
53 void InclusionDirective(SourceLocation HashLoc,
const Token &IncludeTok,
55 CharSourceRange FilenameRange,
57 StringRef RelativePath,
const Module *SuggestedModule,
62 Collector.addFile(
File->getName());
67 ModuleDependencyCollector &Collector;
68 ModuleDependencyMMCallbacks(ModuleDependencyCollector &Collector)
69 : Collector(Collector) {}
71 void moduleMapAddHeader(StringRef HeaderPath)
override {
72 if (llvm::sys::path::is_absolute(HeaderPath))
73 Collector.addFile(HeaderPath);
75 void moduleMapAddUmbrellaHeader(FileEntryRef Header)
override {
84 std::make_unique<ModuleDependencyListener>(*
this, R.
getFileManager()));
91 std::make_unique<ModuleDependencyMMCallbacks>(*
this));
97 if (llvm::sys::fs::real_path(Path, TmpDest))
107 if (!llvm::sys::fs::real_path(UpperDest, RealDest) && Path == RealDest)
120 VFSWriter.setOverlayDir(VFSDir);
128 VFSWriter.setUseExternalNames(
false);
132 llvm::sys::path::append(YAMLPath,
"vfs.yaml");
133 llvm::raw_fd_ostream OS(YAMLPath, EC, llvm::sys::fs::OF_TextWithCRLF);
141std::error_code ModuleDependencyCollector::copyToRoot(StringRef Src,
143 using namespace llvm::sys;
144 llvm::FileCollector::PathCanonicalizer::PathStorage Paths =
145 Canonicalizer.canonicalize(Src);
152 path::append(CacheDst, path::relative_path(Paths.CopyFrom));
156 if (!fs::exists(Dst))
157 return std::error_code();
158 path::append(CacheDst, Dst);
159 Paths.CopyFrom = Dst;
163 if (std::error_code EC = fs::create_directories(path::parent_path(CacheDst),
166 if (std::error_code EC = fs::copy_file(Paths.CopyFrom, CacheDst))
175 return std::error_code();
180 if (copyToRoot(Filename, FileDst))
llvm::MachO::FileType FileType
static bool isCaseSensitivePath(StringRef Path)
Defines the clang::Preprocessor interface.
Abstract interface for callback invocations by the ASTReader.
Reads an AST files chain containing the contents of a translation unit.
void addListener(std::unique_ptr< ASTReaderListener > L)
Add an AST callback listener.
FileManager & getFileManager() const
StringRef getNameAsRequested() const
The name of this FileEntry, as originally requested without applying any remappings for VFS 'use-exte...
void attachToASTReader(ASTReader &R) override
virtual void addFileMapping(StringRef VPath, StringRef RPath)
void attachToPreprocessor(Preprocessor &PP) override
virtual void addFile(StringRef Filename, StringRef FileDst={})
virtual bool insertSeen(StringRef Filename)
virtual void writeFileMap()
A mechanism to observe the actions of the module map loader as it reads module map files.
void addModuleMapCallbacks(std::unique_ptr< ModuleMapCallbacks > Callback)
Add a module map callback.
This interface provides a way to observe the actions of the preprocessor as it does its thing.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.
void addPPCallbacks(std::unique_ptr< PPCallbacks > C)
SourceManager & getSourceManager() const
HeaderSearch & getHeaderSearchInfo() const
CharacteristicKind
Indicates whether a file or directory holds normal user code, system code, or system code which is im...
The JSON file list parser is used to communicate input to InstallAPI.
CustomizableOptional< FileEntryRef > OptionalFileEntryRef
@ Module
Module linkage, which indicates that the entity can be referred to from other translation units withi...
LLVM_READONLY char toUppercase(char c)
Converts the given ASCII character to its uppercase equivalent.