LLVM 23.0.0git
BuiltinUnifiedCASDatabases.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_CAS_BUILTINUNIFIEDCASDATABASES_H
10#define LLVM_CAS_BUILTINUNIFIEDCASDATABASES_H
11
13#include "llvm/Support/Error.h"
14
15namespace llvm::cas {
16
17class ActionCache;
18class ObjectStore;
19
20/// Create on-disk \c ObjectStore and \c ActionCache instances based on
21/// \c ondisk::UnifiedOnDiskCache, with built-in hashing.
23Expected<std::pair<std::unique_ptr<ObjectStore>, std::unique_ptr<ActionCache>>>
25
26/// Validate the data in \p Path, if needed to ensure correctness.
27///
28/// \param Path directory for the on-disk database.
29/// \param CheckHash Whether to validate hashes match the data.
30/// \param AllowRecovery Whether to automatically recover from invalid data by
31/// marking the files for garbage collection.
32/// \param ForceValidation Whether to force validation to occur even if it
33/// should not be necessary.
34/// \param LLVMCasBinaryPath If provided, validation is performed out-of-process
35/// using the given \c llvm-cas executable which protects against crashes
36/// during validation. Otherwise validation is performed in-process.
37///
38/// \returns \c Valid if the data is already valid, \c Recovered if data
39/// was invalid but has been cleared, \c Skipped if validation is not needed,
40/// or an \c Error if validation cannot be performed or if the data is left
41/// in an invalid state because \p AllowRecovery is false.
43Expected<ValidationResult> validateOnDiskUnifiedCASDatabasesIfNeeded(
44 StringRef Path, bool CheckHash, bool AllowRecovery, bool ForceValidation,
45 std::optional<StringRef> LLVMCasBinaryPath);
46
47} // namespace llvm::cas
48
49#endif // LLVM_CAS_BUILTINUNIFIEDCASDATABASES_H
#define LLVM_ABI
Definition Compiler.h:213
A cache from a key (that describes an action) to the result of performing that action.
Definition ActionCache.h:49
Content-addressable storage for objects.
Definition ObjectStore.h:90
LLVM_ABI Expected< std::pair< std::unique_ptr< ObjectStore >, std::unique_ptr< ActionCache > > > createOnDiskUnifiedCASDatabases(StringRef Path)
Create on-disk ObjectStore and ActionCache instances based on ondisk::UnifiedOnDiskCache,...
LLVM_ABI Expected< ValidationResult > validateOnDiskUnifiedCASDatabasesIfNeeded(StringRef Path, bool CheckHash, bool AllowRecovery, bool ForceValidation, std::optional< StringRef > LLVMCasBinaryPath)
Validate the data in Path, if needed to ensure correctness.