17#include "llvm/ADT/iterator_range.h"
18#include "llvm/Config/llvm-config.h"
19#include "llvm/Support/FileSystem.h"
20#include "llvm/Support/Path.h"
21#include "llvm/Support/raw_ostream.h"
33 : Collector(Collector), FileMgr(FileMgr) {}
37 bool IsExplicitModule)
override {
47struct ModuleDependencyPPCallbacks :
public PPCallbacks {
52 : Collector(Collector),
SM(
SM) {}
55 StringRef FileName,
bool IsAngled,
58 StringRef RelativePath,
const Module *Imported,
69 : Collector(Collector) {}
72 if (llvm::sys::path::is_absolute(HeaderPath))
77 StringRef HeaderFilename = Header->
getName();
92 StringRef UmbreallDirFromHeader =
93 llvm::sys::path::parent_path(HeaderFilename);
95 if (!UmbrellaDir.equals(UmbreallDirFromHeader)) {
97 llvm::sys::path::append(AltHeaderFilename, UmbrellaDir,
98 llvm::sys::path::filename(HeaderFilename));
99 if (FileMgr->
getFile(AltHeaderFilename))
109 std::make_unique<ModuleDependencyListener>(*
this, R.
getFileManager()));
116 std::make_unique<ModuleDependencyMMCallbacks>(*
this));
122 if (llvm::sys::fs::real_path(Path, TmpDest))
132 if (!llvm::sys::fs::real_path(UpperDest, RealDest) && Path.equals(RealDest))
145 VFSWriter.setOverlayDir(VFSDir);
153 VFSWriter.setUseExternalNames(
false);
157 llvm::sys::path::append(YAMLPath,
"vfs.yaml");
158 llvm::raw_fd_ostream OS(YAMLPath, EC, llvm::sys::fs::OF_TextWithCRLF);
166std::error_code ModuleDependencyCollector::copyToRoot(StringRef Src,
168 using namespace llvm::sys;
169 llvm::FileCollector::PathCanonicalizer::PathStorage Paths =
170 Canonicalizer.canonicalize(Src);
177 path::append(CacheDst, path::relative_path(Paths.CopyFrom));
181 if (!fs::exists(Dst))
182 return std::error_code();
183 path::append(CacheDst, Dst);
184 Paths.CopyFrom = Dst;
188 if (std::error_code EC = fs::create_directories(path::parent_path(CacheDst),
191 if (std::error_code EC = fs::copy_file(Paths.CopyFrom, CacheDst))
200 return std::error_code();
static bool isCaseSensitivePath(StringRef Path)
Defines the clang::Preprocessor interface.
Abstract interface for callback invocations by the ASTReader.
virtual bool needsInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the input files of the AST file via visitInpu...
virtual bool visitInputFile(StringRef Filename, bool isSystem, bool isOverridden, bool isExplicitModule)
if needsInputFileVisitation returns true, this is called for each non-system input file of the AST Fi...
virtual bool needsSystemInputFileVisitation()
Returns true if this ASTReaderListener wants to receive the system input files of the AST file via vi...
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
Represents a character-granular source range.
StringRef getName() const
Cached information about one file (either on disk or in the virtual file system).
const DirectoryEntry * getDir() const
Return the directory the file lives in.
StringRef getName() const
Implements support for file system lookup, file system caching, and directory search management.
OptionalFileEntryRef getOptionalFileRef(StringRef Filename, bool OpenFile=false, bool CacheFailure=true)
Get a FileEntryRef if it exists, without doing anything on error.
llvm::ErrorOr< const FileEntry * > getFile(StringRef Filename, bool OpenFile=false, bool CacheFailure=true)
Lookup, cache, and verify the specified file (real or virtual).
Record the location of an inclusion directive, such as an #include or #import statement.
Collects the dependencies for imported modules into a directory.
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 parser as it reads module map files.
virtual void moduleMapAddUmbrellaHeader(FileManager *FileMgr, const FileEntry *Header)
Called when an umbrella header is added during module map parsing.
virtual void moduleMapAddHeader(StringRef Filename)
Called when a header is added during module map parsing.
void addModuleMapCallbacks(std::unique_ptr< ModuleMapCallbacks > Callback)
Add a module map callback.
Describes a module or submodule.
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
Encodes a location in the source.
This class handles loading and caching of source files into memory.
Token - This structure provides full information about a lexed token.
CharacteristicKind
Indicates whether a file or directory holds normal user code, system code, or system code which is im...
@ C
Languages that the frontend can parse and compile.
LLVM_READONLY char toUppercase(char c)
Converts the given ASCII character to its uppercase equivalent.