clang-tools 20.0.0git
|
Modularize utilities class. More...
#include <ModularizeUtilities.h>
Public Member Functions | |
ModularizeUtilities (std::vector< std::string > &InputPaths, llvm::StringRef Prefix, llvm::StringRef ProblemFilesListPath) | |
Constructor. | |
std::error_code | loadAllHeaderListsAndDependencies () |
Load header list and dependencies. | |
std::error_code | doCoverageCheck (std::vector< std::string > &IncludePaths, llvm::ArrayRef< std::string > CommandLine) |
Do coverage checks. | |
void | addUniqueProblemFile (std::string FilePath) |
Add unique problem file. | |
void | addNoCompileErrorsFile (std::string FilePath) |
Add file with no compile errors. | |
void | displayProblemFiles () |
List problem files. | |
void | displayGoodFiles () |
List files with no problems. | |
void | displayCombinedFiles () |
List files with problem files commented out. | |
Static Public Member Functions | |
static ModularizeUtilities * | createModularizeUtilities (std::vector< std::string > &InputPaths, llvm::StringRef Prefix, llvm::StringRef ProblemFilesListPath) |
Create instance of ModularizeUtilities. | |
static std::string | getCanonicalPath (llvm::StringRef FilePath) |
Convert header path to canonical form. | |
static bool | isHeader (llvm::StringRef FileName) |
Check for header file extension. | |
static std::string | getDirectoryFromPath (llvm::StringRef Path) |
Get directory path component from file path. | |
Public Attributes | |
std::vector< std::string > | InputFilePaths |
The input file paths. | |
llvm::StringRef | HeaderPrefix |
The header prefix. | |
llvm::StringRef | ProblemFilesPath |
The path of problem files list file. | |
llvm::SmallVector< std::string, 32 > | HeaderFileNames |
List of top-level header files. | |
DependencyMap | Dependencies |
Map of top-level header file dependencies. | |
bool | HasModuleMap |
True if we have module maps. | |
int | MissingHeaderCount |
Missing header count. | |
llvm::SmallVector< std::string, 32 > | GoodFileNames |
List of header files with no problems during the first pass, that is, no compile errors. | |
llvm::SmallVector< std::string, 32 > | ProblemFileNames |
List of header files with problems. | |
std::shared_ptr< clang::LangOptions > | LangOpts |
Options controlling the language variant. | |
const llvm::IntrusiveRefCntPtr< clang::DiagnosticIDs > | DiagIDs |
Diagnostic IDs. | |
llvm::IntrusiveRefCntPtr< clang::DiagnosticOptions > | DiagnosticOpts |
Options controlling the diagnostic engine. | |
clang::TextDiagnosticPrinter | DC |
Diagnostic consumer. | |
llvm::IntrusiveRefCntPtr< clang::DiagnosticsEngine > | Diagnostics |
Diagnostic engine. | |
std::shared_ptr< clang::TargetOptions > | TargetOpts |
Options controlling the target. | |
llvm::IntrusiveRefCntPtr< clang::TargetInfo > | Target |
Target information. | |
clang::FileSystemOptions | FileSystemOpts |
Options controlling the file system manager. | |
llvm::IntrusiveRefCntPtr< clang::FileManager > | FileMgr |
File system manager. | |
llvm::IntrusiveRefCntPtr< clang::SourceManager > | SourceMgr |
Source manager. | |
std::unique_ptr< clang::HeaderSearch > | HeaderInfo |
Header search manager. | |
std::vector< std::unique_ptr< clang::ModuleMap > > | ModuleMaps |
Protected Member Functions | |
std::error_code | loadSingleHeaderListsAndDependencies (llvm::StringRef InputPath) |
Load single header list and dependencies. | |
std::error_code | loadProblemHeaderList (llvm::StringRef InputPath) |
Load problem header list. | |
std::error_code | loadModuleMap (llvm::StringRef InputPath) |
Load single module map and extract header file list. | |
bool | collectModuleMapHeaders (clang::ModuleMap *ModMap) |
Collect module Map headers. | |
bool | collectModuleHeaders (const clang::Module &Mod) |
Collect referenced headers from one module. | |
bool | collectUmbrellaHeaders (llvm::StringRef UmbrellaDirName, DependentsVector &Dependents) |
Collect headers from an umbrella directory. | |
Modularize utilities class.
Support functions and data for modularize.
Definition at line 37 of file ModularizeUtilities.h.
ModularizeUtilities::ModularizeUtilities | ( | std::vector< std::string > & | InputPaths, |
llvm::StringRef | Prefix, | ||
llvm::StringRef | ProblemFilesListPath | ||
) |
Constructor.
You can use the static createModularizeUtilities to create an instance of this object.
InputPaths | The input file paths. |
Prefix | The headear path prefix. |
ProblemFilesListPath | The problem header list path. |
Definition at line 43 of file ModularizeUtilities.cpp.
void ModularizeUtilities::addNoCompileErrorsFile | ( | std::string | FilePath | ) |
Add file with no compile errors.
Also standardizes the path.
FilePath | Problem file path. |
Definition at line 505 of file ModularizeUtilities.cpp.
References getCanonicalPath(), and GoodFileNames.
void ModularizeUtilities::addUniqueProblemFile | ( | std::string | FilePath | ) |
Add unique problem file.
Also standardizes the path.
FilePath | Problem file path. |
Definition at line 493 of file ModularizeUtilities.cpp.
References getCanonicalPath(), and ProblemFileNames.
|
protected |
Collect referenced headers from one module.
Collects the headers referenced in the given module into HeaderFileNames.
Mod | The module reference. |
Definition at line 337 of file ModularizeUtilities.cpp.
References collectModuleHeaders(), collectUmbrellaHeaders(), getCanonicalPath(), HeaderFileNames, Loc, MissingHeaderCount, and SourceMgr.
Referenced by collectModuleHeaders(), and collectModuleMapHeaders().
|
protected |
Collect module Map headers.
Walks the modules and collects referenced headers into HeaderFileNames.
ModMap | A loaded module map object. |
Definition at line 323 of file ModularizeUtilities.cpp.
References collectModuleHeaders(), and M.
Referenced by loadModuleMap().
|
protected |
Collect headers from an umbrella directory.
UmbrellaDirName | The umbrella directory name. |
Definition at line 400 of file ModularizeUtilities.cpp.
References collectUmbrellaHeaders(), Directory, E, getCanonicalPath(), isHeader(), and Type.
Referenced by collectModuleHeaders(), and collectUmbrellaHeaders().
|
static |
Create instance of ModularizeUtilities.
InputPaths | The input file paths. |
Prefix | The headear path prefix. |
ProblemFilesListPath | The problem header list path. |
Definition at line 65 of file ModularizeUtilities.cpp.
Referenced by main().
void ModularizeUtilities::displayCombinedFiles | ( | ) |
List files with problem files commented out.
Definition at line 535 of file ModularizeUtilities.cpp.
References HeaderFileNames, and ProblemFileNames.
void ModularizeUtilities::displayGoodFiles | ( | ) |
List files with no problems.
Definition at line 519 of file ModularizeUtilities.cpp.
References HeaderFileNames, and ProblemFileNames.
void ModularizeUtilities::displayProblemFiles | ( | ) |
List problem files.
Definition at line 511 of file ModularizeUtilities.cpp.
References ProblemFileNames.
std::error_code ModularizeUtilities::doCoverageCheck | ( | std::vector< std::string > & | IncludePaths, |
llvm::ArrayRef< std::string > | CommandLine | ||
) |
Do coverage checks.
For each loaded module map, do header coverage check. Starting from the directory of the module.modulemap file, Find all header files, optionally looking only at files covered by the include path options, and compare against the headers referenced by the module.modulemap file. Display warnings for unaccounted-for header files.
IncludePaths | The include paths to check for files. (Note that other directories above these paths are ignored. To expect all files to be accounted for from the module.modulemap file directory on down, leave this empty.) |
CommandLine | Compile command line arguments. |
Definition at line 113 of file ModularizeUtilities.cpp.
References CommandLine, Modularize::CoverageChecker::createCoverageChecker(), IncludePaths(), InputFilePaths, and ModuleMaps.
|
static |
Convert header path to canonical form.
The canonical form is basically just use forward slashes, and remove "./".
FilePath | The file path. |
Definition at line 453 of file ModularizeUtilities.cpp.
References replaceDotDot().
Referenced by addNoCompileErrorsFile(), addUniqueProblemFile(), collectModuleHeaders(), Modularize::CoverageChecker::collectUmbrellaHeaderHeader(), Modularize::CoverageChecker::collectUmbrellaHeaders(), collectUmbrellaHeaders(), findInputFile(), loadProblemHeaderList(), and loadSingleHeaderListsAndDependencies().
|
static |
Get directory path component from file path.
Definition at line 483 of file ModularizeUtilities.cpp.
References Directory, and Path.
Referenced by Modularize::CoverageChecker::collectFileSystemHeaders().
|
static |
Check for header file extension.
If the file extension is .h, .inc, or missing, it's assumed to be a header.
FileName | The file name. Must not be a directory. |
Definition at line 467 of file ModularizeUtilities.cpp.
References FileName.
Referenced by Modularize::CoverageChecker::collectUmbrellaHeaders(), and collectUmbrellaHeaders().
std::error_code ModularizeUtilities::loadAllHeaderListsAndDependencies | ( | ) |
Load header list and dependencies.
Definition at line 73 of file ModularizeUtilities.cpp.
References E, InputFilePaths, loadModuleMap(), loadProblemHeaderList(), loadSingleHeaderListsAndDependencies(), and ProblemFilesPath.
|
protected |
Load single module map and extract header file list.
InputPath | The input file path. |
Definition at line 257 of file ModularizeUtilities.cpp.
References collectModuleMapHeaders(), DC, Diagnostics, FileMgr, HasModuleMap, HeaderInfo, LangOpts, MissingHeaderCount, ModuleMaps, SourceMgr, and Target.
Referenced by loadAllHeaderListsAndDependencies().
|
protected |
Load problem header list.
InputPath | The input file path. |
Definition at line 205 of file ModularizeUtilities.cpp.
References E, getCanonicalPath(), HeaderPrefix, Line, ProblemFileNames, and Strings.
Referenced by loadAllHeaderListsAndDependencies().
|
protected |
Load single header list and dependencies.
InputPath | The input file path. |
Definition at line 132 of file ModularizeUtilities.cpp.
References Dependencies, E, getCanonicalPath(), HeaderFileNames, HeaderPrefix, Line, and Strings.
Referenced by loadAllHeaderListsAndDependencies().
clang::TextDiagnosticPrinter Modularize::ModularizeUtilities::DC |
Diagnostic consumer.
Definition at line 203 of file ModularizeUtilities.h.
Referenced by loadModuleMap().
DependencyMap Modularize::ModularizeUtilities::Dependencies |
Map of top-level header file dependencies.
Definition at line 53 of file ModularizeUtilities.h.
Referenced by loadSingleHeaderListsAndDependencies().
const llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> Modularize::ModularizeUtilities::DiagIDs |
Diagnostic IDs.
Definition at line 199 of file ModularizeUtilities.h.
llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> Modularize::ModularizeUtilities::DiagnosticOpts |
Options controlling the diagnostic engine.
Definition at line 201 of file ModularizeUtilities.h.
llvm::IntrusiveRefCntPtr<clang::DiagnosticsEngine> Modularize::ModularizeUtilities::Diagnostics |
Diagnostic engine.
Definition at line 205 of file ModularizeUtilities.h.
Referenced by loadModuleMap().
llvm::IntrusiveRefCntPtr<clang::FileManager> Modularize::ModularizeUtilities::FileMgr |
File system manager.
Definition at line 213 of file ModularizeUtilities.h.
Referenced by loadModuleMap().
clang::FileSystemOptions Modularize::ModularizeUtilities::FileSystemOpts |
Options controlling the file system manager.
Definition at line 211 of file ModularizeUtilities.h.
llvm::SmallVector<std::string, 32> Modularize::ModularizeUtilities::GoodFileNames |
List of header files with no problems during the first pass, that is, no compile errors.
Definition at line 60 of file ModularizeUtilities.h.
Referenced by addNoCompileErrorsFile().
bool Modularize::ModularizeUtilities::HasModuleMap |
True if we have module maps.
Definition at line 55 of file ModularizeUtilities.h.
Referenced by loadModuleMap().
llvm::SmallVector<std::string, 32> Modularize::ModularizeUtilities::HeaderFileNames |
List of top-level header files.
Definition at line 51 of file ModularizeUtilities.h.
Referenced by collectModuleHeaders(), displayCombinedFiles(), displayGoodFiles(), and loadSingleHeaderListsAndDependencies().
std::unique_ptr<clang::HeaderSearch> Modularize::ModularizeUtilities::HeaderInfo |
Header search manager.
Definition at line 217 of file ModularizeUtilities.h.
Referenced by loadModuleMap().
llvm::StringRef Modularize::ModularizeUtilities::HeaderPrefix |
The header prefix.
Definition at line 44 of file ModularizeUtilities.h.
Referenced by loadProblemHeaderList(), and loadSingleHeaderListsAndDependencies().
std::vector<std::string> Modularize::ModularizeUtilities::InputFilePaths |
The input file paths.
Definition at line 42 of file ModularizeUtilities.h.
Referenced by doCoverageCheck(), and loadAllHeaderListsAndDependencies().
std::shared_ptr<clang::LangOptions> Modularize::ModularizeUtilities::LangOpts |
Options controlling the language variant.
Definition at line 197 of file ModularizeUtilities.h.
Referenced by loadModuleMap().
int Modularize::ModularizeUtilities::MissingHeaderCount |
Missing header count.
Definition at line 57 of file ModularizeUtilities.h.
Referenced by collectModuleHeaders(), and loadModuleMap().
std::vector<std::unique_ptr<clang::ModuleMap> > Modularize::ModularizeUtilities::ModuleMaps |
Definition at line 219 of file ModularizeUtilities.h.
Referenced by doCoverageCheck(), and loadModuleMap().
llvm::SmallVector<std::string, 32> Modularize::ModularizeUtilities::ProblemFileNames |
List of header files with problems.
Definition at line 62 of file ModularizeUtilities.h.
Referenced by addUniqueProblemFile(), displayCombinedFiles(), displayGoodFiles(), displayProblemFiles(), and loadProblemHeaderList().
llvm::StringRef Modularize::ModularizeUtilities::ProblemFilesPath |
The path of problem files list file.
Definition at line 46 of file ModularizeUtilities.h.
Referenced by loadAllHeaderListsAndDependencies().
llvm::IntrusiveRefCntPtr<clang::SourceManager> Modularize::ModularizeUtilities::SourceMgr |
Source manager.
Definition at line 215 of file ModularizeUtilities.h.
Referenced by collectModuleHeaders(), and loadModuleMap().
llvm::IntrusiveRefCntPtr<clang::TargetInfo> Modularize::ModularizeUtilities::Target |
Target information.
Definition at line 209 of file ModularizeUtilities.h.
Referenced by loadModuleMap().
std::shared_ptr<clang::TargetOptions> Modularize::ModularizeUtilities::TargetOpts |
Options controlling the target.
Definition at line 207 of file ModularizeUtilities.h.