[llvm] [CAS] Add LLVMCAS library with InMemoryCAS implementation (PR #114096)
Paul Kirth via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 8 15:55:40 PDT 2025
================
@@ -0,0 +1,156 @@
+//===- llvm/CAS/CASID.h -----------------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_CAS_CASID_H
+#define LLVM_CAS_CASID_H
+
+#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMapInfo.h"
+#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/Error.h"
+
+namespace llvm {
+
+class raw_ostream;
+
+namespace cas {
+
+class CASID;
+
+/// Context for CAS identifiers.
+class CASContext {
+ virtual void anchor();
+
+public:
+ virtual ~CASContext() = default;
+
+ /// Get an identifer for the schema used by this CAS context. Two CAS
+ /// instances should return \c true for this identifier if and only if their
+ /// CASIDs are safe to compare by hash. This is used by \a
+ /// CASID::equalsImpl().
+ virtual StringRef getHashSchemaIdentifier() const = 0;
+
+protected:
+ /// Print \p ID to \p OS.
+ virtual void printIDImpl(raw_ostream &OS, const CASID &ID) const = 0;
+
+ friend class CASID;
+};
+
+/// Unique identifier for a CAS object.
+///
+/// Locally, stores an internal CAS identifier that's specific to a single CAS
+/// instance. It's guaranteed not to change across the view of that CAS, but
+/// might change between runs.
+///
+/// It also has \a CASIDContext pointer to allow comparison of these
+/// identifiers. If two CASIDs are from the same CASIDContext, they can be
+/// compared directly. If they are, then \a
+/// CASIDContext::getHashSchemaIdentifier() is compared to see if they can be
+/// compared by hash, in which case the result of \a getHash() is compared.
+class CASID {
+public:
----------------
ilovepi wrote:
Shouldn't the public methods have documentation comments?
https://github.com/llvm/llvm-project/pull/114096
More information about the llvm-commits
mailing list