clang-tools 20.0.0git
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.
 
std::error_code doChecks ()
 Do checks.
 
void collectModuleHeaders ()
 Collect module headers.
 
bool collectModuleHeaders (const clang::Module &Mod)
 Collect referenced headers from one module.
 
bool collectUmbrellaHeaders (llvm::StringRef UmbrellaDirName)
 Collect headers from an umbrella directory.
 
bool collectUmbrellaHeaderHeaders (llvm::StringRef UmbrellaHeaderName)
 Collect headers referenced from an umbrella file.
 
void collectUmbrellaHeaderHeader (llvm::StringRef HeaderName)
 Called from CoverageCheckerCallbacks to track a header included from an umbrella header.
 
bool collectFileSystemHeaders ()
 Collect file system header files.
 
bool collectFileSystemHeaders (llvm::StringRef IncludePath)
 Collect file system header files from the given path.
 
void findUnaccountedForHeaders ()
 Find headers unaccounted-for in module map.
 

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.
 

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 38 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 145 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 318 of file CoverageChecker.cpp.

References collectFileSystemHeaders(), E, and Modularize::ModularizeUtilities::getDirectoryFromPath().

Referenced by collectFileSystemHeaders(), and 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 197 of file CoverageChecker.cpp.

References collectModuleHeaders(), and E.

Referenced by collectModuleHeaders(), and 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 298 of file CoverageChecker.cpp.

References Modularize::ModularizeUtilities::getCanonicalPath().

Referenced by CoverageCheckerCallbacks::InclusionDirective().

◆ collectUmbrellaHeaderHeaders()

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

Collect headers referenced from an umbrella file.

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

Definition at line 273 of file CoverageChecker.cpp.

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

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

Referenced by collectUmbrellaHeaders().

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

References CommandLine.

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

References E.

Referenced by doChecks().


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