clang-tools  6.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 38 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 44 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 503 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 491 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 334 of file ModularizeUtilities.cpp.

References collectUmbrellaHeaders(), getCanonicalPath(), HeaderFileNames, 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 321 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 396 of file ModularizeUtilities.cpp.

References Directory(), File, getCanonicalPath(), and isHeader().

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

References ModularizeUtilities().

◆ displayCombinedFiles()

void ModularizeUtilities::displayCombinedFiles ( )

List files with problem files commented out.

Definition at line 533 of file ModularizeUtilities.cpp.

References File, HeaderFileNames, and ProblemFileNames.

◆ displayGoodFiles()

void ModularizeUtilities::displayGoodFiles ( )

List files with no problems.

Definition at line 517 of file ModularizeUtilities.cpp.

References HeaderFileNames, and ProblemFileNames.

◆ displayProblemFiles()

void ModularizeUtilities::displayProblemFiles ( )

List problem files.

Definition at line 509 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 115 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 451 of file ModularizeUtilities.cpp.

References replaceDotDot().

Referenced by addNoCompileErrorsFile(), addUniqueProblemFile(), Modularize::CoverageChecker::collectFileSystemHeaders(), Modularize::CoverageChecker::collectModuleHeaders(), collectModuleHeaders(), Modularize::CoverageChecker::collectUmbrellaHeaderHeader(), Modularize::CoverageChecker::collectUmbrellaHeaders(), and collectUmbrellaHeaders().

◆ 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 481 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 465 of file ModularizeUtilities.cpp.

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

◆ loadAllHeaderListsAndDependencies()

std::error_code ModularizeUtilities::loadAllHeaderListsAndDependencies ( )

Load header list and dependencies.

Returns
std::error_code.

Definition at line 74 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 259 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 207 of file ModularizeUtilities.cpp.

References HeaderPrefix.

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

References HeaderPrefix.

Referenced by loadAllHeaderListsAndDependencies().

Member Data Documentation

◆ DC

clang::TextDiagnosticPrinter Modularize::ModularizeUtilities::DC

Diagnostic consumer.

Definition at line 204 of file ModularizeUtilities.h.

Referenced by loadModuleMap().

◆ Dependencies

DependencyMap Modularize::ModularizeUtilities::Dependencies

Map of top-level header file dependencies.

Definition at line 54 of file ModularizeUtilities.h.

◆ DiagIDs

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

Diagnostic IDs.

Definition at line 200 of file ModularizeUtilities.h.

◆ DiagnosticOpts

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

Options controlling the diagnostic engine.

Definition at line 202 of file ModularizeUtilities.h.

◆ Diagnostics

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

Diagnostic engine.

Definition at line 206 of file ModularizeUtilities.h.

Referenced by loadModuleMap().

◆ FileMgr

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

File system manager.

Definition at line 214 of file ModularizeUtilities.h.

Referenced by loadModuleMap().

◆ FileSystemOpts

clang::FileSystemOptions Modularize::ModularizeUtilities::FileSystemOpts

Options controlling the file system manager.

Definition at line 212 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 61 of file ModularizeUtilities.h.

Referenced by addNoCompileErrorsFile().

◆ HasModuleMap

bool Modularize::ModularizeUtilities::HasModuleMap

True if we have module maps.

Definition at line 56 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 52 of file ModularizeUtilities.h.

Referenced by collectModuleHeaders(), displayCombinedFiles(), and displayGoodFiles().

◆ HeaderInfo

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

Header search manager.

Definition at line 218 of file ModularizeUtilities.h.

Referenced by loadModuleMap().

◆ HeaderPrefix

llvm::StringRef Modularize::ModularizeUtilities::HeaderPrefix

The header prefix.

Definition at line 45 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 43 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 198 of file ModularizeUtilities.h.

Referenced by loadModuleMap().

◆ MissingHeaderCount

int Modularize::ModularizeUtilities::MissingHeaderCount

Missing header count.

Definition at line 58 of file ModularizeUtilities.h.

Referenced by collectModuleHeaders(), and loadModuleMap().

◆ ModuleMaps

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

Definition at line 220 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 63 of file ModularizeUtilities.h.

Referenced by addUniqueProblemFile(), displayCombinedFiles(), displayGoodFiles(), and displayProblemFiles().

◆ ProblemFilesPath

llvm::StringRef Modularize::ModularizeUtilities::ProblemFilesPath

The path of problem files list file.

Definition at line 47 of file ModularizeUtilities.h.

Referenced by loadAllHeaderListsAndDependencies().

◆ SourceMgr

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

Source manager.

Definition at line 216 of file ModularizeUtilities.h.

Referenced by collectModuleHeaders(), and loadModuleMap().

◆ Target

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

Target information.

Definition at line 210 of file ModularizeUtilities.h.

Referenced by loadModuleMap().

◆ TargetOpts

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

Options controlling the target.

Definition at line 208 of file ModularizeUtilities.h.


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