LLVM 22.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
12#include "llvm/Support/Error.h"
13
14namespace llvm::cas {
15
16class ActionCache;
17class ObjectStore;
18
19/// Create on-disk \c ObjectStore and \c ActionCache instances based on
20/// \c ondisk::UnifiedOnDiskCache, with built-in hashing.
22Expected<std::pair<std::unique_ptr<ObjectStore>, std::unique_ptr<ActionCache>>>
24
25/// Represents the result of validating the contents using
26/// \c validateOnDiskUnifiedCASDatabasesIfNeeded.
27///
28/// Note: invalid results are handled as an \c Error.
29enum class ValidationResult {
30 /// The data is already valid.
32 /// The data was invalid, but was recovered.
34 /// Validation was skipped, as it was not needed.
36};
37
38/// Validate the data in \p Path, if needed to ensure correctness.
39///
40/// \param Path directory for the on-disk database.
41/// \param CheckHash Whether to validate hashes match the data.
42/// \param AllowRecovery Whether to automatically recover from invalid data by
43/// marking the files for garbage collection.
44/// \param ForceValidation Whether to force validation to occur even if it
45/// should not be necessary.
46/// \param LLVMCasBinaryPath If provided, validation is performed out-of-process
47/// using the given \c llvm-cas executable which protects against crashes
48/// during validation. Otherwise validation is performed in-process.
49///
50/// \returns \c Valid if the data is already valid, \c Recovered if data
51/// was invalid but has been cleared, \c Skipped if validation is not needed,
52/// or an \c Error if validation cannot be performed or if the data is left
53/// in an invalid state because \p AllowRecovery is false.
55 StringRef Path, bool CheckHash, bool AllowRecovery, bool ForceValidation,
56 std::optional<StringRef> LLVMCasBinaryPath);
57
58} // namespace llvm::cas
59
60#endif // LLVM_CAS_BUILTINUNIFIEDCASDATABASES_H
#define LLVM_ABI
Definition Compiler.h:213
Tagged union holding either a T or a Error.
Definition Error.h:485
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
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,...
ValidationResult
Represents the result of validating the contents using validateOnDiskUnifiedCASDatabasesIfNeeded.
@ Valid
The data is already valid.
@ Recovered
The data was invalid, but was recovered.
@ Skipped
Validation was skipped, as it was not needed.
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.