[clang] 7c4cad4 - [clang][Interp][NFC] Make a few InterpStack functions const
Timm Bäder via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 29 03:51:28 PDT 2022
Author: Timm Bäder
Date: 2022-09-29T12:50:55+02:00
New Revision: 7c4cad43309ebce4a9f3c656ca4629f8ac9ed877
URL: https://github.com/llvm/llvm-project/commit/7c4cad43309ebce4a9f3c656ca4629f8ac9ed877
DIFF: https://github.com/llvm/llvm-project/commit/7c4cad43309ebce4a9f3c656ca4629f8ac9ed877.diff
LOG: [clang][Interp][NFC] Make a few InterpStack functions const
Added:
Modified:
clang/lib/AST/Interp/InterpStack.cpp
clang/lib/AST/Interp/InterpStack.h
Removed:
################################################################################
diff --git a/clang/lib/AST/Interp/InterpStack.cpp b/clang/lib/AST/Interp/InterpStack.cpp
index 5c803f3d9424..7fe678e62192 100644
--- a/clang/lib/AST/Interp/InterpStack.cpp
+++ b/clang/lib/AST/Interp/InterpStack.cpp
@@ -46,7 +46,7 @@ void *InterpStack::grow(size_t Size) {
return Object;
}
-void *InterpStack::peek(size_t Size) {
+void *InterpStack::peek(size_t Size) const {
assert(Chunk && "Stack is empty!");
StackChunk *Ptr = Chunk;
diff --git a/clang/lib/AST/Interp/InterpStack.h b/clang/lib/AST/Interp/InterpStack.h
index b02d3c6a34b0..2888f88fe6d7 100644
--- a/clang/lib/AST/Interp/InterpStack.h
+++ b/clang/lib/AST/Interp/InterpStack.h
@@ -48,12 +48,12 @@ class InterpStack final {
}
/// Returns a reference to the value on the top of the stack.
- template <typename T> T &peek() {
+ template <typename T> T &peek() const {
return *reinterpret_cast<T *>(peek(aligned_size<T>()));
}
/// Returns a pointer to the top object.
- void *top() { return Chunk ? peek(0) : nullptr; }
+ void *top() const { return Chunk ? peek(0) : nullptr; }
/// Returns the size of the stack in bytes.
size_t size() const { return StackSize; }
@@ -72,7 +72,7 @@ class InterpStack final {
/// Grows the stack to accommodate a value and returns a pointer to it.
void *grow(size_t Size);
/// Returns a pointer from the top of the stack.
- void *peek(size_t Size);
+ void *peek(size_t Size) const;
/// Shrinks the stack.
void shrink(size_t Size);
@@ -94,10 +94,13 @@ class InterpStack final {
: Next(nullptr), Prev(Prev), End(reinterpret_cast<char *>(this + 1)) {}
/// Returns the size of the chunk, minus the header.
- size_t size() { return End - start(); }
+ size_t size() const { return End - start(); }
/// Returns a pointer to the start of the data region.
char *start() { return reinterpret_cast<char *>(this + 1); }
+ const char *start() const {
+ return reinterpret_cast<const char *>(this + 1);
+ }
};
static_assert(sizeof(StackChunk) < ChunkSize, "Invalid chunk size");
More information about the cfe-commits
mailing list