clang-tools 3.8.0

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

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:
[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 ModularizeUtilities * | createModularizeUtilities (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...
llvm::IntrusiveRefCntPtr < clang::HeaderSearchOptions > | HeaderSearchOpts
| Options controlling the #include directive. 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 | ( | 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

  InputPaths | The input file paths.
  Prefix | The headear path prefix.
  ProblemFilesListPath | The problem header list path.

Definition at line 44 of file ModularizeUtilities.cpp.

Referenced by createModularizeUtilities().

## Member Function Documentation

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

Add file with no compile errors.

Also standardizes the path.

Parameters

  FilePath | Problem file path.

Definition at line 506 of file ModularizeUtilities.cpp.

References getCanonicalPath(), and GoodFileNames.

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

Add unique problem file.

Also standardizes the path.

Parameters

  FilePath | Problem file path.

Definition at line 494 of file ModularizeUtilities.cpp.

References getCanonicalPath(), and ProblemFileNames.

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

  Mod | The module reference.

Returns
  True if no errors.

Definition at line 337 of file ModularizeUtilities.cpp.

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

Referenced by collectModuleMapHeaders().

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

Collect module Map headers.

Walks the modules and collects referenced headers into HeaderFileNames.

Parameters

  ModMap | A loaded module map object.

Returns
  True if no errors.

Definition at line 324 of file ModularizeUtilities.cpp.

References collectModuleHeaders().

Referenced by loadModuleMap().

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

Collect headers from an umbrella directory.

Parameters

  UmbrellaDirName | The umbrella directory name.

Returns
  True if no errors.

Definition at line 400 of file ModularizeUtilities.cpp.

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

Referenced by collectModuleHeaders().

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

Create instance of ModularizeUtilities.

Parameters

  InputPaths | The input file paths.
  Prefix | The headear path prefix.
  ProblemFilesListPath | The problem header list path.

Returns
  Initialized ModularizeUtilities object.

Definition at line 69 of file ModularizeUtilities.cpp.

References ModularizeUtilities().

void ModularizeUtilities::displayCombinedFiles | ( |  | ) |

List files with problem files commented out.

Definition at line 536 of file ModularizeUtilities.cpp.

References File, HeaderFileNames, and ProblemFileNames.

void ModularizeUtilities::displayGoodFiles | ( |  | ) |

List files with no problems.

Definition at line 520 of file ModularizeUtilities.cpp.

References HeaderFileNames, and ProblemFileNames.

void ModularizeUtilities::displayProblemFiles | ( |  | ) |

List problem files.

Definition at line 512 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.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

  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.

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

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

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

  FilePath | The file path.

Returns
  The file path in canonical form.

Definition at line 454 of file ModularizeUtilities.cpp.

References replaceDotDot().

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

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

References Directory().

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

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

  FileName | The file name. Must not be a directory.

Returns
  true if it has a header extension or no extension.

Definition at line 468 of file ModularizeUtilities.cpp.

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

std::error_code ModularizeUtilities::loadAllHeaderListsAndDependencies | ( |  | ) |

Load header list and dependencies.

Returns
  std::error_code.

Definition at line 77 of file ModularizeUtilities.cpp.

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

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

Load single module map and extract header file list.

Parameters

  InputPath | The input file path.

Returns
  std::error_code.

Definition at line 262 of file ModularizeUtilities.cpp.

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

Referenced by loadAllHeaderListsAndDependencies().

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

Load problem header list.

Parameters

  InputPath | The input file path.

Returns
  std::error_code.

Definition at line 210 of file ModularizeUtilities.cpp.

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

Referenced by loadAllHeaderListsAndDependencies().

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

Load single header list and dependencies.

Parameters

  InputPath | The input file path.

Returns
  std::error_code.

Definition at line 137 of file ModularizeUtilities.cpp.

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

Referenced by loadAllHeaderListsAndDependencies().

## Member Data Documentation

clang::TextDiagnosticPrinter Modularize::ModularizeUtilities::DC

Diagnostic consumer.

Definition at line 204 of file ModularizeUtilities.h.

Referenced by loadModuleMap().

DependencyMap Modularize::ModularizeUtilities::Dependencies

Map of top-level header file dependencies.

Definition at line 54 of file ModularizeUtilities.h.

Referenced by loadSingleHeaderListsAndDependencies().

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

Diagnostic IDs.

Definition at line 200 of file ModularizeUtilities.h.

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

Options controlling the diagnostic engine.

Definition at line 202 of file ModularizeUtilities.h.

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

Diagnostic engine.

Definition at line 206 of file ModularizeUtilities.h.

Referenced by loadModuleMap().

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

File system manager.

Definition at line 214 of file ModularizeUtilities.h.

Referenced by loadModuleMap().

clang::FileSystemOptions Modularize::ModularizeUtilities::FileSystemOpts

Options controlling the file system manager.

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

Referenced by addNoCompileErrorsFile().

bool Modularize::ModularizeUtilities::HasModuleMap

True if we have module maps.

Definition at line 56 of file ModularizeUtilities.h.

Referenced by loadModuleMap().

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(), displayGoodFiles(), and loadSingleHeaderListsAndDependencies().

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

Header search manager.

Definition at line 220 of file ModularizeUtilities.h.

Referenced by loadModuleMap().

llvm::StringRef Modularize::ModularizeUtilities::HeaderPrefix

The header prefix.

Definition at line 45 of file ModularizeUtilities.h.

Referenced by loadProblemHeaderList(), and loadSingleHeaderListsAndDependencies().

llvm::IntrusiveRefCntPtr<clang::HeaderSearchOptions> Modularize::ModularizeUtilities::HeaderSearchOpts

Options controlling the #include directive.

Definition at line 218 of file ModularizeUtilities.h.

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

The input file paths.

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

Referenced by loadModuleMap().

int Modularize::ModularizeUtilities::MissingHeaderCount

Missing header count.

Definition at line 58 of file ModularizeUtilities.h.

Referenced by collectModuleHeaders(), and loadModuleMap().

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

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

Referenced by loadAllHeaderListsAndDependencies().

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

Source manager.

Definition at line 216 of file ModularizeUtilities.h.

Referenced by collectModuleHeaders(), and loadModuleMap().

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

Target information.

Definition at line 210 of file ModularizeUtilities.h.

Referenced by loadModuleMap().

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:

- ModularizeUtilities.h
- ModularizeUtilities.cpp