clang-tools  6.0.0svn
Public Member Functions | Static Public Member Functions | List of all members
Modularize::CoverageChecker Class Reference

Module map checker class. More...

#include <CoverageChecker.h>

Public Member Functions

 CoverageChecker (llvm::StringRef ModuleMapPath, std::vector< std::string > &IncludePaths, llvm::ArrayRef< std::string > CommandLine, clang::ModuleMap *ModuleMap)
 Constructor. More...
 
std::error_code doChecks ()
 Do checks. More...
 
void collectModuleHeaders ()
 Collect module headers. More...
 
bool collectModuleHeaders (const clang::Module &Mod)
 Collect referenced headers from one module. More...
 
bool collectUmbrellaHeaders (llvm::StringRef UmbrellaDirName)
 Collect headers from an umbrella directory. More...
 
bool collectUmbrellaHeaderHeaders (llvm::StringRef UmbrellaHeaderName)
 Collect headers rferenced from an umbrella file. More...
 
void collectUmbrellaHeaderHeader (llvm::StringRef HeaderName)
 Called from CoverageCheckerCallbacks to track a header included from an umbrella header. More...
 
bool collectFileSystemHeaders ()
 Collect file system header files. More...
 
bool collectFileSystemHeaders (llvm::StringRef IncludePath)
 Collect file system header files from the given path. More...
 
void findUnaccountedForHeaders ()
 Find headers unaccounted-for in module map. More...
 

Static Public Member Functions

static std::unique_ptr< CoverageCheckercreateCoverageChecker (llvm::StringRef ModuleMapPath, std::vector< std::string > &IncludePaths, llvm::ArrayRef< std::string > CommandLine, clang::ModuleMap *ModuleMap)
 Create instance of CoverageChecker. More...
 

Detailed Description

Module map checker class.

This is the heart of the checker. The doChecks function does the main work. The data members store the options and internally collected data.

Definition at line 39 of file CoverageChecker.h.

Constructor & Destructor Documentation

◆ CoverageChecker()

CoverageChecker::CoverageChecker ( llvm::StringRef  ModuleMapPath,
std::vector< std::string > &  IncludePaths,
llvm::ArrayRef< std::string >  CommandLine,
clang::ModuleMap *  ModuleMap 
)

Constructor.

You can use the static createCoverageChecker to create an instance of this object.

Parameters
ModuleMapPathThe module.modulemap file path. Can be relative or absolute.
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.
ModuleMapThe module map to check.

Definition at line 143 of file CoverageChecker.cpp.

Member Function Documentation

◆ collectFileSystemHeaders() [1/2]

bool CoverageChecker::collectFileSystemHeaders ( )

Collect file system header files.

This function scans the file system for header files, starting at the directory of the module.modulemap file, optionally filtering out all but the files covered by the include path options.

Returns
True if no errors.

Definition at line 316 of file CoverageChecker.cpp.

References Directory(), Modularize::ModularizeUtilities::getCanonicalPath(), Modularize::ModularizeUtilities::getDirectoryFromPath(), and Modularize::ModularizeUtilities::isHeader().

Referenced by doChecks().

◆ collectFileSystemHeaders() [2/2]

bool Modularize::CoverageChecker::collectFileSystemHeaders ( llvm::StringRef  IncludePath)

Collect file system header files from the given path.

This function scans the file system for header files, starting at the given directory, which is assumed to be relative to the directory of the module.modulemap file.

Returns
True if no errors.

◆ collectModuleHeaders() [1/2]

void CoverageChecker::collectModuleHeaders ( )

Collect module headers.

Walks the modules and collects referenced headers into ModuleMapHeadersSet.

Definition at line 195 of file CoverageChecker.cpp.

References collectUmbrellaHeaderHeaders(), collectUmbrellaHeaders(), and Modularize::ModularizeUtilities::getCanonicalPath().

Referenced by doChecks().

◆ collectModuleHeaders() [2/2]

bool Modularize::CoverageChecker::collectModuleHeaders ( const clang::Module &  Mod)

Collect referenced headers from one module.

Collects the headers referenced in the given module into ModuleMapHeadersSet.

Parameters
ModThe module reference.
Returns
True if no errors.

◆ collectUmbrellaHeaderHeader()

void CoverageChecker::collectUmbrellaHeaderHeader ( llvm::StringRef  HeaderName)

Called from CoverageCheckerCallbacks to track a header included from an umbrella header.

Parameters
HeaderNameThe header file path.

Definition at line 296 of file CoverageChecker.cpp.

References Modularize::ModularizeUtilities::getCanonicalPath().

◆ collectUmbrellaHeaderHeaders()

bool CoverageChecker::collectUmbrellaHeaderHeaders ( llvm::StringRef  UmbrellaHeaderName)

Collect headers rferenced from an umbrella file.

Parameters
UmbrellaHeaderNameThe umbrella file path.
Returns
True if no errors.

Definition at line 271 of file CoverageChecker.cpp.

Referenced by collectModuleHeaders().

◆ collectUmbrellaHeaders()

bool CoverageChecker::collectUmbrellaHeaders ( llvm::StringRef  UmbrellaDirName)

Collect headers from an umbrella directory.

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

Definition at line 236 of file CoverageChecker.cpp.

References Directory(), File, Modularize::ModularizeUtilities::getCanonicalPath(), and Modularize::ModularizeUtilities::isHeader().

Referenced by collectModuleHeaders().

◆ createCoverageChecker()

std::unique_ptr< CoverageChecker > CoverageChecker::createCoverageChecker ( llvm::StringRef  ModuleMapPath,
std::vector< std::string > &  IncludePaths,
llvm::ArrayRef< std::string >  CommandLine,
clang::ModuleMap *  ModuleMap 
)
static

Create instance of CoverageChecker.

Parameters
ModuleMapPathThe module.modulemap file path. Can be relative or absolute.
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.
ModuleMapThe module map to check.
Returns
Initialized CoverageChecker object.

Definition at line 153 of file CoverageChecker.cpp.

Referenced by Modularize::ModularizeUtilities::doCoverageCheck().

◆ doChecks()

std::error_code CoverageChecker::doChecks ( )

Do checks.

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.

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 170 of file CoverageChecker.cpp.

References collectFileSystemHeaders(), collectModuleHeaders(), and findUnaccountedForHeaders().

◆ findUnaccountedForHeaders()

void CoverageChecker::findUnaccountedForHeaders ( )

Find headers unaccounted-for in module map.

This function compares the list of collected header files against those referenced in the module map. Display warnings for unaccounted-for header files. Save unaccounted-for file list for possible. fixing action.

Definition at line 410 of file CoverageChecker.cpp.

Referenced by doChecks().


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