14 #ifndef LLVM_CLANG_FRONTEND_PRECOMPILED_PREAMBLE_H 15 #define LLVM_CLANG_FRONTEND_PRECOMPILED_PREAMBLE_H 19 #include "llvm/ADT/IntrusiveRefCntPtr.h" 20 #include "llvm/Support/AlignOf.h" 21 #include "llvm/Support/MD5.h" 24 #include <system_error> 25 #include <type_traits> 36 class CompilerInstance;
37 class CompilerInvocation;
39 class PCHContainerOperations;
43 llvm::MemoryBuffer *Buffer,
46 class PreambleCallbacks;
53 struct PreambleFileHash;
80 static llvm::ErrorOr<PrecompiledPreamble>
84 std::shared_ptr<PCHContainerOperations> PCHContainerOps,
114 llvm::MemoryBuffer *MainFileBuffer)
const;
121 llvm::MemoryBuffer *MainFileBuffer)
const;
125 bool PreambleEndsAtStartOfLine,
126 llvm::StringMap<PreambleFileHash> FilesInPreamble);
136 static llvm::ErrorOr<TempPCHFile> CreateNewPreamblePCHFile();
139 static llvm::ErrorOr<TempPCHFile> createInSystemTempDir(
const Twine &Prefix,
144 static llvm::ErrorOr<TempPCHFile> createFromCustomPath(
const Twine &Path);
147 TempPCHFile(std::string FilePath);
150 TempPCHFile(TempPCHFile &&Other);
151 TempPCHFile &operator=(TempPCHFile &&Other);
153 TempPCHFile(
const TempPCHFile &) =
delete;
157 llvm::StringRef getFilePath()
const;
160 void RemoveFileIfPresent();
166 class InMemoryPreamble {
173 enum class Kind { Empty, InMemory, TempFile };
175 PCHStorage() =
default;
176 PCHStorage(TempPCHFile File);
177 PCHStorage(InMemoryPreamble Memory);
179 PCHStorage(
const PCHStorage &) =
delete;
180 PCHStorage &operator=(
const PCHStorage &) =
delete;
182 PCHStorage(PCHStorage &&Other);
183 PCHStorage &operator=(PCHStorage &&Other);
189 TempPCHFile &asFile();
190 const TempPCHFile &asFile()
const;
192 InMemoryPreamble &asMemory();
193 const InMemoryPreamble &asMemory()
const;
200 Kind StorageKind = Kind::Empty;
201 llvm::AlignedCharArrayUnion<TempPCHFile, InMemoryPreamble> Storage = {};
205 struct PreambleFileHash {
216 llvm::MD5::MD5Result MD5 = {};
218 static PreambleFileHash createForFile(off_t Size, time_t ModTime);
219 static PreambleFileHash
220 createForMemoryBuffer(
const llvm::MemoryBuffer *Buffer);
222 friend bool operator==(
const PreambleFileHash &LHS,
223 const PreambleFileHash &RHS) {
224 return LHS.Size == RHS.Size && LHS.ModTime == RHS.ModTime &&
227 friend bool operator!=(
const PreambleFileHash &LHS,
228 const PreambleFileHash &RHS) {
229 return !(LHS == RHS);
237 llvm::MemoryBuffer *MainFileBuffer)
const;
242 static void setupPreambleStorage(
const PCHStorage &Storage,
253 llvm::StringMap<PreambleFileHash> FilesInPreamble;
257 std::vector<char> PreambleBytes;
259 bool PreambleEndsAtStartOfLine;
278 virtual void AfterPCHEmitted(
ASTWriter &Writer);
285 virtual std::unique_ptr<PPCallbacks> createPPCallbacks();
298 const char *name()
const noexcept
override;
299 std::string message(
int condition)
const override;
Describes the bounds (start, size) of the preamble and a flag required by PreprocessorOptions::Precom...
bool operator==(CanQual< T > x, CanQual< U > y)
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
DominatorTree GraphTraits specialization so the DominatorTree can be iterable by generic graph iterat...
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
The virtual file system interface.
std::error_code make_error_code(BuildPreambleError Error)
Concrete class used by the front-end to report problems and issues.
A set of callbacks to gather useful information while building a preamble.
Defines the clang::Preprocessor interface.
PreambleBounds ComputePreambleBounds(const LangOptions &LangOpts, llvm::MemoryBuffer *Buffer, unsigned MaxLines)
Runs lexer to compute suggested preamble bounds.
CompilerInstance - Helper class for managing a single instance of the Clang compiler.
Dataflow Directional Tag Classes.
A class holding a PCH and all information to check whether it is valid to reuse the PCH for the subse...
Helper class for holding the data necessary to invoke the compiler.
bool operator!=(CanQual< T > x, CanQual< U > y)
Writes an AST file containing the contents of a translation unit.
static Decl::Kind getKind(const Decl *D)