clang 23.0.0git
ModulesDriver.h
Go to the documentation of this file.
1//===----------------------------------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file defines functionality to support driver managed builds for
11/// compilations which use Clang modules or standard C++20 named modules.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CLANG_DRIVER_MODULESDRIVER_H
16#define LLVM_CLANG_DRIVER_MODULESDRIVER_H
17
18#include "clang/Basic/LLVM.h"
19#include "clang/Driver/Types.h"
20#include "llvm/Support/Error.h"
21
22namespace llvm::vfs {
23class FileSystem;
24} // namespace llvm::vfs
25
26namespace clang {
28namespace driver {
29class Compilation;
30} // namespace driver
31} // namespace clang
32
34
35/// Emits diagnostics for arguments incompatible with -fmodules-driver.
36void diagnoseModulesDriverArgs(llvm::opt::DerivedArgList &DAL,
37 DiagnosticsEngine &Diags);
38
39/// The parsed Standard library module manifest.
41 struct Module {
43 std::vector<std::string> SystemIncludeDirs;
44 };
45
46 bool IsStdlib = false;
47 std::string LogicalName;
48 std::string SourcePath;
49 std::optional<LocalArguments> LocalArgs;
50 };
51
52 std::vector<Module> Modules;
53};
54
55/// Reads the Standard library module manifest at \p ManifestPath.
56///
57/// Assumes that all file paths specified in the manifest are relative to
58/// \p ManifestPath and converts them to absolute.
59///
60/// \returns The parsed manifest on success; otherwise, a \c llvm::FileError
61/// or \c llvm::json::ParseError.
63readStdModuleManifest(llvm::StringRef ManifestPath, llvm::vfs::FileSystem &VFS);
64
65/// Constructs compilation inputs for each module listed in the provided
66/// Standard library module manifest.
67///
68/// \param ManifestEntries All entries of the Standard library module manifest.
69/// \param C The Compilation being built.
70/// \param Inputs The input list to which the new module inputs are appended.
73 InputList &Inputs);
74
75/// Scans the compilation inputs for module dependencies and adjusts the
76/// compilation to build and supply those modules as required.
77///
78/// \param C The Compilation being built.
79/// \param ManifestEntries All entries of the Standard library module manifest.
82
83} // namespace clang::driver::modules
84
85#endif // LLVM_CLANG_DRIVER_MODULESDRIVER_H
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
Concrete class used by the front-end to report problems and issues.
Definition Diagnostic.h:233
Compilation - A set of tasks to perform for a single driver invocation.
Definition Compilation.h:45
void buildStdModuleManifestInputs(ArrayRef< StdModuleManifest::Module > ManifestEntries, Compilation &C, InputList &Inputs)
Constructs compilation inputs for each module listed in the provided Standard library module manifest...
void runModulesDriver(Compilation &C, ArrayRef< StdModuleManifest::Module > ManifestEntries)
Scans the compilation inputs for module dependencies and adjusts the compilation to build and supply ...
llvm::Expected< StdModuleManifest > readStdModuleManifest(llvm::StringRef ManifestPath, llvm::vfs::FileSystem &VFS)
Reads the Standard library module manifest at ManifestPath.
void diagnoseModulesDriverArgs(llvm::opt::DerivedArgList &DAL, DiagnosticsEngine &Diags)
Emits diagnostics for arguments incompatible with -fmodules-driver.
llvm::SmallVector< InputTy, 16 > InputList
A list of inputs and their types for the given arguments.
Definition Types.h:136
The JSON file list parser is used to communicate input to InstallAPI.
std::optional< LocalArguments > LocalArgs
The parsed Standard library module manifest.