clang-tools 20.0.0git
Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | List of all members
Modularize::ModularizeUtilities Class Reference

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 ModularizeUtilitiescreateModularizeUtilities (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.
 

Detailed Description

Modularize utilities class.

Support functions and data for modularize.

Definition at line 37 of file ModularizeUtilities.h.

Constructor & Destructor Documentation

◆ ModularizeUtilities()

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.

Parameters
InputPathsThe input file paths.
PrefixThe headear path prefix.
ProblemFilesListPathThe problem header list path.

Definition at line 43 of file ModularizeUtilities.cpp.

Member Function Documentation

◆ addNoCompileErrorsFile()

void ModularizeUtilities::addNoCompileErrorsFile ( std::string  FilePath)

Add file with no compile errors.

Also standardizes the path.

Parameters
FilePathProblem file path.

Definition at line 505 of file ModularizeUtilities.cpp.

References getCanonicalPath(), and GoodFileNames.

◆ addUniqueProblemFile()

void ModularizeUtilities::addUniqueProblemFile ( std::string  FilePath)

Add unique problem file.

Also standardizes the path.

Parameters
FilePathProblem file path.

Definition at line 493 of file ModularizeUtilities.cpp.

References getCanonicalPath(), and ProblemFileNames.

◆ collectModuleHeaders()

bool ModularizeUtilities::collectModuleHeaders ( const clang::Module &  Mod)
protected

Collect referenced headers from one module.

Collects the headers referenced in the given module into HeaderFileNames.

Parameters
ModThe module reference.
Returns
True if no errors.

Definition at line 337 of file ModularizeUtilities.cpp.

References collectModuleHeaders(), collectUmbrellaHeaders(), getCanonicalPath(), HeaderFileNames, Loc, MissingHeaderCount, and SourceMgr.

Referenced by collectModuleHeaders(), and collectModuleMapHeaders().

◆ collectModuleMapHeaders()

bool ModularizeUtilities::collectModuleMapHeaders ( clang::ModuleMap *  ModMap)
protected

Collect module Map headers.

Walks the modules and collects referenced headers into HeaderFileNames.

Parameters
ModMapA loaded module map object.
Returns
True if no errors.

Definition at line 323 of file ModularizeUtilities.cpp.

References collectModuleHeaders(), and M.

Referenced by loadModuleMap().

◆ collectUmbrellaHeaders()

bool ModularizeUtilities::collectUmbrellaHeaders ( llvm::StringRef  UmbrellaDirName,
DependentsVector Dependents 
)
protected

Collect headers from an umbrella directory.

Parameters
UmbrellaDirNameThe umbrella directory name.
Returns
True if no errors.

Definition at line 400 of file ModularizeUtilities.cpp.

References collectUmbrellaHeaders(), Directory, E, getCanonicalPath(), isHeader(), and Type.

Referenced by collectModuleHeaders(), and collectUmbrellaHeaders().

◆ createModularizeUtilities()

ModularizeUtilities * ModularizeUtilities::createModularizeUtilities ( std::vector< std::string > &  InputPaths,
llvm::StringRef  Prefix,
llvm::StringRef  ProblemFilesListPath 
)
static

Create instance of ModularizeUtilities.

Parameters
InputPathsThe input file paths.
PrefixThe headear path prefix.
ProblemFilesListPathThe problem header list path.
Returns
Initialized ModularizeUtilities object.

Definition at line 65 of file ModularizeUtilities.cpp.

Referenced by main().

◆ displayCombinedFiles()

void ModularizeUtilities::displayCombinedFiles ( )

List files with problem files commented out.

Definition at line 535 of file ModularizeUtilities.cpp.

References HeaderFileNames, and ProblemFileNames.

◆ displayGoodFiles()

void ModularizeUtilities::displayGoodFiles ( )

List files with no problems.

Definition at line 519 of file ModularizeUtilities.cpp.

References HeaderFileNames, and ProblemFileNames.

◆ displayProblemFiles()

void ModularizeUtilities::displayProblemFiles ( )

List problem files.

Definition at line 511 of file ModularizeUtilities.cpp.

References ProblemFileNames.

◆ doCoverageCheck()

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.

Parameters
IncludePathsThe 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.)
CommandLineCompile command line arguments.
Returns
0 if there were no errors or warnings, 1 if there were warnings, 2 if any other problem, such as a bad module map path argument was specified.

Definition at line 113 of file ModularizeUtilities.cpp.

References CommandLine, Modularize::CoverageChecker::createCoverageChecker(), IncludePaths(), InputFilePaths, and ModuleMaps.

◆ getCanonicalPath()

std::string ModularizeUtilities::getCanonicalPath ( llvm::StringRef  FilePath)
static

Convert header path to canonical form.

The canonical form is basically just use forward slashes, and remove "./".

Parameters
FilePathThe file path.
Returns
The file path in canonical form.

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().

◆ getDirectoryFromPath()

std::string ModularizeUtilities::getDirectoryFromPath ( llvm::StringRef  Path)
static

Get directory path component from file path.

Returns
the component of the given path, which will be relative if the given path is relative, absolute if the given path is absolute, or "." if the path has no leading path component.

Definition at line 483 of file ModularizeUtilities.cpp.

References Directory, and Path.

Referenced by Modularize::CoverageChecker::collectFileSystemHeaders().

◆ isHeader()

bool ModularizeUtilities::isHeader ( llvm::StringRef  FileName)
static

Check for header file extension.

If the file extension is .h, .inc, or missing, it's assumed to be a header.

Parameters
FileNameThe file name. Must not be a directory.
Returns
true if it has a header extension or no extension.

Definition at line 467 of file ModularizeUtilities.cpp.

References FileName.

Referenced by Modularize::CoverageChecker::collectUmbrellaHeaders(), and collectUmbrellaHeaders().

◆ loadAllHeaderListsAndDependencies()

std::error_code ModularizeUtilities::loadAllHeaderListsAndDependencies ( )

Load header list and dependencies.

Returns
std::error_code.

Definition at line 73 of file ModularizeUtilities.cpp.

References E, InputFilePaths, loadModuleMap(), loadProblemHeaderList(), loadSingleHeaderListsAndDependencies(), and ProblemFilesPath.

◆ loadModuleMap()

std::error_code ModularizeUtilities::loadModuleMap ( llvm::StringRef  InputPath)
protected

Load single module map and extract header file list.

Parameters
InputPathThe input file path.
Returns
std::error_code.

Definition at line 257 of file ModularizeUtilities.cpp.

References collectModuleMapHeaders(), DC, Diagnostics, FileMgr, HasModuleMap, HeaderInfo, LangOpts, MissingHeaderCount, ModuleMaps, SourceMgr, and Target.

Referenced by loadAllHeaderListsAndDependencies().

◆ loadProblemHeaderList()

std::error_code ModularizeUtilities::loadProblemHeaderList ( llvm::StringRef  InputPath)
protected

Load problem header list.

Parameters
InputPathThe input file path.
Returns
std::error_code.

Definition at line 205 of file ModularizeUtilities.cpp.

References E, getCanonicalPath(), HeaderPrefix, Line, ProblemFileNames, and Strings.

Referenced by loadAllHeaderListsAndDependencies().

◆ loadSingleHeaderListsAndDependencies()

std::error_code ModularizeUtilities::loadSingleHeaderListsAndDependencies ( llvm::StringRef  InputPath)
protected

Load single header list and dependencies.

Parameters
InputPathThe input file path.
Returns
std::error_code.

Definition at line 132 of file ModularizeUtilities.cpp.

References Dependencies, E, getCanonicalPath(), HeaderFileNames, HeaderPrefix, Line, and Strings.

Referenced by loadAllHeaderListsAndDependencies().

Member Data Documentation

◆ DC

clang::TextDiagnosticPrinter Modularize::ModularizeUtilities::DC

Diagnostic consumer.

Definition at line 203 of file ModularizeUtilities.h.

Referenced by loadModuleMap().

◆ Dependencies

DependencyMap Modularize::ModularizeUtilities::Dependencies

Map of top-level header file dependencies.

Definition at line 53 of file ModularizeUtilities.h.

Referenced by loadSingleHeaderListsAndDependencies().

◆ DiagIDs

const llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> Modularize::ModularizeUtilities::DiagIDs

Diagnostic IDs.

Definition at line 199 of file ModularizeUtilities.h.

◆ DiagnosticOpts

llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> Modularize::ModularizeUtilities::DiagnosticOpts

Options controlling the diagnostic engine.

Definition at line 201 of file ModularizeUtilities.h.

◆ Diagnostics

llvm::IntrusiveRefCntPtr<clang::DiagnosticsEngine> Modularize::ModularizeUtilities::Diagnostics

Diagnostic engine.

Definition at line 205 of file ModularizeUtilities.h.

Referenced by loadModuleMap().

◆ FileMgr

llvm::IntrusiveRefCntPtr<clang::FileManager> Modularize::ModularizeUtilities::FileMgr

File system manager.

Definition at line 213 of file ModularizeUtilities.h.

Referenced by loadModuleMap().

◆ FileSystemOpts

clang::FileSystemOptions Modularize::ModularizeUtilities::FileSystemOpts

Options controlling the file system manager.

Definition at line 211 of file ModularizeUtilities.h.

◆ GoodFileNames

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().

◆ HasModuleMap

bool Modularize::ModularizeUtilities::HasModuleMap

True if we have module maps.

Definition at line 55 of file ModularizeUtilities.h.

Referenced by loadModuleMap().

◆ HeaderFileNames

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().

◆ HeaderInfo

std::unique_ptr<clang::HeaderSearch> Modularize::ModularizeUtilities::HeaderInfo

Header search manager.

Definition at line 217 of file ModularizeUtilities.h.

Referenced by loadModuleMap().

◆ HeaderPrefix

llvm::StringRef Modularize::ModularizeUtilities::HeaderPrefix

The header prefix.

Definition at line 44 of file ModularizeUtilities.h.

Referenced by loadProblemHeaderList(), and loadSingleHeaderListsAndDependencies().

◆ InputFilePaths

std::vector<std::string> Modularize::ModularizeUtilities::InputFilePaths

The input file paths.

Definition at line 42 of file ModularizeUtilities.h.

Referenced by doCoverageCheck(), and loadAllHeaderListsAndDependencies().

◆ LangOpts

std::shared_ptr<clang::LangOptions> Modularize::ModularizeUtilities::LangOpts

Options controlling the language variant.

Definition at line 197 of file ModularizeUtilities.h.

Referenced by loadModuleMap().

◆ MissingHeaderCount

int Modularize::ModularizeUtilities::MissingHeaderCount

Missing header count.

Definition at line 57 of file ModularizeUtilities.h.

Referenced by collectModuleHeaders(), and loadModuleMap().

◆ ModuleMaps

std::vector<std::unique_ptr<clang::ModuleMap> > Modularize::ModularizeUtilities::ModuleMaps

Definition at line 219 of file ModularizeUtilities.h.

Referenced by doCoverageCheck(), and loadModuleMap().

◆ ProblemFileNames

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().

◆ ProblemFilesPath

llvm::StringRef Modularize::ModularizeUtilities::ProblemFilesPath

The path of problem files list file.

Definition at line 46 of file ModularizeUtilities.h.

Referenced by loadAllHeaderListsAndDependencies().

◆ SourceMgr

llvm::IntrusiveRefCntPtr<clang::SourceManager> Modularize::ModularizeUtilities::SourceMgr

Source manager.

Definition at line 215 of file ModularizeUtilities.h.

Referenced by collectModuleHeaders(), and loadModuleMap().

◆ Target

llvm::IntrusiveRefCntPtr<clang::TargetInfo> Modularize::ModularizeUtilities::Target

Target information.

Definition at line 209 of file ModularizeUtilities.h.

Referenced by loadModuleMap().

◆ TargetOpts

std::shared_ptr<clang::TargetOptions> Modularize::ModularizeUtilities::TargetOpts

Options controlling the target.

Definition at line 207 of file ModularizeUtilities.h.


The documentation for this class was generated from the following files: