clang 23.0.0git
ModulesDriver.cpp File Reference

This file defines functionality to support driver managed builds for compilations which use Clang modules or standard C++20 named modules. More...

#include "clang/Driver/ModulesDriver.h"
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/LLVM.h"
#include "clang/Driver/Compilation.h"
#include "clang/Driver/Driver.h"
#include "clang/Driver/Job.h"
#include "clang/Driver/Tool.h"
#include "clang/Driver/ToolChain.h"
#include "llvm/Support/JSON.h"
#include "llvm/Support/Path.h"
#include "llvm/Support/PrettyStackTrace.h"
#include "llvm/Support/VirtualFileSystem.h"

Go to the source code of this file.

Namespaces

namespace  clang
 The JSON file list parser is used to communicate input to InstallAPI.
namespace  clang::driver
namespace  clang::driver::modules

Typedefs

using ManifestEntryLookup

Functions

static bool clang::driver::modules::fromJSON (const llvm::json::Value &Params, StdModuleManifest::Module::LocalArguments &LocalArgs, llvm::json::Path P)
static bool clang::driver::modules::fromJSON (const llvm::json::Value &Params, StdModuleManifest::Module &ModuleEntry, llvm::json::Path P)
static bool clang::driver::modules::fromJSON (const llvm::json::Value &Params, StdModuleManifest &Manifest, llvm::json::Path P)
static Expected< StdModuleManifestparseManifest (StringRef Buffer)
 Parses the Standard library module manifest from Buffer.
static void makeManifestPathsAbsolute (MutableArrayRef< StdModuleManifest::Module > ManifestEntries, StringRef ManifestPath)
 Converts each file path in manifest from relative to absolute.
static ManifestEntryLookup buildManifestLookupMap (ArrayRef< StdModuleManifest::Module > ManifestEntries)
 Builds a mapping from a module's source path to its entry in the manifest.
static const StdModuleManifest::ModulegetManifestEntryForCommand (const Command &Job, const ManifestEntryLookup &ManifestEntryBySource)
 Returns the manifest entry corresponding to Job, or nullptr if none exists.
static void addSystemIncludeDirsFromManifest (Compilation &C, Command &Job, ArgStringList &CC1Args, ArrayRef< std::string > SystemIncludeDirs)
 Adds all SystemIncludeDirs to the CC1Args of Job.
static bool isCC1Job (const Command &Job)
static void applyArgsForStdModuleManifestInputs (Compilation &C, const ManifestEntryLookup &ManifestEntryBySource, MutableArrayRef< std::unique_ptr< Command > > Jobs)
 Apply command-line modifications specific for inputs originating from the Standard library module manifest.

Detailed Description

This file defines functionality to support driver managed builds for compilations which use Clang modules or standard C++20 named modules.

Definition in file ModulesDriver.cpp.

Typedef Documentation

◆ ManifestEntryLookup

Initial value:
llvm::DenseMap<StringRef, const StdModuleManifest::Module *>

Definition at line 127 of file ModulesDriver.cpp.

Function Documentation

◆ addSystemIncludeDirsFromManifest()

void addSystemIncludeDirsFromManifest ( Compilation & C,
Command & Job,
ArgStringList & CC1Args,
ArrayRef< std::string > SystemIncludeDirs )
static

◆ applyArgsForStdModuleManifestInputs()

void applyArgsForStdModuleManifestInputs ( Compilation & C,
const ManifestEntryLookup & ManifestEntryBySource,
MutableArrayRef< std::unique_ptr< Command > > Jobs )
static

Apply command-line modifications specific for inputs originating from the Standard library module manifest.

Definition at line 176 of file ModulesDriver.cpp.

References addSystemIncludeDirsFromManifest(), clang::C, getManifestEntryForCommand(), and isCC1Job().

Referenced by clang::driver::modules::runModulesDriver().

◆ buildManifestLookupMap()

ManifestEntryLookup buildManifestLookupMap ( ArrayRef< StdModuleManifest::Module > ManifestEntries)
static

Builds a mapping from a module's source path to its entry in the manifest.

Definition at line 132 of file ModulesDriver.cpp.

Referenced by clang::driver::modules::runModulesDriver().

◆ getManifestEntryForCommand()

const StdModuleManifest::Module * getManifestEntryForCommand ( const Command & Job,
const ManifestEntryLookup & ManifestEntryBySource )
static

Returns the manifest entry corresponding to Job, or nullptr if none exists.

Definition at line 146 of file ModulesDriver.cpp.

References clang::driver::Command::getInputInfos().

Referenced by applyArgsForStdModuleManifestInputs().

◆ isCC1Job()

bool isCC1Job ( const Command & Job)
static

◆ makeManifestPathsAbsolute()

void makeManifestPathsAbsolute ( MutableArrayRef< StdModuleManifest::Module > ManifestEntries,
StringRef ManifestPath )
static

Converts each file path in manifest from relative to absolute.

Each file path in the manifest is expected to be relative the manifest's location ManifestPath itself.

Definition at line 77 of file ModulesDriver.cpp.

◆ parseManifest()

Expected< StdModuleManifest > parseManifest ( StringRef Buffer)
static

Parses the Standard library module manifest from Buffer.

Definition at line 60 of file ModulesDriver.cpp.

References clang::driver::modules::fromJSON().