[llvm] [CAS] LLVMCAS implementation (PR #68448)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Oct 6 14:01:15 PDT 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff a9138cdb36ccc79bff4dae9b050aa0a01b8ba809 5113476801d0df97d53336ed1d12e41c6b8874ac -- llvm/include/llvm/ADT/TrieRawHashMap.h llvm/include/llvm/CAS/ActionCache.h llvm/include/llvm/CAS/BuiltinCASContext.h llvm/include/llvm/CAS/BuiltinObjectHasher.h llvm/include/llvm/CAS/BuiltinUnifiedCASDatabases.h llvm/include/llvm/CAS/CASFileSystem.h llvm/include/llvm/CAS/CASID.h llvm/include/llvm/CAS/CASNodeSchema.h llvm/include/llvm/CAS/CASReference.h llvm/include/llvm/CAS/HierarchicalTreeBuilder.h llvm/include/llvm/CAS/MappedFileRegionBumpPtr.h llvm/include/llvm/CAS/ObjectStore.h llvm/include/llvm/CAS/OnDiskGraphDB.h llvm/include/llvm/CAS/OnDiskHashMappedTrie.h llvm/include/llvm/CAS/OnDiskKeyValueDB.h llvm/include/llvm/CAS/TreeEntry.h llvm/include/llvm/CAS/TreeSchema.h llvm/include/llvm/CAS/UnifiedOnDiskCache.h llvm/lib/CAS/ActionCache.cpp llvm/lib/CAS/ActionCaches.cpp llvm/lib/CAS/BuiltinCAS.cpp llvm/lib/CAS/BuiltinCAS.h llvm/lib/CAS/BuiltinObjectHasher.h llvm/lib/CAS/BuiltinUnifiedCASDatabases.cpp llvm/lib/CAS/CASNodeSchema.cpp llvm/lib/CAS/HashMappedTrieIndexGenerator.h llvm/lib/CAS/HierarchicalTreeBuilder.cpp llvm/lib/CAS/InMemoryCAS.cpp llvm/lib/CAS/MappedFileRegionBumpPtr.cpp llvm/lib/CAS/ObjectStore.cpp llvm/lib/CAS/OnDiskCAS.cpp llvm/lib/CAS/OnDiskCommon.cpp llvm/lib/CAS/OnDiskCommon.h llvm/lib/CAS/OnDiskGraphDB.cpp llvm/lib/CAS/OnDiskHashMappedTrie.cpp llvm/lib/CAS/OnDiskKeyValueDB.cpp llvm/lib/CAS/TreeEntry.cpp llvm/lib/CAS/TreeSchema.cpp llvm/lib/CAS/UnifiedOnDiskCache.cpp llvm/lib/Support/TrieHashIndexGenerator.h llvm/lib/Support/TrieRawHashMap.cpp llvm/tools/llvm-cas/llvm-cas.cpp llvm/unittests/ADT/TrieRawHashMapTest.cpp llvm/unittests/CAS/CASTestConfig.cpp llvm/unittests/CAS/CASTestConfig.h llvm/unittests/CAS/ObjectStoreTest.cpp llvm/include/llvm/Support/FileSystem.h
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/llvm/include/llvm/CAS/BuiltinObjectHasher.h b/llvm/include/llvm/CAS/BuiltinObjectHasher.h
index ea5eadf98..008179252 100644
--- a/llvm/include/llvm/CAS/BuiltinObjectHasher.h
+++ b/llvm/include/llvm/CAS/BuiltinObjectHasher.h
@@ -64,13 +64,13 @@ private:
void updateArray(ArrayRef<char> Bytes) {
updateArray(ArrayRef(reinterpret_cast<const uint8_t *>(Bytes.data()),
- Bytes.size()));
+ Bytes.size()));
}
void updateSize(uint64_t Size) {
Size = support::endian::byte_swap(Size, support::endianness::little);
- Hasher.update(ArrayRef(reinterpret_cast<const uint8_t *>(&Size),
- sizeof(Size)));
+ Hasher.update(
+ ArrayRef(reinterpret_cast<const uint8_t *>(&Size), sizeof(Size)));
}
BuiltinObjectHasher() = default;
diff --git a/llvm/include/llvm/CAS/ObjectStore.h b/llvm/include/llvm/CAS/ObjectStore.h
index 22afdc92b..16c133198 100644
--- a/llvm/include/llvm/CAS/ObjectStore.h
+++ b/llvm/include/llvm/CAS/ObjectStore.h
@@ -355,7 +355,6 @@ using ObjectStoreCreateFuncTy =
Expected<std::shared_ptr<ObjectStore>>(const Twine &);
void registerCASURLScheme(StringRef Prefix, ObjectStoreCreateFuncTy *Func);
-
} // namespace cas
} // namespace llvm
diff --git a/llvm/include/llvm/CAS/OnDiskKeyValueDB.h b/llvm/include/llvm/CAS/OnDiskKeyValueDB.h
index 00b1a2e35..a6b4b1249 100644
--- a/llvm/include/llvm/CAS/OnDiskKeyValueDB.h
+++ b/llvm/include/llvm/CAS/OnDiskKeyValueDB.h
@@ -35,9 +35,7 @@ public:
Expected<std::optional<ArrayRef<char>>> get(ArrayRef<uint8_t> Key);
/// \returns Total size of stored data.
- size_t getStorageSize() const {
- return Cache.size();
- }
+ size_t getStorageSize() const { return Cache.size(); }
/// Open the on-disk store from a directory.
///
diff --git a/llvm/include/llvm/CAS/TreeSchema.h b/llvm/include/llvm/CAS/TreeSchema.h
index e4bc55c78..c9329751a 100644
--- a/llvm/include/llvm/CAS/TreeSchema.h
+++ b/llvm/include/llvm/CAS/TreeSchema.h
@@ -69,10 +69,10 @@ private:
class TreeProxy : public ObjectProxy {
public:
static Expected<TreeProxy> get(const TreeSchema &Schema,
- Expected<ObjectProxy> Ref);
+ Expected<ObjectProxy> Ref);
static Expected<TreeProxy> create(TreeSchema &Schema,
- ArrayRef<NamedTreeEntry> Entries);
+ ArrayRef<NamedTreeEntry> Entries);
const TreeSchema &getSchema() const { return *Schema; }
diff --git a/llvm/lib/CAS/InMemoryCAS.cpp b/llvm/lib/CAS/InMemoryCAS.cpp
index 9c4f2bce5..378e822d2 100644
--- a/llvm/lib/CAS/InMemoryCAS.cpp
+++ b/llvm/lib/CAS/InMemoryCAS.cpp
@@ -33,7 +33,6 @@ using InMemoryIndexT =
/// their hash.
using InMemoryIndexValueT = InMemoryIndexT::value_type;
-
class InMemoryObject {
public:
enum class Kind {
@@ -118,15 +117,15 @@ public:
ArrayRef<const InMemoryObject *> getRefs() const { return getRefsImpl(); }
ArrayRef<const InMemoryObject *> getRefsImpl() const {
- return ArrayRef(
- reinterpret_cast<const InMemoryObject *const *>(this + 1), NumRefs);
+ return ArrayRef(reinterpret_cast<const InMemoryObject *const *>(this + 1),
+ NumRefs);
}
ArrayRef<char> getData() const { return getDataImpl(); }
ArrayRef<char> getDataImpl() const {
ArrayRef<const InMemoryObject *> Refs = getRefs();
- return ArrayRef(
- reinterpret_cast<const char *>(Refs.data() + Refs.size()), DataSize);
+ return ArrayRef(reinterpret_cast<const char *>(Refs.data() + Refs.size()),
+ DataSize);
}
static InMemoryInlineObject &
diff --git a/llvm/lib/CAS/OnDiskHashMappedTrie.cpp b/llvm/lib/CAS/OnDiskHashMappedTrie.cpp
index 9621cb94f..09fef70ee 100644
--- a/llvm/lib/CAS/OnDiskHashMappedTrie.cpp
+++ b/llvm/lib/CAS/OnDiskHashMappedTrie.cpp
@@ -624,7 +624,7 @@ HashMappedTrieHandle::getRecord(SubtrieSlotValue Offset) {
OnDiskHashMappedTrie::ValueProxy Proxy;
Proxy.Data = MutableArrayRef(Begin, getRecordDataSize());
Proxy.Hash = ArrayRef(reinterpret_cast<const uint8_t *>(Proxy.Data.end()),
- getNumHashBytes());
+ getNumHashBytes());
return RecordData{Proxy, Offset};
}
diff --git a/llvm/lib/CAS/TreeSchema.cpp b/llvm/lib/CAS/TreeSchema.cpp
index db7bdaab6..91f3d8e3d 100644
--- a/llvm/lib/CAS/TreeSchema.cpp
+++ b/llvm/lib/CAS/TreeSchema.cpp
@@ -152,13 +152,12 @@ Expected<TreeProxy> TreeSchema::load(ObjectProxy Object) const {
return TreeProxy::get(*this, Object);
}
-Expected<TreeProxy>
-TreeSchema::create(ArrayRef<NamedTreeEntry> Entries) {
+Expected<TreeProxy> TreeSchema::create(ArrayRef<NamedTreeEntry> Entries) {
return TreeProxy::create(*this, Entries);
}
Expected<TreeProxy> TreeProxy::get(const TreeSchema &Schema,
- Expected<ObjectProxy> Ref) {
+ Expected<ObjectProxy> Ref) {
if (!Ref)
return Ref.takeError();
return TreeProxy(Schema, *Ref);
@@ -182,8 +181,7 @@ StringRef TreeProxy::getName(size_t I) const {
return StringRef(getData().data() + StartIdx, EndIdx - StartIdx);
}
-Expected<TreeProxy::Builder>
-TreeProxy::Builder::startNode(TreeSchema &Schema) {
+Expected<TreeProxy::Builder> TreeProxy::Builder::startNode(TreeSchema &Schema) {
Builder B(Schema);
B.Refs.push_back(Schema.getKindRef());
return std::move(B);
diff --git a/llvm/tools/llvm-cas/llvm-cas.cpp b/llvm/tools/llvm-cas/llvm-cas.cpp
index 272862da0..5aa44b880 100644
--- a/llvm/tools/llvm-cas/llvm-cas.cpp
+++ b/llvm/tools/llvm-cas/llvm-cas.cpp
@@ -25,8 +25,9 @@
using namespace llvm;
using namespace llvm::cas;
-static cl::opt<bool> AllTrees("all-trees",
- cl::desc("Print all trees, not just empty ones, for ls-tree-recursive"));
+static cl::opt<bool> AllTrees(
+ "all-trees",
+ cl::desc("Print all trees, not just empty ones, for ls-tree-recursive"));
static cl::list<std::string> Inputs(cl::Positional, cl::desc("Input object"));
static int dump(ObjectStore &CAS);
@@ -230,13 +231,12 @@ int listTreeRecursively(ObjectStore &CAS, const CASID &ID) {
int catBlob(ObjectStore &CAS, const CASID &ID) { return catNodeData(CAS, ID); }
-static Expected<std::unique_ptr<MemoryBuffer>>
-openBuffer(StringRef DataPath) {
+static Expected<std::unique_ptr<MemoryBuffer>> openBuffer(StringRef DataPath) {
if (DataPath.empty())
return createStringError(inconvertibleErrorCode(), "--data missing");
- return errorOrToExpected(
- DataPath == "-" ? llvm::MemoryBuffer::getSTDIN()
- : llvm::MemoryBuffer::getFile(DataPath));
+ return errorOrToExpected(DataPath == "-"
+ ? llvm::MemoryBuffer::getSTDIN()
+ : llvm::MemoryBuffer::getFile(DataPath));
}
int dump(ObjectStore &CAS) {
diff --git a/llvm/unittests/ADT/TrieRawHashMapTest.cpp b/llvm/unittests/ADT/TrieRawHashMapTest.cpp
index 209810d14..b93b961a2 100644
--- a/llvm/unittests/ADT/TrieRawHashMapTest.cpp
+++ b/llvm/unittests/ADT/TrieRawHashMapTest.cpp
@@ -63,9 +63,7 @@ public:
return Ret;
}
- void destroyTrie() {
- Trie.reset();
- }
+ void destroyTrie() { Trie.reset(); }
~SimpleTrieHashMapTest() {
if (Trie)
@@ -179,8 +177,7 @@ TEST_F(SmallNodeTrieTest, TrieStructure) {
// Check last subtrie.
// Last allocated trie is the next node in the allocation chain.
auto LastAlloctedSubTrie = getNextTrie(getRoot());
- ASSERT_EQ(getTriePrefixAsString(LastAlloctedSubTrie),
- "fffffffffffffff[110]");
+ ASSERT_EQ(getTriePrefixAsString(LastAlloctedSubTrie), "fffffffffffffff[110]");
ASSERT_EQ(getStartBit(LastAlloctedSubTrie), 63u);
ASSERT_EQ(getNumBits(LastAlloctedSubTrie), 1u);
ASSERT_EQ(getNumSlotUsed(LastAlloctedSubTrie), 2u);
@@ -245,8 +242,7 @@ TEST_F(SmallNodeTrieTest, TrieStructureSmallFinalSubtrie) {
// Check last subtrie.
// Last allocated trie is the next node in the allocation chain.
auto LastAlloctedSubTrie = getNextTrie(getRoot());
- ASSERT_EQ(getTriePrefixAsString(LastAlloctedSubTrie),
- "fffffffffffffff[110]");
+ ASSERT_EQ(getTriePrefixAsString(LastAlloctedSubTrie), "fffffffffffffff[110]");
ASSERT_EQ(getStartBit(LastAlloctedSubTrie), 63u);
ASSERT_EQ(getNumBits(LastAlloctedSubTrie), 1u);
ASSERT_EQ(getNumSlotUsed(LastAlloctedSubTrie), 2u);
@@ -315,9 +311,8 @@ TEST_F(NumStrNodeTrieTest, TrieInsertLazy) {
auto insertNum = [&](uint64_t Num) {
std::string S = Twine(I).str();
auto Hash = hash(Num);
- return Trie.insertLazy(Hash, [&](TrieType::LazyValueConstructor C) {
- C(std::move(S));
- });
+ return Trie.insertLazy(
+ Hash, [&](TrieType::LazyValueConstructor C) { C(std::move(S)); });
};
auto S1 = insertNum(I);
// The address of the Data should be the same.
``````````
</details>
https://github.com/llvm/llvm-project/pull/68448
More information about the llvm-commits
mailing list