clang 22.0.0git
ModuleCache.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_SERIALIZATION_MODULECACHE_H
10#define LLVM_CLANG_SERIALIZATION_MODULECACHE_H
11
12#include "clang/Basic/LLVM.h"
13#include "llvm/ADT/IntrusiveRefCntPtr.h"
14
15#include <ctime>
16
17namespace llvm {
18class AdvisoryLock;
19} // namespace llvm
20
21namespace clang {
22class InMemoryModuleCache;
23
24/// The module cache used for compiling modules implicitly. This centralizes the
25/// operations the compiler might want to perform on the cache.
26class ModuleCache : public RefCountedBase<ModuleCache> {
27public:
28 /// May perform any work that only needs to be performed once for multiple
29 /// calls \c getLock() with the same module filename.
30 virtual void prepareForGetLock(StringRef ModuleFilename) = 0;
31
32 /// Returns lock for the given module file. The lock is initially unlocked.
33 virtual std::unique_ptr<llvm::AdvisoryLock>
34 getLock(StringRef ModuleFilename) = 0;
35
36 // TODO: Abstract away timestamps with isUpToDate() and markUpToDate().
37 // TODO: Consider exposing a "validation lock" API to prevent multiple clients
38 // concurrently noticing an out-of-date module file and validating its inputs.
39
40 /// Returns the timestamp denoting the last time inputs of the module file
41 /// were validated.
42 virtual std::time_t getModuleTimestamp(StringRef ModuleFilename) = 0;
43
44 /// Updates the timestamp denoting the last time inputs of the module file
45 /// were validated.
46 virtual void updateModuleTimestamp(StringRef ModuleFilename) = 0;
47
48 /// Returns this process's view of the module cache.
50 virtual const InMemoryModuleCache &getInMemoryModuleCache() const = 0;
51
52 // TODO: Virtualize writing/reading PCM files, pruning, etc.
53
54 virtual ~ModuleCache() = default;
55};
56
57/// Creates new \c ModuleCache backed by a file system directory that may be
58/// operated on by multiple processes. This instance must be used across all
59/// \c CompilerInstance instances participating in building modules for single
60/// translation unit in order to share the same \c InMemoryModuleCache.
62} // namespace clang
63
64#endif
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
In-memory cache for modules.
The module cache used for compiling modules implicitly.
Definition: ModuleCache.h:26
virtual void prepareForGetLock(StringRef ModuleFilename)=0
May perform any work that only needs to be performed once for multiple calls getLock() with the same ...
virtual ~ModuleCache()=default
virtual const InMemoryModuleCache & getInMemoryModuleCache() const =0
virtual std::time_t getModuleTimestamp(StringRef ModuleFilename)=0
Returns the timestamp denoting the last time inputs of the module file were validated.
virtual InMemoryModuleCache & getInMemoryModuleCache()=0
Returns this process's view of the module cache.
virtual void updateModuleTimestamp(StringRef ModuleFilename)=0
Updates the timestamp denoting the last time inputs of the module file were validated.
virtual std::unique_ptr< llvm::AdvisoryLock > getLock(StringRef ModuleFilename)=0
Returns lock for the given module file. The lock is initially unlocked.
The JSON file list parser is used to communicate input to InstallAPI.
IntrusiveRefCntPtr< ModuleCache > createCrossProcessModuleCache()
Creates new ModuleCache backed by a file system directory that may be operated on by multiple process...
Definition: ModuleCache.cpp:63
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30