clang
24.0.0git
include
clang
DependencyScanning
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
12
#include "
clang/Basic/AtomicLineLogger.h
"
13
#include "
clang/Serialization/ModuleCache.h
"
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
23
namespace
llvm
{
24
class
MemoryBuffer;
25
}
// namespace llvm
26
27
namespace
clang
{
28
namespace
dependencies
{
29
30
struct
ModuleCacheEntry
{
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
{
39
S_Unknown
,
40
S_Read
,
41
S_Written
,
42
} State =
S_Unknown
;
43
/// The buffer we've read from disk or written to the module cache, if any.
44
/// Buffers returned from \c ModuleCache::read() share ownership of this, so
45
/// it can be replaced while readers still reference the previous contents.
46
std::shared_ptr<const llvm::MemoryBuffer>
Buffer
;
47
/// The modification time of the entry.
48
time_t
ModTime
= 0;
49
};
50
51
struct
ModuleCacheEntries
{
52
std::mutex
Mutex
;
53
llvm::StringMap<std::unique_ptr<ModuleCacheEntry>>
Map
;
54
55
bool
ValidateAgainstInvalidatedPaths
=
false
;
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
63
private
:
64
mutable
std::mutex InvalidatedPathsMutex;
65
llvm::StringSet<> InvalidatedPaths;
66
std::atomic<bool> AnyInvalidatedPaths =
false
;
67
};
68
69
std::shared_ptr<ModuleCache>
70
makeInProcessModuleCache
(
ModuleCacheEntries
&Entries,
AtomicLineLogger
&Logger);
71
72
}
// namespace dependencies
73
}
// namespace clang
74
75
#endif
// LLVM_CLANG_DEPENDENCYSCANNING_INPROCESSMODULECACHE_H
AtomicLineLogger.h
Defines a logger where each line is written atomically to the file.
ModuleCache.h
clang::AtomicLineLogger
Definition
AtomicLineLogger.h:63
clang::dependencies
Definition
DependencyActionController.h:22
clang::dependencies::makeInProcessModuleCache
std::shared_ptr< ModuleCache > makeInProcessModuleCache(ModuleCacheEntries &Entries, AtomicLineLogger &Logger)
Definition
InProcessModuleCache.cpp:246
clang
Top level wrappers for InstallAPI frontend operations.
Definition
CalledOnceCheck.h:17
llvm
Diagnostic wrappers for TextAPI types for error reporting.
Definition
Dominators.h:30
clang::dependencies::ModuleCacheEntries
Definition
InProcessModuleCache.h:51
clang::dependencies::ModuleCacheEntries::Map
llvm::StringMap< std::unique_ptr< ModuleCacheEntry > > Map
Definition
InProcessModuleCache.h:53
clang::dependencies::ModuleCacheEntries::flush
void flush()
Flushes all PCMs built in-process to disk.
Definition
InProcessModuleCache.cpp:49
clang::dependencies::ModuleCacheEntries::isDirectoryInvalidated
std::optional< bool > isDirectoryInvalidated(StringRef Directory) const
Definition
InProcessModuleCache.cpp:40
clang::dependencies::ModuleCacheEntries::addInvalidatedPath
void addInvalidatedPath(StringRef Path)
Definition
InProcessModuleCache.cpp:25
clang::dependencies::ModuleCacheEntries::Mutex
std::mutex Mutex
Definition
InProcessModuleCache.h:52
clang::dependencies::ModuleCacheEntries::ValidateAgainstInvalidatedPaths
bool ValidateAgainstInvalidatedPaths
Definition
InProcessModuleCache.h:55
clang::dependencies::ModuleCacheEntry
Definition
InProcessModuleCache.h:30
clang::dependencies::ModuleCacheEntry::Timestamp
std::atomic< std::time_t > Timestamp
Definition
InProcessModuleCache.h:36
clang::dependencies::ModuleCacheEntry::S_Written
@ S_Written
Definition
InProcessModuleCache.h:41
clang::dependencies::ModuleCacheEntry::S_Read
@ S_Read
Definition
InProcessModuleCache.h:40
clang::dependencies::ModuleCacheEntry::S_Unknown
@ S_Unknown
Definition
InProcessModuleCache.h:39
clang::dependencies::ModuleCacheEntry::CondVar
std::condition_variable CondVar
Definition
InProcessModuleCache.h:32
clang::dependencies::ModuleCacheEntry::ModTime
time_t ModTime
The modification time of the entry.
Definition
InProcessModuleCache.h:48
clang::dependencies::ModuleCacheEntry::Buffer
std::shared_ptr< const llvm::MemoryBuffer > Buffer
The buffer we've read from disk or written to the module cache, if any.
Definition
InProcessModuleCache.h:46
clang::dependencies::ModuleCacheEntry::Locked
bool Locked
Definition
InProcessModuleCache.h:33
clang::dependencies::ModuleCacheEntry::Mutex
std::mutex Mutex
Definition
InProcessModuleCache.h:31
clang::dependencies::ModuleCacheEntry::Generation
unsigned Generation
Definition
InProcessModuleCache.h:34
Generated on
for clang by
1.14.0