clang 24.0.0git
InProcessModuleCache.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#ifndef LLVM_CLANG_DEPENDENCYSCANNING_INPROCESSMODULECACHE_H
10#define LLVM_CLANG_DEPENDENCYSCANNING_INPROCESSMODULECACHE_H
11
14#include "llvm/ADT/StringMap.h"
15#include "llvm/ADT/StringSet.h"
16
17#include <atomic>
18#include <condition_variable>
19#include <memory>
20#include <mutex>
21#include <optional>
22
23namespace llvm {
24class MemoryBuffer;
25} // namespace llvm
26
27namespace clang {
28namespace dependencies {
29
31 std::mutex Mutex;
32 std::condition_variable CondVar;
33 bool Locked = false;
34 unsigned Generation = 0;
35
36 std::atomic<std::time_t> Timestamp = 0;
37
38 enum {
42 } State = S_Unknown;
43 /// The buffer we've read from disk, if any.
44 std::unique_ptr<llvm::MemoryBuffer> ReadBuffer;
45 /// The buffer we've written to module cache, if any.
46 std::unique_ptr<llvm::MemoryBuffer> WrittenBuffer;
47 /// The modification time of the entry.
48 time_t ModTime = 0;
49};
50
52 std::mutex Mutex;
53 llvm::StringMap<std::unique_ptr<ModuleCacheEntry>> Map;
54
56
57 void addInvalidatedPath(StringRef Path);
58 std::optional<bool> isDirectoryInvalidated(StringRef Directory) const;
59
60 /// Flushes all PCMs built in-process to disk.
61 void flush();
62
63private:
64 mutable std::mutex InvalidatedPathsMutex;
65 llvm::StringSet<> InvalidatedPaths;
66 std::atomic<bool> AnyInvalidatedPaths = false;
67};
68
69std::shared_ptr<ModuleCache>
71
72} // namespace dependencies
73} // namespace clang
74
75#endif // LLVM_CLANG_DEPENDENCYSCANNING_INPROCESSMODULECACHE_H
Defines a logger where each line is written atomically to the file.
std::shared_ptr< ModuleCache > makeInProcessModuleCache(ModuleCacheEntries &Entries, AtomicLineLogger &Logger)
Top level wrappers for InstallAPI frontend operations.
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
llvm::StringMap< std::unique_ptr< ModuleCacheEntry > > Map
void flush()
Flushes all PCMs built in-process to disk.
std::optional< bool > isDirectoryInvalidated(StringRef Directory) const
time_t ModTime
The modification time of the entry.
std::unique_ptr< llvm::MemoryBuffer > WrittenBuffer
The buffer we've written to module cache, if any.
std::unique_ptr< llvm::MemoryBuffer > ReadBuffer
The buffer we've read from disk, if any.