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.
21Expected<std::pair<std::unique_ptr<ObjectStore>, std::unique_ptr<ActionCache>>>
23
24/// Represents the result of validating the contents using
25/// \c validateOnDiskUnifiedCASDatabasesIfNeeded.
26///
27/// Note: invalid results are handled as an \c Error.
28enum class ValidationResult {
29 /// The data is already valid.
31 /// The data was invalid, but was recovered.
33 /// Validation was skipped, as it was not needed.
35};
36
37/// Validate the data in \p Path, if needed to ensure correctness.
38///
39/// \param Path directory for the on-disk database.
40/// \param CheckHash Whether to validate hashes match the data.
41/// \param AllowRecovery Whether to automatically recover from invalid data by
42/// marking the files for garbage collection.
43/// \param ForceValidation Whether to force validation to occur even if it
44/// should not be necessary.
45/// \param LLVMCasBinaryPath If provided, validation is performed out-of-process
46/// using the given \c llvm-cas executable which protects against crashes
47/// during validation. Otherwise validation is performed in-process.
48///
49/// \returns \c Valid if the data is already valid, \c Recovered if data
50/// was invalid but has been cleared, \c Skipped if validation is not needed,
51/// or an \c Error if validation cannot be performed or if the data is left
52/// in an invalid state because \p AllowRecovery is false.
54 StringRef Path, bool CheckHash, bool AllowRecovery, bool ForceValidation,
55 std::optional<StringRef> LLVMCasBinaryPath);
56
57} // namespace llvm::cas
58
59#endif // LLVM_CAS_BUILTINUNIFIEDCASDATABASES_H
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
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.