16 using namespace clang;
17 using namespace tooling;
18 using namespace dependencies;
38 llvm::sys::path::remove_leading_dotslash(File->getName());
40 MDC.MainDeps.push_back(FileName);
46 StringRef SearchPath, StringRef RelativePath,
const Module *Imported,
48 if (!File && !Imported) {
51 MDC.MainDeps.push_back(FileName);
58 .ImportedByMainFile =
true;
67 for (
const Module *M : DirectDeps) {
68 handleTopLevelModule(M);
71 for (
auto &&I : MDC.Deps)
75 for (
auto &&I : MDC.MainDeps)
79 void ModuleDepCollectorPP::handleTopLevelModule(
const Module *M) {
82 auto ModI = MDC.Deps.insert(
85 if (!ModI.first->second.ModuleName.empty())
106 addAllSubmoduleDeps(M, MD);
109 void ModuleDepCollectorPP::addAllSubmoduleDeps(
const Module *M,
114 addAllSubmoduleDeps(SubM, MD);
128 : Instance(I), Consumer(C), ContextHash(I.getInvocation().getModuleHash()) {
132 PP.
addPPCallbacks(std::make_unique<ModuleDepCollectorPP>(Instance, *
this));
Module * getTopLevelModule()
Retrieve the top-level module for this (sub)module, which may be this module.
const FileEntry * getASTFile() const
The serialized AST file for this module, if one was created.
CharacteristicKind
Indicates whether a file or directory holds normal user code, system code, or system code which is im...
IntrusiveRefCntPtr< ASTReader > getASTReader() const
Optional< FileEntryRef > getFileEntryRefForID(FileID FID) const
Returns the FileEntryRef for the provided FileID.
Token - This structure provides full information about a lexed token.
Describes a module or submodule.
StringRef getTopLevelModuleName() const
Retrieve the name of the top-level module.
std::string getFullModuleName(bool AllowStringLiterals=false) const
Retrieve the full name of this module, including the path from its top-level module.
HeaderSearch & getHeaderSearchInfo() const
SourceLocation getExpansionLoc(SourceLocation Loc) const
Given a SourceLocation object Loc, return the expansion location referenced by the ID...
const FileEntry * getContainingModuleMapFile(const Module *Module) const
Retrieve the module map file containing the definition of the given module.
llvm::SmallSetVector< Module *, 2 > Imports
The set of modules imported by this module, and on which this module depends.
Represents a character-granular source range.
const FileEntry * getFileEntryForID(FileID FID) const
Returns the FileEntry record for the provided FileID.
Defines the clang::Preprocessor interface.
Information about a module that has been loaded by the ASTReader.
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
Encodes a location in the source.
StringRef getName() const
Cached information about one file (either on disk or in the virtual file system). ...
DependencyOutputOptions - Options for controlling the compiler dependency file generation.
An opaque identifier used by SourceManager which refers to a source file (MemoryBuffer) along with it...
Dataflow Directional Tag Classes.
llvm::iterator_range< submodule_iterator > submodules()
Reads an AST files chain containing the contents of a translation unit.
FileID getMainFileID() const
Returns the FileID of the main source file.
SourceManager & getSourceManager() const
Return the current source manager.
FileID getFileID(SourceLocation SpellingLoc) const
Return the FileID for a SourceLocation.
Preprocessor & getPreprocessor() const
Return the current preprocessor.
bool isSystem(CharacteristicKind CK)
Determine whether a file / directory characteristic is for system code.
void addPPCallbacks(std::unique_ptr< PPCallbacks > C)
This class handles loading and caching of source files into memory.
Engages in a tight little dance with the lexer to efficiently preprocess tokens.