clang-tools  9.0.0svn
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>

Collaboration diagram for Modularize::ModularizeUtilities:
Collaboration graph
[legend]

Public Member Functions

 ModularizeUtilities (std::vector< std::string > &InputPaths, llvm::StringRef Prefix, llvm::StringRef ProblemFilesListPath)
 Constructor. More...
 
std::error_code loadAllHeaderListsAndDependencies ()
 Load header list and dependencies. More...
 
std::error_code doCoverageCheck (std::vector< std::string > &IncludePaths, llvm::ArrayRef< std::string > CommandLine)
 Do coverage checks. More...
 
void addUniqueProblemFile (std::string FilePath)
 Add unique problem file. More...
 
void addNoCompileErrorsFile (std::string FilePath)
 Add file with no compile errors. More...
 
void displayProblemFiles ()
 List problem files. More...
 
void displayGoodFiles ()
 List files with no problems. More...
 
void displayCombinedFiles ()
 List files with problem files commented out. More...
 

Static Public Member Functions

static ModularizeUtilitiescreateModularizeUtilities (std::vector< std::string > &InputPaths, llvm::StringRef Prefix, llvm::StringRef ProblemFilesListPath)
 Create instance of ModularizeUtilities. More...
 
static std::string getCanonicalPath (llvm::StringRef FilePath)
 Convert header path to canonical form. More...
 
static bool isHeader (llvm::StringRef FileName)
 Check for header file extension. More...
 
static std::string getDirectoryFromPath (llvm::StringRef Path)
 Get directory path component from file path. More...
 

Public Attributes

std::vector< std::string > InputFilePaths
 The input file paths. More...
 
llvm::StringRef HeaderPrefix
 The header prefix. More...
 
llvm::StringRef ProblemFilesPath
 The path of problem files list file. More...
 
llvm::SmallVector< std::string, 32 > HeaderFileNames
 List of top-level header files. More...
 
DependencyMap Dependencies
 Map of top-level header file dependencies. More...
 
bool HasModuleMap
 True if we have module maps. More...
 
int MissingHeaderCount
 Missing header count. More...
 
llvm::SmallVector< std::string, 32 > GoodFileNames
 List of header files with no problems during the first pass, that is, no compile errors. More...
 
llvm::SmallVector< std::string, 32 > ProblemFileNames
 List of header files with problems. More...
 
std::shared_ptr< clang::LangOptions > LangOpts
 Options controlling the language variant. More...
 
const llvm::IntrusiveRefCntPtr< clang::DiagnosticIDs > DiagIDs
 Diagnostic IDs. More...
 
llvm::IntrusiveRefCntPtr< clang::DiagnosticOptions > DiagnosticOpts
 Options controlling the diagnostic engine. More...
 
clang::TextDiagnosticPrinter DC
 Diagnostic consumer. More...
 
llvm::IntrusiveRefCntPtr< clang::DiagnosticsEngine > Diagnostics
 Diagnostic engine. More...
 
std::shared_ptr< clang::TargetOptions > TargetOpts
 Options controlling the target. More...
 
llvm::IntrusiveRefCntPtr< clang::TargetInfo > Target
 Target information. More...
 
clang::FileSystemOptions FileSystemOpts
 Options controlling the file system manager. More...
 
llvm::IntrusiveRefCntPtr< clang::FileManager > FileMgr
 File system manager. More...
 
llvm::IntrusiveRefCntPtr< clang::SourceManager > SourceMgr
 Source manager. More...
 
std::unique_ptr< clang::HeaderSearch > HeaderInfo
 Header search manager. More...
 
std::vector< std::unique_ptr< clang::ModuleMap > > ModuleMaps
 

Protected Member Functions

std::error_code loadSingleHeaderListsAndDependencies (llvm::StringRef InputPath)
 Load single header list and dependencies. More...
 
std::error_code loadProblemHeaderList (llvm::StringRef InputPath)
 Load problem header list. More...
 
std::error_code loadModuleMap (llvm::StringRef InputPath)
 Load single module map and extract header file list. More...
 
bool collectModuleMapHeaders (clang::ModuleMap *ModMap)
 Collect module Map headers. More...
 
bool collectModuleHeaders (const clang::Module &Mod)
 Collect referenced headers from one module. More...
 
bool collectUmbrellaHeaders (llvm::StringRef UmbrellaDirName, DependentsVector &Dependents)
 Collect headers from an umbrella directory. More...
 

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.

Referenced by createModularizeUtilities().

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 502 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 490 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 333 of file ModularizeUtilities.cpp.

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

Referenced by 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 320 of file ModularizeUtilities.cpp.

References collectModuleHeaders().

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 395 of file ModularizeUtilities.cpp.

References Directory().

Referenced by collectModuleHeaders().

◆ 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.

References ModularizeUtilities().

◆ displayCombinedFiles()

void ModularizeUtilities::displayCombinedFiles ( )

List files with problem files commented out.

Definition at line 532 of file ModularizeUtilities.cpp.

References HeaderFileNames, and ProblemFileNames.

◆ displayGoodFiles()

void ModularizeUtilities::displayGoodFiles ( )

List files with no problems.

Definition at line 516 of file ModularizeUtilities.cpp.

References HeaderFileNames, and ProblemFileNames.

◆ displayProblemFiles()

void ModularizeUtilities::displayProblemFiles ( )

List problem files.

Definition at line 508 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.map 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.map 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 114 of file ModularizeUtilities.cpp.

References Modularize::CoverageChecker::createCoverageChecker(), 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 450 of file ModularizeUtilities.cpp.

References clang::clangd::replace(), and replaceDotDot().

Referenced by addNoCompileErrorsFile(), addUniqueProblemFile(), Modularize::CoverageChecker::collectModuleHeaders(), collectModuleHeaders(), Modularize::CoverageChecker::collectUmbrellaHeaderHeader(), 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 480 of file ModularizeUtilities.cpp.

References Directory().

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 464 of file ModularizeUtilities.cpp.

◆ loadAllHeaderListsAndDependencies()

std::error_code ModularizeUtilities::loadAllHeaderListsAndDependencies ( )

Load header list and dependencies.

Returns
std::error_code.

Definition at line 73 of file ModularizeUtilities.cpp.

References 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 258 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 206 of file ModularizeUtilities.cpp.

References 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 133 of file ModularizeUtilities.cpp.

References Dependencies, getCanonicalPath(), HeaderFileNames, HeaderPrefix, Index, 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(), loadSingleHeaderListsAndDependencies(), and writeModuleMap().

◆ 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: