2015-02-13 22:29:22 +08:00
|
|
|
//=====-- ModularizeUtilities.h - Utilities for modularize -*- C++ -*-======//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2015-02-13 22:29:22 +08:00
|
|
|
//
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
///
|
|
|
|
/// \file
|
Remove \brief commands from doxygen comments.
Summary:
We've been running doxygen with the autobrief option for a couple of
years now. This makes the \brief markers into our comments
redundant. Since they are a visual distraction and we don't want to
encourage more \brief markers in new code either, this patch removes
them all.
Patch produced by
for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done
[This is analogous to LLVM r331272 and CFE r331834]
Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D66578
llvm-svn: 369643
2019-08-22 19:32:57 +08:00
|
|
|
/// ModularizeUtilities class definition.
|
2015-02-13 22:29:22 +08:00
|
|
|
///
|
|
|
|
//===--------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef MODULARIZEUTILITIES_H
|
|
|
|
#define MODULARIZEUTILITIES_H
|
|
|
|
|
|
|
|
#include "Modularize.h"
|
2015-02-19 00:14:32 +08:00
|
|
|
#include "clang/Basic/Diagnostic.h"
|
|
|
|
#include "clang/Basic/FileManager.h"
|
|
|
|
#include "clang/Basic/LangOptions.h"
|
|
|
|
#include "clang/Basic/TargetInfo.h"
|
|
|
|
#include "clang/Basic/TargetOptions.h"
|
|
|
|
#include "clang/Frontend/TextDiagnosticPrinter.h"
|
|
|
|
#include "clang/Lex/HeaderSearch.h"
|
|
|
|
#include "clang/Lex/HeaderSearchOptions.h"
|
|
|
|
#include "clang/Lex/ModuleMap.h"
|
|
|
|
#include "clang/Lex/Preprocessor.h"
|
|
|
|
#include "llvm/ADT/SmallVector.h"
|
|
|
|
#include "llvm/ADT/StringSet.h"
|
2015-02-13 22:29:22 +08:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
namespace Modularize {
|
|
|
|
|
|
|
|
/// Modularize utilities class.
|
|
|
|
/// Support functions and data for modularize.
|
|
|
|
class ModularizeUtilities {
|
|
|
|
public:
|
|
|
|
// Input arguments.
|
|
|
|
|
|
|
|
/// The input file paths.
|
|
|
|
std::vector<std::string> InputFilePaths;
|
|
|
|
/// The header prefix.
|
|
|
|
llvm::StringRef HeaderPrefix;
|
2015-07-10 08:37:25 +08:00
|
|
|
/// The path of problem files list file.
|
|
|
|
llvm::StringRef ProblemFilesPath;
|
2015-02-13 22:29:22 +08:00
|
|
|
|
|
|
|
// Output data.
|
|
|
|
|
2015-02-19 00:14:32 +08:00
|
|
|
/// List of top-level header files.
|
2015-02-13 22:29:22 +08:00
|
|
|
llvm::SmallVector<std::string, 32> HeaderFileNames;
|
2015-02-19 00:14:32 +08:00
|
|
|
/// Map of top-level header file dependencies.
|
2015-02-13 22:29:22 +08:00
|
|
|
DependencyMap Dependencies;
|
2015-02-20 00:47:27 +08:00
|
|
|
/// True if we have module maps.
|
|
|
|
bool HasModuleMap;
|
2015-06-05 07:35:19 +08:00
|
|
|
/// Missing header count.
|
|
|
|
int MissingHeaderCount;
|
2015-07-10 08:37:25 +08:00
|
|
|
/// List of header files with no problems during the first pass,
|
|
|
|
/// that is, no compile errors.
|
|
|
|
llvm::SmallVector<std::string, 32> GoodFileNames;
|
|
|
|
/// List of header files with problems.
|
|
|
|
llvm::SmallVector<std::string, 32> ProblemFileNames;
|
2015-02-13 22:29:22 +08:00
|
|
|
|
|
|
|
// Functions.
|
|
|
|
|
|
|
|
/// Constructor.
|
|
|
|
/// You can use the static createModularizeUtilities to create an instance
|
|
|
|
/// of this object.
|
|
|
|
/// \param InputPaths The input file paths.
|
|
|
|
/// \param Prefix The headear path prefix.
|
2015-07-10 08:37:25 +08:00
|
|
|
/// \param ProblemFilesListPath The problem header list path.
|
2015-02-13 22:29:22 +08:00
|
|
|
ModularizeUtilities(std::vector<std::string> &InputPaths,
|
2015-07-10 08:37:25 +08:00
|
|
|
llvm::StringRef Prefix,
|
|
|
|
llvm::StringRef ProblemFilesListPath);
|
2015-02-13 22:29:22 +08:00
|
|
|
|
|
|
|
/// Create instance of ModularizeUtilities.
|
|
|
|
/// \param InputPaths The input file paths.
|
|
|
|
/// \param Prefix The headear path prefix.
|
2015-07-10 08:37:25 +08:00
|
|
|
/// \param ProblemFilesListPath The problem header list path.
|
2015-02-13 22:29:22 +08:00
|
|
|
/// \returns Initialized ModularizeUtilities object.
|
|
|
|
static ModularizeUtilities *createModularizeUtilities(
|
|
|
|
std::vector<std::string> &InputPaths,
|
2015-07-10 08:37:25 +08:00
|
|
|
llvm::StringRef Prefix,
|
|
|
|
llvm::StringRef ProblemFilesListPath);
|
2015-02-13 22:29:22 +08:00
|
|
|
|
|
|
|
/// Load header list and dependencies.
|
|
|
|
/// \returns std::error_code.
|
|
|
|
std::error_code loadAllHeaderListsAndDependencies();
|
|
|
|
|
2015-02-20 00:47:27 +08:00
|
|
|
/// 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.
|
|
|
|
/// \param 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.)
|
|
|
|
/// \param 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.
|
|
|
|
std::error_code doCoverageCheck(std::vector<std::string> &IncludePaths,
|
|
|
|
llvm::ArrayRef<std::string> CommandLine);
|
|
|
|
|
2015-07-10 08:37:25 +08:00
|
|
|
/// Add unique problem file.
|
|
|
|
/// Also standardizes the path.
|
|
|
|
/// \param FilePath Problem file path.
|
|
|
|
void addUniqueProblemFile(std::string FilePath);
|
|
|
|
|
|
|
|
/// Add file with no compile errors.
|
|
|
|
/// Also standardizes the path.
|
|
|
|
/// \param FilePath Problem file path.
|
|
|
|
void addNoCompileErrorsFile(std::string FilePath);
|
|
|
|
|
|
|
|
/// List problem files.
|
|
|
|
void displayProblemFiles();
|
|
|
|
|
|
|
|
/// List files with no problems.
|
|
|
|
void displayGoodFiles();
|
|
|
|
|
|
|
|
/// List files with problem files commented out.
|
|
|
|
void displayCombinedFiles();
|
|
|
|
|
2015-02-19 00:14:32 +08:00
|
|
|
// Internal.
|
|
|
|
|
2015-02-13 22:29:22 +08:00
|
|
|
protected:
|
2015-02-19 00:14:32 +08:00
|
|
|
|
2015-02-13 22:29:22 +08:00
|
|
|
/// Load single header list and dependencies.
|
|
|
|
/// \param InputPath The input file path.
|
|
|
|
/// \returns std::error_code.
|
|
|
|
std::error_code loadSingleHeaderListsAndDependencies(
|
|
|
|
llvm::StringRef InputPath);
|
2015-02-18 04:43:47 +08:00
|
|
|
|
2015-07-10 08:37:25 +08:00
|
|
|
/// Load problem header list.
|
|
|
|
/// \param InputPath The input file path.
|
|
|
|
/// \returns std::error_code.
|
|
|
|
std::error_code loadProblemHeaderList(
|
|
|
|
llvm::StringRef InputPath);
|
|
|
|
|
2015-02-19 00:14:32 +08:00
|
|
|
/// Load single module map and extract header file list.
|
|
|
|
/// \param InputPath The input file path.
|
|
|
|
/// \returns std::error_code.
|
|
|
|
std::error_code loadModuleMap(
|
|
|
|
llvm::StringRef InputPath);
|
|
|
|
|
|
|
|
/// Collect module Map headers.
|
|
|
|
/// Walks the modules and collects referenced headers into
|
2015-02-19 22:31:48 +08:00
|
|
|
/// HeaderFileNames.
|
2015-02-19 00:14:32 +08:00
|
|
|
/// \param ModMap A loaded module map object.
|
|
|
|
/// \return True if no errors.
|
|
|
|
bool collectModuleMapHeaders(clang::ModuleMap *ModMap);
|
|
|
|
|
|
|
|
/// Collect referenced headers from one module.
|
|
|
|
/// Collects the headers referenced in the given module into
|
2015-02-19 22:31:48 +08:00
|
|
|
/// HeaderFileNames.
|
2015-02-19 00:14:32 +08:00
|
|
|
/// \param Mod The module reference.
|
|
|
|
/// \return True if no errors.
|
|
|
|
bool collectModuleHeaders(const clang::Module &Mod);
|
|
|
|
|
|
|
|
/// Collect headers from an umbrella directory.
|
|
|
|
/// \param UmbrellaDirName The umbrella directory name.
|
|
|
|
/// \return True if no errors.
|
|
|
|
bool collectUmbrellaHeaders(llvm::StringRef UmbrellaDirName,
|
|
|
|
DependentsVector &Dependents);
|
|
|
|
|
2015-02-18 04:43:47 +08:00
|
|
|
public:
|
|
|
|
|
|
|
|
// Utility functions.
|
|
|
|
|
|
|
|
/// Convert header path to canonical form.
|
|
|
|
/// The canonical form is basically just use forward slashes,
|
|
|
|
/// and remove "./".
|
|
|
|
/// \param FilePath The file path.
|
|
|
|
/// \returns The file path in canonical form.
|
|
|
|
static std::string getCanonicalPath(llvm::StringRef FilePath);
|
2015-02-19 00:14:32 +08:00
|
|
|
|
|
|
|
/// Check for header file extension.
|
|
|
|
/// If the file extension is .h, .inc, or missing, it's
|
|
|
|
/// assumed to be a header.
|
|
|
|
/// \param FileName The file name. Must not be a directory.
|
|
|
|
/// \returns true if it has a header extension or no extension.
|
|
|
|
static bool isHeader(llvm::StringRef FileName);
|
|
|
|
|
2015-02-20 00:47:27 +08:00
|
|
|
/// 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.
|
|
|
|
static std::string getDirectoryFromPath(llvm::StringRef Path);
|
|
|
|
|
2015-02-19 00:14:32 +08:00
|
|
|
// Internal data.
|
|
|
|
|
|
|
|
/// Options controlling the language variant.
|
|
|
|
std::shared_ptr<clang::LangOptions> LangOpts;
|
|
|
|
/// Diagnostic IDs.
|
|
|
|
const llvm::IntrusiveRefCntPtr<clang::DiagnosticIDs> DiagIDs;
|
|
|
|
/// Options controlling the diagnostic engine.
|
|
|
|
llvm::IntrusiveRefCntPtr<clang::DiagnosticOptions> DiagnosticOpts;
|
|
|
|
/// Diagnostic consumer.
|
|
|
|
clang::TextDiagnosticPrinter DC;
|
|
|
|
/// Diagnostic engine.
|
|
|
|
llvm::IntrusiveRefCntPtr<clang::DiagnosticsEngine> Diagnostics;
|
|
|
|
/// Options controlling the target.
|
|
|
|
std::shared_ptr<clang::TargetOptions> TargetOpts;
|
|
|
|
/// Target information.
|
|
|
|
llvm::IntrusiveRefCntPtr<clang::TargetInfo> Target;
|
|
|
|
/// Options controlling the file system manager.
|
|
|
|
clang::FileSystemOptions FileSystemOpts;
|
|
|
|
/// File system manager.
|
|
|
|
llvm::IntrusiveRefCntPtr<clang::FileManager> FileMgr;
|
|
|
|
/// Source manager.
|
|
|
|
llvm::IntrusiveRefCntPtr<clang::SourceManager> SourceMgr;
|
|
|
|
/// Header search manager.
|
|
|
|
std::unique_ptr<clang::HeaderSearch> HeaderInfo;
|
|
|
|
// The loaded module map objects.
|
|
|
|
std::vector<std::unique_ptr<clang::ModuleMap>> ModuleMaps;
|
2015-02-13 22:29:22 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // end namespace Modularize
|
|
|
|
|
|
|
|
#endif // MODULARIZEUTILITIES_H
|