13 #ifndef LLVM_CLANG_FRONTEND_PRECOMPILED_PREAMBLE_H 14 #define LLVM_CLANG_FRONTEND_PRECOMPILED_PREAMBLE_H 18 #include "llvm/ADT/IntrusiveRefCntPtr.h" 19 #include "llvm/Support/AlignOf.h" 20 #include "llvm/Support/MD5.h" 23 #include <system_error> 24 #include <type_traits> 34 class CompilerInstance;
35 class CompilerInvocation;
37 class PCHContainerOperations;
41 llvm::MemoryBuffer *Buffer,
44 class PreambleCallbacks;
51 struct PreambleFileHash;
78 static llvm::ErrorOr<PrecompiledPreamble>
83 std::shared_ptr<PCHContainerOperations> PCHContainerOps,
101 llvm::vfs::FileSystem *VFS)
const;
113 llvm::MemoryBuffer *MainFileBuffer)
const;
120 llvm::MemoryBuffer *MainFileBuffer)
const;
124 bool PreambleEndsAtStartOfLine,
125 llvm::StringMap<PreambleFileHash> FilesInPreamble);
135 static llvm::ErrorOr<TempPCHFile> CreateNewPreamblePCHFile();
138 TempPCHFile(std::string FilePath);
141 TempPCHFile(TempPCHFile &&Other);
142 TempPCHFile &operator=(TempPCHFile &&Other);
144 TempPCHFile(
const TempPCHFile &) =
delete;
148 llvm::StringRef getFilePath()
const;
151 void RemoveFileIfPresent();
157 class InMemoryPreamble {
164 enum class Kind { Empty, InMemory, TempFile };
166 PCHStorage() =
default;
167 PCHStorage(TempPCHFile File);
168 PCHStorage(InMemoryPreamble Memory);
170 PCHStorage(
const PCHStorage &) =
delete;
171 PCHStorage &operator=(
const PCHStorage &) =
delete;
173 PCHStorage(PCHStorage &&Other);
174 PCHStorage &operator=(PCHStorage &&Other);
180 TempPCHFile &asFile();
181 const TempPCHFile &asFile()
const;
183 InMemoryPreamble &asMemory();
184 const InMemoryPreamble &asMemory()
const;
191 Kind StorageKind = Kind::Empty;
192 llvm::AlignedCharArrayUnion<TempPCHFile, InMemoryPreamble> Storage = {};
196 struct PreambleFileHash {
207 llvm::MD5::MD5Result MD5 = {};
209 static PreambleFileHash createForFile(off_t Size, time_t ModTime);
210 static PreambleFileHash
211 createForMemoryBuffer(
const llvm::MemoryBuffer *Buffer);
213 friend bool operator==(
const PreambleFileHash &LHS,
214 const PreambleFileHash &RHS) {
215 return LHS.Size == RHS.Size && LHS.ModTime == RHS.ModTime &&
218 friend bool operator!=(
const PreambleFileHash &LHS,
219 const PreambleFileHash &RHS) {
220 return !(LHS == RHS);
228 llvm::MemoryBuffer *MainFileBuffer)
const;
234 setupPreambleStorage(
const PCHStorage &Storage,
245 llvm::StringMap<PreambleFileHash> FilesInPreamble;
249 std::vector<char> PreambleBytes;
251 bool PreambleEndsAtStartOfLine;
270 virtual void AfterPCHEmitted(
ASTWriter &Writer);
277 virtual std::unique_ptr<PPCallbacks> createPPCallbacks();
292 const char *
name()
const noexcept
override;
293 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)
Specialize PointerLikeTypeTraits to allow LazyGenerationalUpdatePtr to be placed into a PointerUnion...
PreprocessorOptions - This class is used for passing the various options used in preprocessor initial...
__SIZE_TYPE__ size_t
The unsigned integer type of the result of the sizeof operator.
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)