Skip to content

Commit dd47c8a

Browse files
committed
[llvm/CAS] Move createOnDiskUnifiedCASDatabases function to a separate header than ObjectStore.h
1 parent cfb3eb8 commit dd47c8a

File tree

8 files changed

+55
-18
lines changed

8 files changed

+55
-18
lines changed

clang/lib/CAS/CASOptions.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "clang/Basic/Diagnostic.h"
1111
#include "clang/Basic/DiagnosticCAS.h"
1212
#include "llvm/CAS/ActionCache.h"
13+
#include "llvm/CAS/BuiltinUnifiedCASDatabases.h"
1314
#include "llvm/CAS/ObjectStore.h"
1415
#include "llvm/Support/Path.h"
1516

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
//===- BuiltinUnifiedCASDatabases.h -----------------------------*- C++ -*-===//
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+
14+
namespace llvm::cas {
15+
16+
class ActionCache;
17+
class ObjectStore;
18+
19+
/// Create on-disk \c ObjectStore and \c ActionCache instances based on
20+
/// \c ondisk::UnifiedOnDiskCache, with built-in hashing.
21+
Expected<std::pair<std::unique_ptr<ObjectStore>, std::unique_ptr<ActionCache>>>
22+
createOnDiskUnifiedCASDatabases(StringRef Path);
23+
24+
} // namespace llvm::cas
25+
26+
#endif // LLVM_CAS_BUILTINUNIFIEDCASDATABASES_H

llvm/include/llvm/CAS/ObjectStore.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -381,13 +381,6 @@ using ObjectStoreCreateFuncTy =
381381
Expected<std::unique_ptr<ObjectStore>>(const Twine &);
382382
void registerCASURLScheme(StringRef Prefix, ObjectStoreCreateFuncTy *Func);
383383

384-
class ActionCache;
385-
386-
/// Create on-disk \p ObjectStore and \p ActionCache instances based on \p
387-
/// ondisk::UnifiedOnDiskCache.
388-
Expected<std::pair<std::unique_ptr<ObjectStore>, std::unique_ptr<ActionCache>>>
389-
createOnDiskUnifiedCASDatabases(StringRef Path);
390-
391384
} // namespace cas
392385
} // namespace llvm
393386

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//===- BuiltinUnifiedCASDatabases.cpp ---------------------------*- C++ -*-===//
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+
#include "llvm/CAS/BuiltinUnifiedCASDatabases.h"
10+
#include "BuiltinCAS.h"
11+
#include "llvm/CAS/ActionCache.h"
12+
#include "llvm/CAS/UnifiedOnDiskCache.h"
13+
14+
using namespace llvm;
15+
using namespace llvm::cas;
16+
17+
Expected<std::pair<std::unique_ptr<ObjectStore>, std::unique_ptr<ActionCache>>>
18+
cas::createOnDiskUnifiedCASDatabases(StringRef Path) {
19+
std::shared_ptr<ondisk::UnifiedOnDiskCache> UniDB;
20+
if (Error E = builtin::createBuiltinUnifiedOnDiskCache(Path).moveInto(UniDB))
21+
return std::move(E);
22+
auto CAS = builtin::createObjectStoreFromUnifiedOnDiskCache(UniDB);
23+
auto AC = builtin::createActionCacheFromUnifiedOnDiskCache(std::move(UniDB));
24+
return std::make_pair(std::move(CAS), std::move(AC));
25+
}

llvm/lib/CAS/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ add_llvm_component_library(LLVMCAS
66
ActionCache.cpp
77
ActionCaches.cpp
88
BuiltinCAS.cpp
9+
BuiltinUnifiedCASDatabases.cpp
910
CASFileSystem.cpp
1011
CASNodeSchema.cpp
1112
CASOutputBackend.cpp

llvm/lib/CAS/ObjectStore.cpp

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
#include "BuiltinCAS.h"
1111
#include "llvm/ADT/DenseSet.h"
1212
#include "llvm/ADT/StringMap.h"
13-
#include "llvm/CAS/ActionCache.h"
1413
#include "llvm/CAS/UnifiedOnDiskCache.h"
1514
#include "llvm/Support/Debug.h"
1615
#include "llvm/Support/FileSystem.h"
@@ -192,13 +191,3 @@ void cas::registerCASURLScheme(StringRef Prefix,
192191
ObjectStoreCreateFuncTy *Func) {
193192
getRegisteredScheme().insert({Prefix, Func});
194193
}
195-
196-
Expected<std::pair<std::unique_ptr<ObjectStore>, std::unique_ptr<ActionCache>>>
197-
cas::createOnDiskUnifiedCASDatabases(StringRef Path) {
198-
std::shared_ptr<ondisk::UnifiedOnDiskCache> UniDB;
199-
if (Error E = builtin::createBuiltinUnifiedOnDiskCache(Path).moveInto(UniDB))
200-
return std::move(E);
201-
auto CAS = builtin::createObjectStoreFromUnifiedOnDiskCache(UniDB);
202-
auto AC = builtin::createActionCacheFromUnifiedOnDiskCache(std::move(UniDB));
203-
return std::make_pair(std::move(CAS), std::move(AC));
204-
}

llvm/tools/llvm-cas/llvm-cas.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "llvm/ADT/Optional.h"
1010
#include "llvm/CAS/ActionCache.h"
11+
#include "llvm/CAS/BuiltinUnifiedCASDatabases.h"
1112
#include "llvm/CAS/CASFileSystem.h"
1213
#include "llvm/CAS/CachingOnDiskFileSystem.h"
1314
#include "llvm/CAS/HierarchicalTreeBuilder.h"

llvm/tools/llvm-remote-cache-test/llvm-remote-cache-test.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "llvm/CAS/ActionCache.h"
14+
#include "llvm/CAS/BuiltinUnifiedCASDatabases.h"
1415
#include "llvm/CAS/ObjectStore.h"
1516
#include "llvm/RemoteCachingService/LLVMCASCacheProvider.h"
1617
#include "llvm/RemoteCachingService/RemoteCacheProvider.h"

0 commit comments

Comments
 (0)