[clang] 8e7c1b9 - [clang][Interp][NFCI] Make InitMap::isInitialized() const
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Sat Jan 21 23:34:36 PST 2023
Author: Timm Bäder
Date: 2023-01-22T08:33:40+01:00
New Revision: 8e7c1b9a3d5f08046261ca0b7e5d319a4c4c9b25
URL: https://github.com/llvm/llvm-project/commit/8e7c1b9a3d5f08046261ca0b7e5d319a4c4c9b25
DIFF: https://github.com/llvm/llvm-project/commit/8e7c1b9a3d5f08046261ca0b7e5d319a4c4c9b25.diff
LOG: [clang][Interp][NFCI] Make InitMap::isInitialized() const
Added:
Modified:
clang/lib/AST/Interp/Descriptor.cpp
clang/lib/AST/Interp/Descriptor.h
Removed:
################################################################################
diff --git a/clang/lib/AST/Interp/Descriptor.cpp b/clang/lib/AST/Interp/Descriptor.cpp
index 09e0b650eb67..70294af7dea7 100644
--- a/clang/lib/AST/Interp/Descriptor.cpp
+++ b/clang/lib/AST/Interp/Descriptor.cpp
@@ -280,6 +280,11 @@ InitMap::T *InitMap::data() {
return reinterpret_cast<T *>(Start);
}
+const InitMap::T *InitMap::data() const {
+ auto *Start = reinterpret_cast<const char *>(this) + align(sizeof(InitMap));
+ return reinterpret_cast<const T *>(Start);
+}
+
bool InitMap::initialize(unsigned I) {
unsigned Bucket = I / PER_FIELD;
T Mask = T(1) << (I % PER_FIELD);
@@ -290,7 +295,7 @@ bool InitMap::initialize(unsigned I) {
return UninitFields == 0;
}
-bool InitMap::isInitialized(unsigned I) {
+bool InitMap::isInitialized(unsigned I) const {
unsigned Bucket = I / PER_FIELD;
return data()[Bucket] & (T(1) << (I % PER_FIELD));
}
diff --git a/clang/lib/AST/Interp/Descriptor.h b/clang/lib/AST/Interp/Descriptor.h
index ae39d38d8184..730d66b0cb64 100644
--- a/clang/lib/AST/Interp/Descriptor.h
+++ b/clang/lib/AST/Interp/Descriptor.h
@@ -205,13 +205,14 @@ struct InitMap final {
/// Returns a pointer to storage.
T *data();
+ const T *data() const;
public:
/// Initializes an element. Returns true when object if fully initialized.
bool initialize(unsigned I);
/// Checks if an element was initialized.
- bool isInitialized(unsigned I);
+ bool isInitialized(unsigned I) const;
/// Allocates a map holding N elements.
static InitMap *allocate(unsigned N);
More information about the cfe-commits
mailing list