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,
113 llvm::MemoryBuffer *MainFileBuffer)
const;
117 bool PreambleEndsAtStartOfLine,
118 llvm::StringMap<PreambleFileHash> FilesInPreamble);
128 static llvm::ErrorOr<TempPCHFile> CreateNewPreamblePCHFile();
131 static llvm::ErrorOr<TempPCHFile> createInSystemTempDir(
const Twine &Prefix,
136 static llvm::ErrorOr<TempPCHFile> createFromCustomPath(
const Twine &Path);
139 TempPCHFile(std::string FilePath);
142 TempPCHFile(TempPCHFile &&Other);
143 TempPCHFile &operator=(TempPCHFile &&Other);
145 TempPCHFile(
const TempPCHFile &) =
delete;
149 llvm::StringRef getFilePath()
const;
152 void RemoveFileIfPresent();
158 class InMemoryPreamble {
165 enum class Kind { Empty, InMemory, TempFile };
167 PCHStorage() =
default;
168 PCHStorage(TempPCHFile File);
169 PCHStorage(InMemoryPreamble Memory);
171 PCHStorage(
const PCHStorage &) =
delete;
172 PCHStorage &operator=(
const PCHStorage &) =
delete;
174 PCHStorage(PCHStorage &&Other);
175 PCHStorage &operator=(PCHStorage &&Other);
181 TempPCHFile &asFile();
182 const TempPCHFile &asFile()
const;
184 InMemoryPreamble &asMemory();
185 const InMemoryPreamble &asMemory()
const;
192 Kind StorageKind = Kind::Empty;
193 llvm::AlignedCharArrayUnion<TempPCHFile, InMemoryPreamble> Storage = {};
197 struct PreambleFileHash {
208 llvm::MD5::MD5Result MD5 = {};
210 static PreambleFileHash createForFile(off_t Size, time_t ModTime);
211 static PreambleFileHash
212 createForMemoryBuffer(
const llvm::MemoryBuffer *Buffer);
214 friend bool operator==(
const PreambleFileHash &LHS,
215 const PreambleFileHash &RHS) {
216 return LHS.Size == RHS.Size && LHS.ModTime == RHS.ModTime &&
219 friend bool operator!=(
const PreambleFileHash &LHS,
220 const PreambleFileHash &RHS) {
221 return !(LHS == RHS);
228 static void setupPreambleStorage(
const PCHStorage &Storage,
239 llvm::StringMap<PreambleFileHash> FilesInPreamble;
243 std::vector<char> PreambleBytes;
245 bool PreambleEndsAtStartOfLine;
264 virtual void AfterPCHEmitted(
ASTWriter &Writer);
271 virtual std::unique_ptr<PPCallbacks> createPPCallbacks();
285 const char *name()
const noexcept
override;
286 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)